nlmixr: an open-source package for pharmacometric ...€¦ · nlmixr is an open-source R package...
Transcript of nlmixr: an open-source package for pharmacometric ...€¦ · nlmixr is an open-source R package...
![Page 1: nlmixr: an open-source package for pharmacometric ...€¦ · nlmixr is an open-source R package • Written by Wenping Wang and available on GitHub: •builds on RxODE, an R package](https://reader033.fdocuments.us/reader033/viewer/2022060208/5f0429ce7e708231d40c9fbc/html5/thumbnails/1.jpg)
Uppsala University Presentation
Rik Schoemaker, PhD 8 December 2016
The nlmixr development team: Wenping Wang, Yuan Xiong,
Justin Wilkins and Rik Schoemaker
nlmixr: an open-source package for
pharmacometric modelling in R
![Page 2: nlmixr: an open-source package for pharmacometric ...€¦ · nlmixr is an open-source R package • Written by Wenping Wang and available on GitHub: •builds on RxODE, an R package](https://reader033.fdocuments.us/reader033/viewer/2022060208/5f0429ce7e708231d40c9fbc/html5/thumbnails/2.jpg)
nlmixr is an open-source R package
• Written by Wenping Wang and available on GitHub:
• builds on RxODE, an R package for simulation of nonlinear mixed effect models using ODEs
• combined with nlme, an R package for parameter estimation in nonlinear mixed effect models
• but also gnlmm and SAEM estimation routines…
• nlmixr provides an efficient and versatile way to specify pharmacometric models (closed-form and ODEs) and dosing scenarios, with rapid execution due to compilation in C
• NONMEM® with first-order conditional estimation with interaction was used as a comparator to test nlmixr
nlmixr development team2
![Page 3: nlmixr: an open-source package for pharmacometric ...€¦ · nlmixr is an open-source R package • Written by Wenping Wang and available on GitHub: •builds on RxODE, an R package](https://reader033.fdocuments.us/reader033/viewer/2022060208/5f0429ce7e708231d40c9fbc/html5/thumbnails/3.jpg)
Example syntax
library(nlmixr)
datr<-read.csv("BOLUS_1CPT.csv", header=TRUE)
datr$EVID<-ifelse(datr$EVID==1,101,datr$EVID)
specs<-list(fixed=lCL+lV~1,random=pdDiag(form=lCL+lV~1),start=c(lCL=1.6,lV=4.5))
#Closed-form:
fit<-nlme_lin_cmpt(datr,par_model=specs,ncmt=1,oral=FALSE,weight=varPower(fixed=c(1)))
#ODE:
ode <- "d/dt(centr) = -(CL/V)*centr;"
mypar <- function(lCL, lV )
{CL = exp(lCL)
V = exp(lV)}
fitODE<-nlme_ode(datr,model=ode,par_model=specs,par_trans=mypar,response="centr",
response.scaler="V", weight=varPower(fixed=c(1)),
control=nlmeControl(pnlsTol=.1))
nlmixr development team3
![Page 4: nlmixr: an open-source package for pharmacometric ...€¦ · nlmixr is an open-source R package • Written by Wenping Wang and available on GitHub: •builds on RxODE, an R package](https://reader033.fdocuments.us/reader033/viewer/2022060208/5f0429ce7e708231d40c9fbc/html5/thumbnails/4.jpg)
Rich data sets
• 4 different dose levels (10, 30, 60 and 120 mg) of 30 subjects each as • single dose (over 72h)
• multiple dose (4 daily doses)
• single and multiple dose combined
• and steady state dosing
• Range of test models: • 1- and 2-compartment disposition
• with and without 1st order absorption
• linear or Michaelis-Menten (MM) clearance
• A total of 42 test cases• all IIVs were set at 30%, residual error at 20%
• overlapping PK parameters were the same for all models
nlmixr development team4
![Page 5: nlmixr: an open-source package for pharmacometric ...€¦ · nlmixr is an open-source R package • Written by Wenping Wang and available on GitHub: •builds on RxODE, an R package](https://reader033.fdocuments.us/reader033/viewer/2022060208/5f0429ce7e708231d40c9fbc/html5/thumbnails/5.jpg)
Example full profiles (linear elimination)
nlmixr development team5
Individual concentration profiles
Time (h)
Con
cent
ratio
n (m
g/L)
0.01
0.1
1
10
100
1000
ID:1/Dose:60 mg ID:2/Dose:10 mg
0.01
0.1
1
10
100
1000
ID:3/Dose:10 mg ID:4/Dose:120 mg
0.01
0.1
1
10
100
1000
ID:5/Dose:60 mg ID:6/Dose:30 mg
0.01
0.1
1
10
100
1000
ID:7/Dose:120 mg ID:8/Dose:30 mg
0.01
0.1
1
10
100
1000
0 50 100 150 200 250 300
ID:9/Dose:120 mg
0 50 100 150 200 250 300
ID:10/Dose:30 mg
nlmixr Demo OccamsTools 161025 fig 1 Individual log concentration curves for runN026: multiple dose oral administration using closed-form solution (1).
![Page 6: nlmixr: an open-source package for pharmacometric ...€¦ · nlmixr is an open-source R package • Written by Wenping Wang and available on GitHub: •builds on RxODE, an R package](https://reader033.fdocuments.us/reader033/viewer/2022060208/5f0429ce7e708231d40c9fbc/html5/thumbnails/6.jpg)
Example full profiles (MM elimination)
nlmixr development team6
0 50 100 200
520
100
Time(h)
Con
cent
ratio
n (m
g/L)
ID:106/Dose:10 mg
0 50 100 200
200
1000
5000
Time(h)
Con
cent
ratio
n (m
g/L)
ID:107/Dose:60 mg
0 50 100 200
500
2000
1000
0
Time(h)
Con
cent
ratio
n (m
g/L)
ID:108/Dose:120 mg
0 50 100 200
100
500
5000
Time(h)
Con
cent
ratio
n (m
g/L)
ID:109/Dose:60 mg
0 50 100 200
500
2000
1000
0
Time(h)
Con
cent
ratio
n (m
g/L)
ID:110/Dose:120 mg
0 50 100 200
5020
020
00
Time(h)
Con
cent
ratio
n (m
g/L)
ID:111/Dose:30 mg
0 50 100 200
520
100
500
Time(h)
Con
cent
ratio
n (m
g/L)
ID:112/Dose:10 mg
0 50 100 200
500
2000
1000
0
Time(h)
Con
cent
ratio
n (m
g/L)
ID:113/Dose:120 mg
0 50 100 200
500
2000
1000
0
Time(h)
Con
cent
ratio
n (m
g/L)
ID:114/Dose:120 mg
0 50 100 200
200
1000
5000
Time(h)
Con
cent
ratio
n (m
g/L)
ID:115/Dose:60 mg
0 50 100 200
5020
010
00
Time(h)
Con
cent
ratio
n (m
g/L)
ID:116/Dose:30 mg
0 50 100 200
520
100
Time(h)
Con
cent
ratio
n (m
g/L)
ID:117/Dose:10 mg
0 50 100 200
520
100
500
Time(h)
Con
cent
ratio
n (m
g/L)
ID:118/Dose:10 mg
0 50 100 200
5020
020
00
Time(h)
Con
cent
ratio
n (m
g/L)
ID:119/Dose:60 mg
0 50 100 200
5020
010
00
Time(h)
Con
cent
ratio
n (m
g/L)
ID:120/Dose:30 mg
nlmixr Demo OccamsTools 161025 fig 22 Individual graphs of log concentration by time for runN022: multiple dose IV administration with MM elimination using ODE solution (8)
![Page 7: nlmixr: an open-source package for pharmacometric ...€¦ · nlmixr is an open-source R package • Written by Wenping Wang and available on GitHub: •builds on RxODE, an R package](https://reader033.fdocuments.us/reader033/viewer/2022060208/5f0429ce7e708231d40c9fbc/html5/thumbnails/7.jpg)
Vc is available in all models: Theta estimates using NONMEMHorizontal black line: value used for simulation
nlmixr development team7
![Page 8: nlmixr: an open-source package for pharmacometric ...€¦ · nlmixr is an open-source R package • Written by Wenping Wang and available on GitHub: •builds on RxODE, an R package](https://reader033.fdocuments.us/reader033/viewer/2022060208/5f0429ce7e708231d40c9fbc/html5/thumbnails/8.jpg)
Grey line: nlmixr/nlme estimates using ODEs
nlmixr development team8
![Page 9: nlmixr: an open-source package for pharmacometric ...€¦ · nlmixr is an open-source R package • Written by Wenping Wang and available on GitHub: •builds on RxODE, an R package](https://reader033.fdocuments.us/reader033/viewer/2022060208/5f0429ce7e708231d40c9fbc/html5/thumbnails/9.jpg)
Non MM models also implemented using closed-form solutionsBlue line: nlmixr/nlme estimates using closed-form solutions
nlmixr development team9
![Page 10: nlmixr: an open-source package for pharmacometric ...€¦ · nlmixr is an open-source R package • Written by Wenping Wang and available on GitHub: •builds on RxODE, an R package](https://reader033.fdocuments.us/reader033/viewer/2022060208/5f0429ce7e708231d40c9fbc/html5/thumbnails/10.jpg)
SE of theta estimates for Vc are very comparable
nlmixr development team10
![Page 11: nlmixr: an open-source package for pharmacometric ...€¦ · nlmixr is an open-source R package • Written by Wenping Wang and available on GitHub: •builds on RxODE, an R package](https://reader033.fdocuments.us/reader033/viewer/2022060208/5f0429ce7e708231d40c9fbc/html5/thumbnails/11.jpg)
Residual error is well-estimatedHorizontal black line: value used for simulation
nlmixr development team11
![Page 12: nlmixr: an open-source package for pharmacometric ...€¦ · nlmixr is an open-source R package • Written by Wenping Wang and available on GitHub: •builds on RxODE, an R package](https://reader033.fdocuments.us/reader033/viewer/2022060208/5f0429ce7e708231d40c9fbc/html5/thumbnails/12.jpg)
Run times are perfectly acceptable, and often lower than NONMEM
nlmixr development team12
![Page 13: nlmixr: an open-source package for pharmacometric ...€¦ · nlmixr is an open-source R package • Written by Wenping Wang and available on GitHub: •builds on RxODE, an R package](https://reader033.fdocuments.us/reader033/viewer/2022060208/5f0429ce7e708231d40c9fbc/html5/thumbnails/13.jpg)
For Vc, Omega (IIV) estimates are also very comparableHorizontal black line: value used for simulation
nlmixr development team13
![Page 14: nlmixr: an open-source package for pharmacometric ...€¦ · nlmixr is an open-source R package • Written by Wenping Wang and available on GitHub: •builds on RxODE, an R package](https://reader033.fdocuments.us/reader033/viewer/2022060208/5f0429ce7e708231d40c9fbc/html5/thumbnails/14.jpg)
But if we examineVp…
nlmixr development team14
![Page 15: nlmixr: an open-source package for pharmacometric ...€¦ · nlmixr is an open-source R package • Written by Wenping Wang and available on GitHub: •builds on RxODE, an R package](https://reader033.fdocuments.us/reader033/viewer/2022060208/5f0429ce7e708231d40c9fbc/html5/thumbnails/15.jpg)
…or Ka…
nlmixr development team15
![Page 16: nlmixr: an open-source package for pharmacometric ...€¦ · nlmixr is an open-source R package • Written by Wenping Wang and available on GitHub: •builds on RxODE, an R package](https://reader033.fdocuments.us/reader033/viewer/2022060208/5f0429ce7e708231d40c9fbc/html5/thumbnails/16.jpg)
…or Q…
often the IIVs are estimated close to zero
nlmixr development team16
![Page 17: nlmixr: an open-source package for pharmacometric ...€¦ · nlmixr is an open-source R package • Written by Wenping Wang and available on GitHub: •builds on RxODE, an R package](https://reader033.fdocuments.us/reader033/viewer/2022060208/5f0429ce7e708231d40c9fbc/html5/thumbnails/17.jpg)
But what about sparse data?
• first-order absorption, one-compartment distribution, linear elimination model
• 4 doses, 150 subjects per dose
• 4 random time point samples in 24 hours after the 7th dose
• 500 datasets
nlmixr development team17
![Page 18: nlmixr: an open-source package for pharmacometric ...€¦ · nlmixr is an open-source R package • Written by Wenping Wang and available on GitHub: •builds on RxODE, an R package](https://reader033.fdocuments.us/reader033/viewer/2022060208/5f0429ce7e708231d40c9fbc/html5/thumbnails/18.jpg)
CL estimates using nlmixr (top) seem to demonstrate some bias
compared to NONMEM (bottom)
nlmixr development team18
![Page 19: nlmixr: an open-source package for pharmacometric ...€¦ · nlmixr is an open-source R package • Written by Wenping Wang and available on GitHub: •builds on RxODE, an R package](https://reader033.fdocuments.us/reader033/viewer/2022060208/5f0429ce7e708231d40c9fbc/html5/thumbnails/19.jpg)
And V estimates demonstrate even larger bias…
nlmixr development team19
![Page 20: nlmixr: an open-source package for pharmacometric ...€¦ · nlmixr is an open-source R package • Written by Wenping Wang and available on GitHub: •builds on RxODE, an R package](https://reader033.fdocuments.us/reader033/viewer/2022060208/5f0429ce7e708231d40c9fbc/html5/thumbnails/20.jpg)
…but NONMEM and nlmixr estimates are highly correlated
nlmixr development team20
![Page 21: nlmixr: an open-source package for pharmacometric ...€¦ · nlmixr is an open-source R package • Written by Wenping Wang and available on GitHub: •builds on RxODE, an R package](https://reader033.fdocuments.us/reader033/viewer/2022060208/5f0429ce7e708231d40c9fbc/html5/thumbnails/21.jpg)
This is also the case for Ka theta estimates… (right)
nlmixr development team21
![Page 22: nlmixr: an open-source package for pharmacometric ...€¦ · nlmixr is an open-source R package • Written by Wenping Wang and available on GitHub: •builds on RxODE, an R package](https://reader033.fdocuments.us/reader033/viewer/2022060208/5f0429ce7e708231d40c9fbc/html5/thumbnails/22.jpg)
…but IIV estimates for Vc and especially for Ka clearly demonstrate a
large fraction of runs with IIV=0 for nlmixr (91.1% vs. 2.2% for NONMEM)
nlmixr development team22
![Page 23: nlmixr: an open-source package for pharmacometric ...€¦ · nlmixr is an open-source R package • Written by Wenping Wang and available on GitHub: •builds on RxODE, an R package](https://reader033.fdocuments.us/reader033/viewer/2022060208/5f0429ce7e708231d40c9fbc/html5/thumbnails/23.jpg)
Disappointing results?
• Findings are in line with earlier experience with nlme
• Bob Bauer claims nlme is somewhere beween ITS and FOCE
• However, nlme in nlmixr provides a gateway into nonlinear mixed effect modelling for statisticians…
• With the machinery in place, the groundwork is laid for other/better estimation routines, like SAEM or FOCE-I…
• SAEM currently also available in nlmixr
nlmixr development team23
![Page 24: nlmixr: an open-source package for pharmacometric ...€¦ · nlmixr is an open-source R package • Written by Wenping Wang and available on GitHub: •builds on RxODE, an R package](https://reader033.fdocuments.us/reader033/viewer/2022060208/5f0429ce7e708231d40c9fbc/html5/thumbnails/24.jpg)
Example nlmixr/SAEM syntax
library(nlmixr)
datr<-read.csv("BOLUS_1CPT.csv", header=TRUE)
datr$EVID<-ifelse(datr$EVID==1,101,datr$EVID)
#temporary work-around for specifying covariates
datr$WT<-1
#Closed-form:
saem_fit <- gen_saem_user_fn(model=lincmt(ncmt=1, oral=FALSE))
#ODE:
ode <- "d/dt(centr) = -(CL/V)*centr;"
m3 = RxODE(ode, modName="m3")
PRED = function() centr / V
mypar <- function(lCL, lV )
{CL = exp(lCL)
V = exp(lV)}
saem_fit <- gen_saem_user_fn(model=m3, PKpars=mypar, pred=PRED)
#run SAEM:
model = list(saem_mod=saem_fit, res.mod=2,covars="WT")
inits = list(theta=c(5,90),omega=c(0.1,0.1),bres=0.2)
cfg = configsaem(model, datr, inits)
cfg$print = 50
fit = saem_fit(cfg)
nlmixr development team24
![Page 25: nlmixr: an open-source package for pharmacometric ...€¦ · nlmixr is an open-source R package • Written by Wenping Wang and available on GitHub: •builds on RxODE, an R package](https://reader033.fdocuments.us/reader033/viewer/2022060208/5f0429ce7e708231d40c9fbc/html5/thumbnails/25.jpg)
IIVs for nlmixr/SAEM for Vp show none of the close to zero behaviour
nlmixr development team25
![Page 26: nlmixr: an open-source package for pharmacometric ...€¦ · nlmixr is an open-source R package • Written by Wenping Wang and available on GitHub: •builds on RxODE, an R package](https://reader033.fdocuments.us/reader033/viewer/2022060208/5f0429ce7e708231d40c9fbc/html5/thumbnails/26.jpg)
IIVs for nlmixr/SAEM for Vp show none of the close to zero behaviour
And some estimates seem better behaved…
nlmixr development team26
![Page 27: nlmixr: an open-source package for pharmacometric ...€¦ · nlmixr is an open-source R package • Written by Wenping Wang and available on GitHub: •builds on RxODE, an R package](https://reader033.fdocuments.us/reader033/viewer/2022060208/5f0429ce7e708231d40c9fbc/html5/thumbnails/27.jpg)
…and could this also be the case for SEs for Vp…?
nlmixr development team27
![Page 28: nlmixr: an open-source package for pharmacometric ...€¦ · nlmixr is an open-source R package • Written by Wenping Wang and available on GitHub: •builds on RxODE, an R package](https://reader033.fdocuments.us/reader033/viewer/2022060208/5f0429ce7e708231d40c9fbc/html5/thumbnails/28.jpg)
…and Vc…?
nlmixr development team28
![Page 29: nlmixr: an open-source package for pharmacometric ...€¦ · nlmixr is an open-source R package • Written by Wenping Wang and available on GitHub: •builds on RxODE, an R package](https://reader033.fdocuments.us/reader033/viewer/2022060208/5f0429ce7e708231d40c9fbc/html5/thumbnails/29.jpg)
…and Vc…?
nlmixr development team29
![Page 30: nlmixr: an open-source package for pharmacometric ...€¦ · nlmixr is an open-source R package • Written by Wenping Wang and available on GitHub: •builds on RxODE, an R package](https://reader033.fdocuments.us/reader033/viewer/2022060208/5f0429ce7e708231d40c9fbc/html5/thumbnails/30.jpg)
nlmixr/SAEM is slower than nlmixr/nlme but still workable
nlmixr development team30
![Page 31: nlmixr: an open-source package for pharmacometric ...€¦ · nlmixr is an open-source R package • Written by Wenping Wang and available on GitHub: •builds on RxODE, an R package](https://reader033.fdocuments.us/reader033/viewer/2022060208/5f0429ce7e708231d40c9fbc/html5/thumbnails/31.jpg)
Very close correspondence for sparse sample theta estimates…
nlmixr development team31
![Page 32: nlmixr: an open-source package for pharmacometric ...€¦ · nlmixr is an open-source R package • Written by Wenping Wang and available on GitHub: •builds on RxODE, an R package](https://reader033.fdocuments.us/reader033/viewer/2022060208/5f0429ce7e708231d40c9fbc/html5/thumbnails/32.jpg)
…and no close to zero IIVs for nlmixr/SAEM
nlmixr development team32
![Page 33: nlmixr: an open-source package for pharmacometric ...€¦ · nlmixr is an open-source R package • Written by Wenping Wang and available on GitHub: •builds on RxODE, an R package](https://reader033.fdocuments.us/reader033/viewer/2022060208/5f0429ce7e708231d40c9fbc/html5/thumbnails/33.jpg)
…and no close to zero IIVs for nlmixr/SAEM
and even better behaved than NONMEM
nlmixr development team33
![Page 34: nlmixr: an open-source package for pharmacometric ...€¦ · nlmixr is an open-source R package • Written by Wenping Wang and available on GitHub: •builds on RxODE, an R package](https://reader033.fdocuments.us/reader033/viewer/2022060208/5f0429ce7e708231d40c9fbc/html5/thumbnails/34.jpg)
Is there an error in the algorithm in view of the systematic bias?
Again that pronounced shift to the left for nlmixr…
nlmixr development team34
![Page 35: nlmixr: an open-source package for pharmacometric ...€¦ · nlmixr is an open-source R package • Written by Wenping Wang and available on GitHub: •builds on RxODE, an R package](https://reader033.fdocuments.us/reader033/viewer/2022060208/5f0429ce7e708231d40c9fbc/html5/thumbnails/35.jpg)
When samples are taken after the 1st dose instead of the 7th…
nlmixr development team35
![Page 36: nlmixr: an open-source package for pharmacometric ...€¦ · nlmixr is an open-source R package • Written by Wenping Wang and available on GitHub: •builds on RxODE, an R package](https://reader033.fdocuments.us/reader033/viewer/2022060208/5f0429ce7e708231d40c9fbc/html5/thumbnails/36.jpg)
When samples are taken after the 1st dose instead of the 7th…
The bias is in the NONMEM estimates and nlmixr is spot on
nlmixr development team36
![Page 37: nlmixr: an open-source package for pharmacometric ...€¦ · nlmixr is an open-source R package • Written by Wenping Wang and available on GitHub: •builds on RxODE, an R package](https://reader033.fdocuments.us/reader033/viewer/2022060208/5f0429ce7e708231d40c9fbc/html5/thumbnails/37.jpg)
More good news?
• nlmixr is available on GitHub at https://github.com/nlmixrdevelopment/nlmixr
• nlmixr also has an adaptive Gausian quadrature algorithm (like NONMEM’s Laplace and higher) allowing fancy models
• nlmixr also has single subject dynamic models e.g. for complex system simulation and estimation (mcmc algorithm)
• Elementary implementation of VPC and bootstrap functionality
nlmixr development team37
![Page 38: nlmixr: an open-source package for pharmacometric ...€¦ · nlmixr is an open-source R package • Written by Wenping Wang and available on GitHub: •builds on RxODE, an R package](https://reader033.fdocuments.us/reader033/viewer/2022060208/5f0429ce7e708231d40c9fbc/html5/thumbnails/38.jpg)
What’s next?
• We need you!
• Improving computational efficiency of estimation algorithms (e.g. within-problem parallelisation)
• Implementation of FOCE-I
• Error-trapping
• Field-testing
• New features implementation
• Etc, etc…
nlmixr development team38
![Page 39: nlmixr: an open-source package for pharmacometric ...€¦ · nlmixr is an open-source R package • Written by Wenping Wang and available on GitHub: •builds on RxODE, an R package](https://reader033.fdocuments.us/reader033/viewer/2022060208/5f0429ce7e708231d40c9fbc/html5/thumbnails/39.jpg)
Example nlmixr/gnlmm syntax:
PK-PD model with ODE of heavy-tail data: t-distribution
kin.m0 <- "C2 = centr/V2;C3 = peri/V3;CONC = centr/V2*1000;
Stim= EMAX*(CONC^GAM)/(CONC^GAM+EC50^GAM);
d/dt(depot) =-KA*depot;d/dt(centr) = KA*depot - CL*C2 - Q*C2 + Q*C3;d/dt(peri) = Q*C2 - Q*C3;d/dt(eff) = KIN*(1-Stim) - KOUT*eff;"sys1 = RxODE(kin.m0)
dt_ls <- function(x, df, mu, a, log=T) {if (log) {
dt((x - mu)/a, df, log=T) - log(a)} else {
1/a * dt((x - mu)/a, df)}
}
llik <- function() {pred = ifelse(eff>0.01, eff, 0.01)sd1 = sqrt(sig2)*pred^.7#dnorm(DV, pred, sd=sd1, log=TRUE)dt_ls(DV, 4, pred, sd1, log=TRUE)
}
inits = list(THTA=c(-3, 0, 9, .7, -.4))inits$OMGA = list(ETA[1]~.001, ETA[2]~1)
fit = gnlmm(llik, data, inits, pars, sys1, control=list(trace=TRUE, optim.inner = "Nelder-Mead", optim.outer = "nmsimplex", reltol.outer = 1.0e-3,mc.cores=4)
)
nlmixr development team39
![Page 40: nlmixr: an open-source package for pharmacometric ...€¦ · nlmixr is an open-source R package • Written by Wenping Wang and available on GitHub: •builds on RxODE, an R package](https://reader033.fdocuments.us/reader033/viewer/2022060208/5f0429ce7e708231d40c9fbc/html5/thumbnails/40.jpg)
Example nlmixr/gnlmm syntax:PK-PD model with ODE of bounded clinical endpoint: beta-distributionkin.m0 <- “
C2 = centr/V2;
C3 = peri/V3;
CONC = centr/V2*1000;
Stim= EMAX*(CONC^GAM)/(CONC^GAM+EC50^GAM);
d/dt(depot) =-KA*depot;
d/dt(centr) = KA*depot - CL*C2 - Q*C2 + Q*C3;
d/dt(peri) = Q*C2 - Q*C3;
d/dt(eff) = KIN*(1-Stim) - KOUT*eff;
“
sys1 = RxODE(kin.m0)
llik <- function() {
mn = ifelse(eff<.0001, .0001, eff2)
odsp = odav/mn^pwod
shp1 = mn*odsp
shp2 = odsp - shp1
dbeta(DV, shp1, shp2, log=TRUE)
}
inits = list(THTA=c(-3, 2, 7.5, .7, 2.1, -.4))
inits$OMGA = list(ETA[1]~.001, ETA[2]~.8, ETA[3]~1)
fit = gnlmm(llik, x, inits, pars, sys1,
control=list(
trace=TRUE,
optim.outer = "nmsimplex",
optim.inner = "Nelder-Mead",
reltol.outer = 1.0e-2,
mc.cores=4)
)
nlmixr development team40
![Page 41: nlmixr: an open-source package for pharmacometric ...€¦ · nlmixr is an open-source R package • Written by Wenping Wang and available on GitHub: •builds on RxODE, an R package](https://reader033.fdocuments.us/reader033/viewer/2022060208/5f0429ce7e708231d40c9fbc/html5/thumbnails/41.jpg)
Example nlmixr/gnlmm syntax:PK-PD model with ODE of binary data with over-dispersion: beta-binomial distributionode.bin1 <- "
C2 = centr/V2;
C3 = peri/V3;
CONC = centr/V2*1000;
d/dt(depot) =-KA*depot;
d/dt(centr) = KA*depot - CL*C2 - Q*C2 + Q*C3;
d/dt(peri) = Q*C2 - Q*C3;
d/dt(eff) = kout*(1+emax*CONC^gam/(ec50^gam+CONC^gam)) -kout*eff ;"
sys5 = RxODE(ode.bin1)
llik <- function() {
lp = alpha+beta*eff
pred = 1/(1+exp(-lp))
if (do.betabinom)
dbetabinom(DV, pred, 1, thta, log = TRUE)
else dbinom(DV, 1, pred, log=TRUE)
}
do.betabinom = T
inits = list(
THTA=c(2, -4, 0.3, -3, 0.2, -2, -3, 200),
if(do.betabinom) 2 else NULL)
)
inits$OMGA = list(ETA[1]~.9, ETA[2]~.9)
fit1 = gnlmm(llik, mydat, inits, mypars, sys5,
control=list(
trace=TRUE,
mc.cores=4)
)
nlmixr development team41