45
Michael K. Smith, PGRD Sandwich . Software for non-linear mixed effects modelling Michael K. Smith, PGRD Sandwich 12 May 2004 RSS meeting, London

Software for Nonlinear mixed effects - University of Glasgow · PDF fileSoftware for non-linear mixed effects modelling ... S-Plus, SAS, WinNonmix, PKBUGS / Pharmaco ... in order to

  • Upload
    lyquynh

  • View
    213

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Software for Nonlinear mixed effects - University of Glasgow · PDF fileSoftware for non-linear mixed effects modelling ... S-Plus, SAS, WinNonmix, PKBUGS / Pharmaco ... in order to

Michael K. Smith, PGRD Sandwich.

Software for non-linear mixed effects modelling

Michael K. Smith, PGRD Sandwich12 May 2004

RSS meeting, London

Page 2: Software for Nonlinear mixed effects - University of Glasgow · PDF fileSoftware for non-linear mixed effects modelling ... S-Plus, SAS, WinNonmix, PKBUGS / Pharmaco ... in order to

Michael K. Smith, PGRD Sandwich.

Contents

• When should I use these models?• Are they just about pharmacokinetics?• Some general points about methodology• Software review:

– NONMEM, S-Plus, SAS, WinNonmix, PKBUGS / Pharmaco

• Theophylline example – PK– Comparison of results between software packages.

• More about methodology– Points to watch out for.– Hints and tips

• Recommendations– Or not!

Page 3: Software for Nonlinear mixed effects - University of Glasgow · PDF fileSoftware for non-linear mixed effects modelling ... S-Plus, SAS, WinNonmix, PKBUGS / Pharmaco ... in order to

Michael K. Smith, PGRD Sandwich.

When should I use these models?

• Imagine we have repeated measures data– Response measured across time, concentration or dose.– Response is a non-linear function with time, conc., dose.– Wish to describe the subject-to-subject variability in key

parameters of the non-linear function.

• We have information between subjects and some information within a subject.– Across all data = how the response changes over time.– Between subjects = what factors make groups of subjects

different?– Within subjects = How does the joint model fit this subject?

Page 4: Software for Nonlinear mixed effects - University of Glasgow · PDF fileSoftware for non-linear mixed effects modelling ... S-Plus, SAS, WinNonmix, PKBUGS / Pharmaco ... in order to

Michael K. Smith, PGRD Sandwich.

Examples

• Emax function: Effect is a function of dose.

0 100 200 300 400

20

40

60

80

100

120

Dose

Effe

ct

)50(,ij

jiji EDdose

doseEmaxEffect

=

Emax = maximum possible effectED50 = dose to get 50% of the maximum effect.

OBVIOUSLY SIMULATED DATA!!!

• Does the maximum possible effect depend on baseline or disease status?

Page 5: Software for Nonlinear mixed effects - University of Glasgow · PDF fileSoftware for non-linear mixed effects modelling ... S-Plus, SAS, WinNonmix, PKBUGS / Pharmaco ... in order to

Michael K. Smith, PGRD Sandwich.

• PK data – Theophylline

• Does body weight influence the Clearance or elimination rate constant?

Time (h)

0

2

4

6

8

10

0 5 10 15 20 25

The

ophy

lline

con

cent

ratio

n (m

g/L)

Examples

[ ])exp()exp()(

tktkkkCl

kDkCp ae

ea

ae −−−−

=

Cl = Drug clearance (L/hr)Ka = Absorption rate const.Ke = Elimination rate const.D = Doset = time

THIS TIME IT’S REAL DATA!!!

Page 6: Software for Nonlinear mixed effects - University of Glasgow · PDF fileSoftware for non-linear mixed effects modelling ... S-Plus, SAS, WinNonmix, PKBUGS / Pharmaco ... in order to

Michael K. Smith, PGRD Sandwich.

• PK data – Theophylline

• Here we fitted the model described in the last slide to the first subject’s data.

• Looking across all subjects we can see if bodyweight influences Clearance.

Examples

55 60 65 70 75 80 85

-0.4

-0.2

0.0

0.2

0.4

Wt

lCl

0 5 10 15 20 25

Time (h)

24

68

10

The

ophy

lline

conc

entr

atio

n (m

g/L)

Page 7: Software for Nonlinear mixed effects - University of Glasgow · PDF fileSoftware for non-linear mixed effects modelling ... S-Plus, SAS, WinNonmix, PKBUGS / Pharmaco ... in order to

Michael K. Smith, PGRD Sandwich.

Not just for pharmacokineticists...

• True, most examples from industry are based on PK.– Other examples: Efficacy, Disease models, growth models.

• It can help enormously with exposure-response relationships.– Designs with multiple doses per individual.– Can use Emax models to describe the dose-response (or

concentration-response).– A growing area. FDA Guidance issued March 2002 (initial

draft 2 years before that!).

• May help you better understand your data.– Assuming a simple linear model, or quadratic function for

may make things easier, but is it sensible from a physiological / biological point of view?

Page 8: Software for Nonlinear mixed effects - University of Glasgow · PDF fileSoftware for non-linear mixed effects modelling ... S-Plus, SAS, WinNonmix, PKBUGS / Pharmaco ... in order to

Michael K. Smith, PGRD Sandwich.

Non-linear mixed effects models

• Hierarchical model.– Non-linear model describing change in response across

repeated measures (time, concentration, dose etc.)– Linear mixed effects model describing how the parameters

of the non-linear model differ between individuals.

• Sources of variability:– Within subjects = model misspecification, measurement

error.– Between subjects = differences between subjects in

covariates, possible influence of unmeasured covariates.

Page 9: Software for Nonlinear mixed effects - University of Glasgow · PDF fileSoftware for non-linear mixed effects modelling ... S-Plus, SAS, WinNonmix, PKBUGS / Pharmaco ... in order to

Michael K. Smith, PGRD Sandwich.

Basic methods - “Global Two Stage”• If we have lots (& roughly same amount) of data on

each individual / experimental unit…– Fit the non-linear model to each individual.– Obtain the parameters of the non-linear function for each

individual.– Fit linear mixed effects models on these parameters,

incorporating covariates etc.

• Easy to do.– This uses only the basic non-linear fitting functions and

linear mixed effects model available in most statistical packages.

• This is a perfectly valid approach.– Has been shown to produce similar results to the full non-

linear mixed effects model approach in this particular case.

Page 10: Software for Nonlinear mixed effects - University of Glasgow · PDF fileSoftware for non-linear mixed effects modelling ... S-Plus, SAS, WinNonmix, PKBUGS / Pharmaco ... in order to

Michael K. Smith, PGRD Sandwich.

Global Two-stage (cont…)

• BUT…– NOT applicable if different amounts of data from each

individual.– Extreme values of model parameters can have greater

influence in this approach.– Our estimates of variability (between subject) will differ from

the non-linear mixed effects approach since we treat our parameters as “data”.

• Could easily be applied in the Theophylline example.– Shown later

Page 11: Software for Nonlinear mixed effects - University of Glasgow · PDF fileSoftware for non-linear mixed effects modelling ... S-Plus, SAS, WinNonmix, PKBUGS / Pharmaco ... in order to

Michael K. Smith, PGRD Sandwich.

Non-linear mixed effects modelling

• Fits the best model to the population as a whole.– Accounts for different amounts of data from each individual.

Weights each accordingly.– Can incorporate covariate values to account for systematic

differences between groups of patients (e.g. bodyweight, gender, genotype, other covariates).

• Finds the best fit for the individual.– Uses random variation in the parameters to get the best fit

for each individual.– Acknowledging that each individual differs from the

population by a finite amount.– Acknowledging the “error” in each observation due to model

misfit or measurement error.

• Joint fit of all parameters.

Page 12: Software for Nonlinear mixed effects - University of Glasgow · PDF fileSoftware for non-linear mixed effects modelling ... S-Plus, SAS, WinNonmix, PKBUGS / Pharmaco ... in order to

Michael K. Smith, PGRD Sandwich.

Where’s the difficulty?

• In order to get to the likelihood we have a “tricky integration”.

• Software currently tries to either linearise the model in order to get an easier integral or number-crunch its way around the problem.

( )( )[ ] ( )∫ − ibiiiie bdFbadfypdfi

,, β

Page 13: Software for Nonlinear mixed effects - University of Glasgow · PDF fileSoftware for non-linear mixed effects modelling ... S-Plus, SAS, WinNonmix, PKBUGS / Pharmaco ... in order to

Michael K. Smith, PGRD Sandwich.

What software is available?• NONMEM

– “The original and best”. Gold standard for pharmacokineticists.

• S-Plus– nlme function

• SAS (v8)– PROC NLMIXED.– A macro is available for pre- v8 users.

• WinNonmix (Pharsight)– GUI Windows “Point and click” interface.

• PKBUGS / Pharmaco– Add-in to WinBUGS with Pop PK models, easy to use

interface (don’t have to write BUGS code).

• MANY others.

Page 14: Software for Nonlinear mixed effects - University of Glasgow · PDF fileSoftware for non-linear mixed effects modelling ... S-Plus, SAS, WinNonmix, PKBUGS / Pharmaco ... in order to

Michael K. Smith, PGRD Sandwich.

NONMEM• Multiple platforms. (VMS, UNIX, DOS)• Data handling / preparation can be a pain.

– Dosing information within the model specification is taken care of within the dataset.

– BUT this makes specification of multiple dosing easy.

• Command files submitted in batch mode.• Built-in functions for common PK models, but can

also define functions directly.• “Flexibility, flexibility, flexibility” quote: Any PK-ist.• Quirky and fairly unforgiving package.

– There are definitely “techniques” which are learnt through use rather than taught in lectures.

• FORTRAN (!)

Page 15: Software for Nonlinear mixed effects - University of Glasgow · PDF fileSoftware for non-linear mixed effects modelling ... S-Plus, SAS, WinNonmix, PKBUGS / Pharmaco ... in order to

Michael K. Smith, PGRD Sandwich.

NONMEM (cont…)$PROB Analysis of 1 compartment oral model for theophyline data $INPUT ID BWT AMT TIME DV $DATA [NONMEM.MIKE.DNG]THEO.DAT IGNORE=# $SUBS ADVAN2 $PK TVKA=THETA(1) TVK=THETA(2) TVV=THETA(3) K=TVK*EXP(ETA(2)) KA=TVKA*EXP(ETA(1)) V=TVV*EXP(ETA(3)) S2=V CL=V*K $ERROR IPRED = F IRES = DV - F W = F IF (W.EQ.0) W=1 IWRES = IRES / W Y=F+EPS(1) $THETA (0,1.5) (0,0.04) (0,0.4) $OMEGA 0.3 0.2 0.2 $SIGMA 0.5 $ESTIMATION SIGDIGITS=3 POSTHOC $COVARIANCE $SCATTERPLOT DV VS PRED $SCATTERPLOT RES VS PRED $TAB ID CL V K KA ONEHEADER NOPRINT FILE=Theoph1.dat $TAB ID TIME IPRED IRES IWRES NOPRINT ONEHEADER FILE=sdtab1.dat

Page 16: Software for Nonlinear mixed effects - University of Glasgow · PDF fileSoftware for non-linear mixed effects modelling ... S-Plus, SAS, WinNonmix, PKBUGS / Pharmaco ... in order to

Michael K. Smith, PGRD Sandwich.

NONMEM (cont…)

• UGLY graphics– Line printer style.

Page 17: Software for Nonlinear mixed effects - University of Glasgow · PDF fileSoftware for non-linear mixed effects modelling ... S-Plus, SAS, WinNonmix, PKBUGS / Pharmaco ... in order to

Michael K. Smith, PGRD Sandwich.

DV VS. PRED -1.00E+00 1.60E+00 4.20E+00 DV 6.80E+00 9.40E+00 1.20E+01 . . . . . . . . . . . . . . . . . -1.00E+00. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9** * . . . . . . . . * . . * . 1.40E+00. 2*2 .. . * 2 . . * * . . . . . . * . . . . . . * * * . . * * * . 3.80E+00. * * * .. . * * ** . . * * * . . * * * 2 . . * * *** * . PRED . * * * * * * . . * * * . . * * * * ** * . . * * * . . * * * . 6.20E+00. * * * .. . * * * * 2 . . * 2 . . * * . . * * * ***** ** * . . * * * * * . . . . * * * 2 * . . * * * * * . . * * . 8.60E+00. * .. . * * * * . . * * . . * . . * * * . . * . . * . . . . * . . * . 1.10E+01. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Page 18: Software for Nonlinear mixed effects - University of Glasgow · PDF fileSoftware for non-linear mixed effects modelling ... S-Plus, SAS, WinNonmix, PKBUGS / Pharmaco ... in order to

Michael K. Smith, PGRD Sandwich.

NONMEM (cont…)• Users usually employ S-Plus or other package for

pre- and post-processing.– XPOSE library of functions available.– Create nice diagnostic plots and show model fits.

• Run times can be HUGE (days) for large datasets.– Not uncommon (e.g. end of Phase III)– BUT because it runs in batch mode, you can leave it to run

while you get on with your meetings…

• Lots of documentation on the system (several volumes). Lots of undocumented features though...

• Very large user community, busy e-mail discussion board.

Page 19: Software for Nonlinear mixed effects - University of Glasgow · PDF fileSoftware for non-linear mixed effects modelling ... S-Plus, SAS, WinNonmix, PKBUGS / Pharmaco ... in order to

Michael K. Smith, PGRD Sandwich.

1

1

1

1

1

1

1

1

1

1

1

2

2

2

2

2

2

2

2

2

2

3

3

3

3

3

3

3

3

3

3

4

4

4

4

4

4

4

4

4

4

5

5

5

5

5

5

5

5

5

5

6

6

6

6

6

6

6

6

6

6

7

7

7

7

7

7

7

7

7

7

7

8

8

8

8

8

8

8

8

8

8

9

9

9

9

9

9

9

9

9

9

10

10

10

10

10

10

10

10

10

10

10

11

11

11

11

11

11

11

11

11

11

12

12

12

12

12

12

12

12

12

12

0

2

4

6

8

10

PRED vs DV

0 2 4 6 8 10

1

1

1

1

1

1

1

1

1

1

1

2

2

2

2

2

2

2

2

2

2

3

3

33

3

3

3

3

3

3

4

4

4

44

4

4

4

4

4

5

5

5

5

5

5

5

5

5

5

6

6

6

66

6

6

6

6

6

7

7

7

7

7

7

7

7

7

7

7

8

8

8

8

8

8

8

8

8

8

9

99

9

9

9

9

9

9

9

10

10

10

10

10

10

10

10

10

10

10

11

11

11

11

11

11

11

11

11

11

12

12

12

1212

12

12

12

12

12

IPRE vs DV0 2 4 6 8 10

DV

Pre

dict

ions

Predictions vs dependent variable for run 6

NONMEM (cont…) - Xpose

• Library of diagnostic functions from Upsalla Uni.

Page 20: Software for Nonlinear mixed effects - University of Glasgow · PDF fileSoftware for non-linear mixed effects modelling ... S-Plus, SAS, WinNonmix, PKBUGS / Pharmaco ... in order to

Michael K. Smith, PGRD Sandwich.

NONMEM (cont…) - Xpose

• Model fits

0

2

4

6

8

10

ID: 1 ID: 2

0 5 10 15 20 25ID: 3 ID: 4

0 5 10 15 20 25

ID: 5 ID: 6 ID: 7

0

2

4

6

8

10

ID: 8

0

2

4

6

8

10

ID: 9

0 5 10 15 20 25

ID: 10 ID: 11

0 5 10 15 20 25

ID: 12

TIME

DV

/IPR

E/P

RE

DIndividual plots for run 6

DV IPRE PRED

Page 21: Software for Nonlinear mixed effects - University of Glasgow · PDF fileSoftware for non-linear mixed effects modelling ... S-Plus, SAS, WinNonmix, PKBUGS / Pharmaco ... in order to

Michael K. Smith, PGRD Sandwich.

S-Plus

• nlme function is not specific to PK models.– A library of of common non-linear models are available, but

there is the flexibility to input any model.– PK/PD library for common models, further fitting algorithms.– nlme itself is capable of fitting multiple levels of variability,

although models in the PK/PD library are limited to two-level models.

• Can use all of S-Plus functionality for plots, exploratory analysis, individual fits.– Useful diagnostic code (plots, summaries) available directly.

• Straightforward data input.

Page 22: Software for Nonlinear mixed effects - University of Glasgow · PDF fileSoftware for non-linear mixed effects modelling ... S-Plus, SAS, WinNonmix, PKBUGS / Pharmaco ... in order to

Michael K. Smith, PGRD Sandwich.

S-Plus (cont…)xyplot(conc~Time,data=Theoph,groups=Subject,panel.superpose,

type="l")

fm1Theo.lis<-nlsList(conc~SSfol(Dose,Time,lKe,lKa,lCl),data=Theoph)

fm1Theo.nlme<-nlme(fm1Theo.lis)

intervals(fm1Theo.nlme,which="var-cov")

fm2Theo.nlme<-update(fm1Theo.nlme,random=pdDiag(list(lKe~1,lKa~1,lCl~1)))

plot(fm2Theo.nlme)

OR

fm.alt.Theo.lis<-nlsList(conc~SSfol(Dose,Time,lCl-lV, lKa, lCl), data=Theoph, start=list(lKa=1.05,lCl=-3.22,lV=-0.73))

fm.alt.Theo.nlme<-nlme(fm.alt.Theo.lis)

Page 23: Software for Nonlinear mixed effects - University of Glasgow · PDF fileSoftware for non-linear mixed effects modelling ... S-Plus, SAS, WinNonmix, PKBUGS / Pharmaco ... in order to

Michael K. Smith, PGRD Sandwich.

S-Plus (cont…)

• Nice, useful graphics!

0

2

4

6

8

10

0 5 10 15 20 25

Time (h)

Con

cent

ratio

n (m

g/L)

Xyplot(…) Intervals(…)

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

6

7

8

11

3

2

4

9

12

10

1

5

lKe

-3.0 -2.5 -2.0

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

lKa

-1 0 1 2 3

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

lCl

-4.0 -3.5 -3.0S

ubje

ct

Page 24: Software for Nonlinear mixed effects - University of Glasgow · PDF fileSoftware for non-linear mixed effects modelling ... S-Plus, SAS, WinNonmix, PKBUGS / Pharmaco ... in order to

Michael K. Smith, PGRD Sandwich.

S-Plus (cont…)

• Model fits

augPred(…)

0

2

4

6

8

10

6

0 5 10 15 20 25

7 8

0 5 10 15 20 25

11

3 2 4

0

2

4

6

8

10

90

2

4

6

8

10

12 100 5 10 15 20 25

1 50 5 10 15 20 25

Time since drug administration (hr)

The

ophy

lline

con

cent

ratio

n in

ser

um (

mg/

l)

Page 25: Software for Nonlinear mixed effects - University of Glasgow · PDF fileSoftware for non-linear mixed effects modelling ... S-Plus, SAS, WinNonmix, PKBUGS / Pharmaco ... in order to

Michael K. Smith, PGRD Sandwich.

S-Plus (cont…)• Need to know a bit about how to use S-Plus.• Need to know how best to parameterise your

function.– Not always straightforward…– Watch for correlations between parameters.

• LOTS of flexibility within this though.– Error structures etc.

• Good documentation.– Pinheiro and Bates book covers technical and practical

aspects of using nlme.

• nlme discussion list on-line with input from Pinheiro and Bates.– Also s-news discussion list for general S-Plus issues.

Page 26: Software for Nonlinear mixed effects - University of Glasgow · PDF fileSoftware for non-linear mixed effects modelling ... S-Plus, SAS, WinNonmix, PKBUGS / Pharmaco ... in order to

Michael K. Smith, PGRD Sandwich.

SAS• PROC NLMIXED in SAS v8• NLINMIX macro in earlier versions.• Like S-Plus you need to specify the functions yourself.

– Same flexibility, same problems.– Not easy for multiple dose PK.– Need to calculate your own starting values.

• Benefits of being wholly within SAS.– Easy data structure.– Can automate, macro-ise if necessary.– Within v8 can use ODS to pull out appropriate statistics.

• Incorporates various methods of integral approximation to maximise the likelihood function.– First-order approximation (like NONMEM)– Gaussian quadrature (numerical integration).– Importance sampling (Monte-Carlo integration).

Page 27: Software for Nonlinear mixed effects - University of Glasgow · PDF fileSoftware for non-linear mixed effects modelling ... S-Plus, SAS, WinNonmix, PKBUGS / Pharmaco ... in order to

Michael K. Smith, PGRD Sandwich.

SAS (cont…)

proc nlmixed data=theoph; parms beta1=-3.22 beta2=0.47 beta3=-2.45 s2b1=0.03 cb12=0 s2b2=0.4 s2=0.5; cl = exp(beta1 + b1); ka = exp(beta2 + b2); ke = exp(beta3); pred = dose*ka*ke*(exp(-ke*time)-exp(-ka*time))/cl/(ka-ke); model conc ~ normal(pred,s2); random b1 b2 ~ normal([0,0],[s2b1,cb12,s2b2]) subject=subject; run;

Page 28: Software for Nonlinear mixed effects - University of Glasgow · PDF fileSoftware for non-linear mixed effects modelling ... S-Plus, SAS, WinNonmix, PKBUGS / Pharmaco ... in order to

Michael K. Smith, PGRD Sandwich.

SAS (cont…)• Some limitations to the complexity of the error

structure.– Not too many correlations between parameters (slows things

down).– Not too many levels. (only between and within individuals).

• Relatively slow…– If using numerical integration of the likelihood instead of

linearisation.

• Need to know how to program up your own diagnostics.

• Online SAS help available (syntax, examples) and a few explanatory papers; – support also available from Russ Wolfinger, Oliver

Schabenberger at SAS.

Page 29: Software for Nonlinear mixed effects - University of Glasgow · PDF fileSoftware for non-linear mixed effects modelling ... S-Plus, SAS, WinNonmix, PKBUGS / Pharmaco ... in order to

Michael K. Smith, PGRD Sandwich.

WinNonmix

• Windows does Non-linear mixed effects.• Nice GUI interface.

– Walks you through each step of constructing the model.– Library of models (PK, PD, PK/PD).– Point and click.

• Good graphical diagnostics.• Algorithms designed to be as close to NONMEM as

possible

• Almost too easy.– Can get carried away and fit daft models…– Things can look right...

Page 30: Software for Nonlinear mixed effects - University of Glasgow · PDF fileSoftware for non-linear mixed effects modelling ... S-Plus, SAS, WinNonmix, PKBUGS / Pharmaco ... in order to

Michael K. Smith, PGRD Sandwich.

WinNonmix (cont…)

Page 31: Software for Nonlinear mixed effects - University of Glasgow · PDF fileSoftware for non-linear mixed effects modelling ... S-Plus, SAS, WinNonmix, PKBUGS / Pharmaco ... in order to

Michael K. Smith, PGRD Sandwich.

WinNonmix (cont…)

• Does most jobs within the one package.– Plots, diagnostics, summaries of parameters.– Excel-style datasheets.

• Reasonable interface to/from other packages as required. – Can import NONMEM style datasets. – Can export plots / output (although there are a lot

produced).– Can import / export datasheets to Excel or flat files.

• Support from Pharsight user support.– Some on-line extra examples, help.– Support queries are usually turned around quite quickly via

e-mail.

Page 32: Software for Nonlinear mixed effects - University of Glasgow · PDF fileSoftware for non-linear mixed effects modelling ... S-Plus, SAS, WinNonmix, PKBUGS / Pharmaco ... in order to

Michael K. Smith, PGRD Sandwich.

PKBUGS / Pharmaco• An add on to WinBUGS.

– PKBUGS offers GUI model specification through WinBUGSv1.3

– Pharmaco offers PK model specification for WinBUGSv1.4.

• PKBUGS allows easy specification of Pop PK models.– GUI interface walks you through specification.– Up to two compartment models through the interface, others

possible if you write the code in WinBUGS.

• Pharmaco allows flexibility of models– Parameterisation, PK/PD model specification etc.

– Uses full functionality of WinBUGSv1.4 (batch mode)– Allows for use of WBDiff functionality (Differential equation solver

plugin for WinBUGS)

• Common data-structure with NONMEM.

Page 33: Software for Nonlinear mixed effects - University of Glasgow · PDF fileSoftware for non-linear mixed effects modelling ... S-Plus, SAS, WinNonmix, PKBUGS / Pharmaco ... in order to

Michael K. Smith, PGRD Sandwich.

PKBUGS / Pharmaco

Page 34: Software for Nonlinear mixed effects - University of Glasgow · PDF fileSoftware for non-linear mixed effects modelling ... S-Plus, SAS, WinNonmix, PKBUGS / Pharmaco ... in order to

Michael K. Smith, PGRD Sandwich.

PKBUGS / Pharmaco

• Some knowledge of using WinBUGS is desirable.– Need to understand the MCMC process, burn-in, sampling,

convergence issues etc.– Some pre- and post-processing required to prepare data and

look at model fits etc.

• Pharmaco functions require more knowledge of WinBUGS coding.– Helps if you have already worked with PKBUGS and

understand the basic principles.– Can export models from PKBUGSv1.1 (WinBUGSv1.3) and

use these as a basis for new models using Pharmaco functions in WinBUGSv1.4.

Page 35: Software for Nonlinear mixed effects - University of Glasgow · PDF fileSoftware for non-linear mixed effects modelling ... S-Plus, SAS, WinNonmix, PKBUGS / Pharmaco ... in order to

Michael K. Smith, PGRD Sandwich.

Theophylline example

• Bronchodilator (methyl xanthine)• Kinetics of drug’s anti-asthmatic properties• 12 Subjects measured 11 times over 25 hours• Oral first order one compartment model

– EASY model.– Single dose

• Analysed by EVERYBODY– Boeckmann, Sheiner, Beal, Pinheiro, Bates, Wolfinger, Davidian, Giltinan…

• THE standard example in all software.

Page 36: Software for Nonlinear mixed effects - University of Glasgow · PDF fileSoftware for non-linear mixed effects modelling ... S-Plus, SAS, WinNonmix, PKBUGS / Pharmaco ... in order to

Michael K. Smith, PGRD Sandwich.

Theophylline - analysis• Although this is the default example in almost all software, the

parameterisation often differs.• Here we convert the default examples to common

parameterisation.• Also use the default or standard method of model fitting.

• Note:– S-Plus and SAS results are QUITE different to NONMEM and

WinNonmix. Why? Which is correct?– + WinBUGS reports the deviance

Package Objective Fn. Value

Ka (1/h)

CL (L/h/kg)

V (L/kg)

s.d.(lKa) %cv

s.d(lCl) %cv

s.d.(lV) %cv

Sigma

NONMEM 105.955 2.86 0.0398 0.482 91.2 30.2 15.0 0.378 S-Plus 358.6 1.56 0.0403 0.456 64.2 26.4 13.5 0.692 SAS 359.9 (-2*LL) 1.58 0.0400 0.458 65.7 26.6 13.5 0.478 WinNonmix 105.955 2.86 0.0398 0.482 91.3 30.2 15.0 0.378 WinBUGS 278.1 + 1.57 0.0400 0.458 70.4 37.0 16.7 0.695

Page 37: Software for Nonlinear mixed effects - University of Glasgow · PDF fileSoftware for non-linear mixed effects modelling ... S-Plus, SAS, WinNonmix, PKBUGS / Pharmaco ... in order to

Michael K. Smith, PGRD Sandwich.

Theophylline - Methods of estimation• Need to know a bit about how the software differs in

its approach to fitting these models.– NONMEM and WinNonmix standard method estimates the

fixed effects at the mean of the random effect (i.e. zero). They then calculate the individual level values for the parameters and the between subject variability.

– This is known as the First Order method since it takes a first order linearisation approximation to the likelihood.

– S-Plus and SAS default estimation methods are similar to the First-Order Conditional Estimation within NONMEM, WinNonmix.

• First order conditional estimation methodology:– In a nutshell: At each step, the estimation recalculates the

between subject variability and factors this into the next step of estimating the fixed effects.

– Matters for Ka since the individuals are very variable.

Page 38: Software for Nonlinear mixed effects - University of Glasgow · PDF fileSoftware for non-linear mixed effects modelling ... S-Plus, SAS, WinNonmix, PKBUGS / Pharmaco ... in order to

Michael K. Smith, PGRD Sandwich.

Theophylline - analysis

• Now using the First Order approximation within SAS.• S-Plus and WinBUGS do not have an equivalent to

the FO method.

• Note much better agreement.

Package Objective Fn. Value

Ka (1/h)

CL (L/h/kg)

V (L/kg)

s.d.(lKa) %cv

s.d(lCl) %cv

s.d.(lV) %cv

Sigma

NONMEM 105.955 2.86 0.0398 0.482 91.2 30.2 15.0 0.378 SAS 348.6 (-2*LL) 2.86 0.0398 0.482 91.3 30.3 15.0 0.378 WinNonmix 105.955 2.86 0.0398 0.482 91.3 30.2 15.0 0.378

Page 39: Software for Nonlinear mixed effects - University of Glasgow · PDF fileSoftware for non-linear mixed effects modelling ... S-Plus, SAS, WinNonmix, PKBUGS / Pharmaco ... in order to

Michael K. Smith, PGRD Sandwich.

Theophylline• Fitting First-order conditional estimation method in NONMEM

and WinNonmix, Lindstrom-Bates algorithm in S-Plus (like FOCE), non-parametric approximation in SAS:

• Results from the Global Two-Stage method– Fitting individual data in WinNonlin and mixed effects model in S-

Plus.

Package Objective Fn. Value

Ka CL V s.d.(lKa) %cv

s.d.(lCl) %cv

s.d.(lV) %cv

Sigma

NONMEM 115.993 1.59 0.0400 0.460 64.3 26.4 13.6 0.477 S-Plus 358.6 (-2*LL) 1.56 0.0403 0.456 64.2 26.4 13.5 0.692 SAS 359.9 (-2*LL) 1.58 0.0400 0.458 65.7 26.6 13.5 0.478 WinNonmix 137.363 1.56 0.0403 0.456 67.1 27.7 14.1 0.481 WinBUGS 278.1 1.57 0.0400 0.458 70.4 37.0 16.7 0.695

K a C L V s .d .(lK a ) % cv

s .d .(lC l) % cv

s .d .(lV ) % cv

S igm a

G T S 1 .36 0 .0405 0 .452 45 .1 26 .8 13 .3 0 .477

Page 40: Software for Nonlinear mixed effects - University of Glasgow · PDF fileSoftware for non-linear mixed effects modelling ... S-Plus, SAS, WinNonmix, PKBUGS / Pharmaco ... in order to

Michael K. Smith, PGRD Sandwich.

So which software should I use?• Depends on how difficult the problem is you are

trying to solve.– How much data do you have?– How complex is the model?

• Depends on software availability.– SAS is more likely to be available in industry settings.– nlme can be used under R as well as S-Plus, and an ODE

solver is also available for R.• http://www.maths.lth.se/help/R/.R/library/nlmeODE/html/00Index.html

– NONMEM is likely to be available in most Clinical Pharmacology departments.

• Depends on the type of model you want to fit.– Certain models aren’t easy to code in SAS and S-Plus.– Certain models aren’t available in WinNonmix.

Page 41: Software for Nonlinear mixed effects - University of Glasgow · PDF fileSoftware for non-linear mixed effects modelling ... S-Plus, SAS, WinNonmix, PKBUGS / Pharmaco ... in order to

Michael K. Smith, PGRD Sandwich.

So which software should I use?• WinNonmix.

– +ve: Easy to use, one-stop-shop.– -ve: Most of the examples, library models are PK or PD driven.

• SAS, S-Plus– +ve: Very flexible for model specification. Easy to manipulate data

within the package.– -ve: Have to take care in model specification.

• NONMEM– +ve: Very flexible for model specification. Very powerful for PK/PD

modelling. HUGE user community.– -ve: Dataset structure is non-standard.

• PKBUGS / Pharmaco– +ve: Nice alternative to linearisation techniques. Easy access to

uncertainty estimates on all parameters.– -ve: Need to know a bit about MCMC, BUGS language. Can be

slow.

Page 42: Software for Nonlinear mixed effects - University of Glasgow · PDF fileSoftware for non-linear mixed effects modelling ... S-Plus, SAS, WinNonmix, PKBUGS / Pharmaco ... in order to

Michael K. Smith, PGRD Sandwich.

General points to be aware of…

• CAUTION:– This stuff is not really for the faint hearted.

• Fitting non-linear mixed effects models can be a tricky (and frustrating) business.– You need to think carefully about whether the model you are

fitting is appropriate.– Sometimes your “most appropriate” model will not fit, due to

data not supporting certain parameters, bad starting values, correlations etc.

– Compromises are quite often necessary.

• Model diagnostics are even more important in these models.– Does the model you’ve fitted describe all subjects

reasonably well?

Page 43: Software for Nonlinear mixed effects - University of Glasgow · PDF fileSoftware for non-linear mixed effects modelling ... S-Plus, SAS, WinNonmix, PKBUGS / Pharmaco ... in order to

Michael K. Smith, PGRD Sandwich.

Conclusions• Try it out!

– Find some examples...

• Be wary!– If the model runs, it doesn’t mean that the answer is correct.– Method of fitting the data does make a difference.– Parameterisation is a big issue.– Correlations between parameters may be an issue in linear

models, but it can be a major issue in non-linear models.– Check your results for “reasonable-ness”. Do they match

what you would expect? How do they compare to either a pooled analysis of all data, or analysis of individuals separately?

• There are some general rules for fitting these models, but experience is the best guide.

Page 44: Software for Nonlinear mixed effects - University of Glasgow · PDF fileSoftware for non-linear mixed effects modelling ... S-Plus, SAS, WinNonmix, PKBUGS / Pharmaco ... in order to

Michael K. Smith, PGRD Sandwich.

References:

• Read up more!– Davidian and Giltinan: “Nonlinear models for repeated

measurement data.”– Pinheiro and Bates: “Mixed-effects models in S and S-Plus.”– Wolfinger: “Fitting nonlinear mixed models with the new

NLMIXED procedure.”

• Theophylline code for SAS, S-Plus, NONMEM, WinBUGS available from me on request.

E-mail: [email protected]

Page 45: Software for Nonlinear mixed effects - University of Glasgow · PDF fileSoftware for non-linear mixed effects modelling ... S-Plus, SAS, WinNonmix, PKBUGS / Pharmaco ... in order to

Michael K. Smith, PGRD Sandwich.

Acknowledgements

• Reviewers of manuscript for providing valuable comments:– Insightful (nlme)– Oliver Schabenberger (PROC NLMIXED)– Pharsight (WinNonmix)– Dave Lunn (PKBUGS / Pharmaco)

• Peter Colman, Tracy Higgins (Pfizer) for reviewing my methods and results.