Citation
-
Source: DESCRIPTION
+
Source: DESCRIPTION
Fidler M (2024).
-nonmem2rx: 'nonmem2rx' Converts 'NONMEM' Models to 'rxode2' .
+nonmem2rx: Converts 'NONMEM' Models to 'rxode2' .
R package version 0.1.5, https://github.com/nlmixr2/nonmem2rx/, https://nlmixr2.github.io/nonmem2rx/ .
@Manual{,
- title = {nonmem2rx: 'nonmem2rx' Converts 'NONMEM' Models to 'rxode2'},
+ title = {nonmem2rx: Converts 'NONMEM' Models to 'rxode2'},
author = {Matthew Fidler},
year = {2024},
note = {R package version 0.1.5, https://github.com/nlmixr2/nonmem2rx/},
diff --git a/index.html b/index.html
index 1e8da83..95ce911 100644
--- a/index.html
+++ b/index.html
@@ -5,7 +5,7 @@
-nonmem2rx Converts NONMEM Models to rxode2 • nonmem2rx
+Converts NONMEM Models to rxode2 • nonmem2rx
@@ -16,7 +16,7 @@
-
+
diff --git a/news/index.html b/news/index.html
index cfbb63f..332209a 100644
--- a/news/index.html
+++ b/news/index.html
@@ -48,11 +48,11 @@
-
nonmem2rx 0.1.5
+
nonmem2rx 0.1.5 CRAN release: 2024-09-18
Be more forgiving in the validation and remove IDs without observations when solving the IPRED
problem.
Binary linkage to dparser changed to structure only, meaning nonmem2rx
may not have to be updated if dparser
is updated.
diff --git a/pkgdown.yml b/pkgdown.yml
index d5b0e9c..900145b 100644
--- a/pkgdown.yml
+++ b/pkgdown.yml
@@ -13,4 +13,4 @@ articles:
articles/simulate-new-dosing: simulate-new-dosing.html
articles/simulate-uncertainty: simulate-uncertainty.html
articles/simulate-with-covs: simulate-with-covs.html
-last_built: 2024-09-18T16:33Z
+last_built: 2024-09-19T15:51Z
diff --git a/reference/as.nonmem2rx.html b/reference/as.nonmem2rx.html
index ec41a03..b2e592e 100644
--- a/reference/as.nonmem2rx.html
+++ b/reference/as.nonmem2rx.html
@@ -48,7 +48,7 @@
diff --git a/reference/autoplot.nonmem2rx.html b/reference/autoplot.nonmem2rx.html
index 308634e..c9930fa 100644
--- a/reference/autoplot.nonmem2rx.html
+++ b/reference/autoplot.nonmem2rx.html
@@ -48,7 +48,7 @@
diff --git a/reference/nmcov.html b/reference/nmcov.html
index faf5f2f..ec8a800 100644
--- a/reference/nmcov.html
+++ b/reference/nmcov.html
@@ -48,7 +48,7 @@
diff --git a/reference/nmext.html b/reference/nmext.html
index 73e9aff..0df2eaa 100644
--- a/reference/nmext.html
+++ b/reference/nmext.html
@@ -48,7 +48,7 @@
diff --git a/reference/nminfo.html b/reference/nminfo.html
index 720899f..2585008 100644
--- a/reference/nminfo.html
+++ b/reference/nminfo.html
@@ -48,7 +48,7 @@
diff --git a/reference/nmlst.html b/reference/nmlst.html
index a16d399..8bb369f 100644
--- a/reference/nmlst.html
+++ b/reference/nmlst.html
@@ -48,7 +48,7 @@
diff --git a/reference/nmtab.html b/reference/nmtab.html
index 398f53d..1b96b43 100644
--- a/reference/nmtab.html
+++ b/reference/nmtab.html
@@ -48,7 +48,7 @@
diff --git a/reference/nmxml.html b/reference/nmxml.html
index 65de2b6..665f4c1 100644
--- a/reference/nmxml.html
+++ b/reference/nmxml.html
@@ -48,7 +48,7 @@
diff --git a/reference/nmxmlCov.html b/reference/nmxmlCov.html
index 203fcc5..84ea682 100644
--- a/reference/nmxmlCov.html
+++ b/reference/nmxmlCov.html
@@ -48,7 +48,7 @@
diff --git a/reference/nonmem2rx.html b/reference/nonmem2rx.html
index 58505f8..d07d3c6 100644
--- a/reference/nonmem2rx.html
+++ b/reference/nonmem2rx.html
@@ -48,7 +48,7 @@
diff --git a/reference/nonmem2rxRec.html b/reference/nonmem2rxRec.html
index ff7ab0a..ccc5bda 100644
--- a/reference/nonmem2rxRec.html
+++ b/reference/nonmem2rxRec.html
@@ -48,7 +48,7 @@
diff --git a/reference/reexports.html b/reference/reexports.html
index abda417..eff6e2a 100644
--- a/reference/reexports.html
+++ b/reference/reexports.html
@@ -86,7 +86,7 @@
diff --git a/search.json b/search.json
index 0b5adcb..178aaea 100644
--- a/search.json
+++ b/search.json
@@ -1 +1 @@
-[{"path":"/articles/convert-nlmixr2.html","id":"creating-a-nlmixr2-compatible-model","dir":"Articles","previous_headings":"","what":"Creating a nlmixr2 compatible model","title":"Converting a NONMEM fit to a nlmixr2 object","text":"Depending model, residual specifications translated nlmixr2 style residuals. means model immediately used either nlmixr2() estimation creating nlmixr2 fit object (though can simulate without certainty without modifications) example something like: model can nlmixr2 estimation instead simply simulation residual needs changed something like: Since model import translation done already, can easily tweak model form. example residual errors automatically translated nlmixr2 parameter style (case option determineError=FALSE)","code":"y <- ipred*(1+eps1) cp ~ prop(prop.sd)"},{"path":"/articles/convert-nlmixr2.html","id":"example-no-error-determined","dir":"Articles","previous_headings":"","what":"Example – no error determined","title":"Converting a NONMEM fit to a nlmixr2 object","text":"One approach get nlmixr2 compatible model copy printed model modify needed. case, name parameters something bit meaningful keeping estimates : .nonmem2rx() function compare already imported rxode2 model function model made manual tweaks : case new model qualifies now information imported nonmem2rx model. means can estimate new model knowing model specified NONMEM. Since iwres affected specify residuals, pay special attention validation. validate, may forgot translate NONMEM variance estimate standard deviation estimate required many estimation methods.","code":"library(nonmem2rx) library(babelmixr2) #> Loading required package: nlmixr2 #> Loading required package: nlmixr2data # First we need the location of the nonmem control stream Since we are running an example, we will use one of the built-in examples in `nonmem2rx` ctlFile <- system.file(\"mods/cpt/runODE032.ctl\", package=\"nonmem2rx\") # You can use a control stream or other file. With the development # version of `babelmixr2`, you can simply point to the listing file mod <- nonmem2rx(ctlFile, lst=\".res\", save=FALSE, determineError=FALSE) #> ℹ getting information from '/home/runner/work/_temp/Library/nonmem2rx/mods/cpt/runODE032.ctl' #> ℹ reading in xml file #> ℹ done #> ℹ reading in ext file #> ℹ done #> ℹ reading in phi file #> ℹ done #> ℹ reading in lst file #> ℹ abbreviated list parsing #> ℹ done #> ℹ done #> ℹ splitting control stream by records #> ℹ done #> ℹ Processing record $INPUT #> ℹ Processing record $MODEL #> ℹ Processing record $gTHETA #> ℹ Processing record $OMEGA #> ℹ Processing record $SIGMA #> ℹ Processing record $PROBLEM #> ℹ Processing record $DATA #> ℹ Processing record $SUBROUTINES #> ℹ Processing record $PK #> ℹ Processing record $DES #> ℹ Processing record $ERROR #> ℹ Processing record $ESTIMATION #> ℹ Ignore record $ESTIMATION #> ℹ Processing record $COVARIANCE #> ℹ Ignore record $COVARIANCE #> ℹ Processing record $TABLE #> ℹ change initial estimate of `theta1` to `1.37034036528946` #> ℹ change initial estimate of `theta2` to `4.19814911033061` #> ℹ change initial estimate of `theta3` to `1.38003493562413` #> ℹ change initial estimate of `theta4` to `3.87657341967489` #> ℹ change initial estimate of `theta5` to `0.196446108190896` #> ℹ change initial estimate of `eta1` to `0.101251418415006` #> ℹ change initial estimate of `eta2` to `0.0993872449483344` #> ℹ change initial estimate of `eta3` to `0.101302674763154` #> ℹ change initial estimate of `eta4` to `0.0730497519364148` #> ℹ read in nonmem input data (for model validation): /home/runner/work/_temp/Library/nonmem2rx/mods/cpt/Bolus_2CPT.csv #> ℹ ignoring lines that begin with a letter (IGNORE=@)' #> ℹ applying names specified by $INPUT #> ℹ subsetting accept/ignore filters code: .data[-which((.data$SD == 0)),] #> ℹ done #> ℹ read in nonmem IPRED data (for model validation): /home/runner/work/_temp/Library/nonmem2rx/mods/cpt/runODE032.csv #> ℹ done #> ℹ changing most variables to lower case #> ℹ done #> ℹ replace theta names #> ℹ done #> ℹ replace eta names #> ℹ done (no labels) #> ℹ renaming compartments #> ℹ done #> ℹ solving ipred problem #> ℹ done #> ℹ solving pred problem #> ℹ done print(mod) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> theta1 theta2 theta3 theta4 RSV #> 1.3703404 4.1981491 1.3800349 3.8765734 0.1964461 #> #> Omega ($omega): #> eta1 eta2 eta3 eta4 #> eta1 0.1012514 0.00000000 0.0000000 0.00000000 #> eta2 0.0000000 0.09938724 0.0000000 0.00000000 #> eta3 0.0000000 0.00000000 0.1013027 0.00000000 #> eta4 0.0000000 0.00000000 0.0000000 0.07304975 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 CENTRAL #> 2 2 PERI #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 theta1 eta1 id #> 2 theta2 eta2 id #> 3 theta3 eta3 id #> 4 theta4 eta4 id #> #> ── Model (Normalized Syntax): ── #> function() { #> description <- \"BOLUS_2CPT_CLV1QV2 SINGLE DOSE FOCEI (120 Ind/2280 Obs) runODE032\" #> dfObs <- 2280 #> dfSub <- 120 #> sigma <- lotri({ #> eps1 ~ 1 #> }) #> thetaMat <- lotri({ #> theta1 ~ c(theta1 = 0.000887681) #> theta2 ~ c(theta1 = -0.00010551, theta2 = 0.000871409) #> theta3 ~ c(theta1 = 0.000184416, theta2 = -0.000106195, #> theta3 = 0.00299336) #> theta4 ~ c(theta1 = -0.000120234, theta2 = -5.06663e-05, #> theta3 = 0.000165252, theta4 = 0.00121347) #> RSV ~ c(theta1 = 5.2783e-08, theta2 = -1.56562e-05, theta3 = 5.99331e-06, #> theta4 = -2.53991e-05, RSV = 9.94218e-06) #> eps1 ~ c(theta1 = 0, theta2 = 0, theta3 = 0, theta4 = 0, #> RSV = 0, eps1 = 0) #> eta1 ~ c(theta1 = -4.71273e-05, theta2 = 4.69667e-05, #> theta3 = -3.64271e-05, theta4 = 2.54796e-05, RSV = -8.16885e-06, #> eps1 = 0, eta1 = 0.000169296) #> omega.2.1 ~ c(theta1 = 0, theta2 = 0, theta3 = 0, theta4 = 0, #> RSV = 0, eps1 = 0, eta1 = 0, omega.2.1 = 0) #> eta2 ~ c(theta1 = -7.37156e-05, theta2 = 2.56634e-05, #> theta3 = -8.08349e-05, theta4 = 1.37e-05, RSV = -4.36564e-06, #> eps1 = 0, eta1 = 8.75181e-06, omega.2.1 = 0, eta2 = 0.00015125) #> omega.3.1 ~ c(theta1 = 0, theta2 = 0, theta3 = 0, theta4 = 0, #> RSV = 0, eps1 = 0, eta1 = 0, omega.2.1 = 0, eta2 = 0, #> omega.3.1 = 0) #> omega.3.2 ~ c(theta1 = 0, theta2 = 0, theta3 = 0, theta4 = 0, #> RSV = 0, eps1 = 0, eta1 = 0, omega.2.1 = 0, eta2 = 0, #> omega.3.1 = 0, omega.3.2 = 0) #> eta3 ~ c(theta1 = 6.63383e-05, theta2 = -8.19002e-05, #> theta3 = 0.000548985, theta4 = 0.000168356, RSV = 1.59122e-06, #> eps1 = 0, eta1 = 3.48714e-05, omega.2.1 = 0, eta2 = 4.31593e-07, #> omega.3.1 = 0, omega.3.2 = 0, eta3 = 0.000959029) #> omega.4.1 ~ c(theta1 = 0, theta2 = 0, theta3 = 0, theta4 = 0, #> RSV = 0, eps1 = 0, eta1 = 0, omega.2.1 = 0, eta2 = 0, #> omega.3.1 = 0, omega.3.2 = 0, eta3 = 0, omega.4.1 = 0) #> omega.4.2 ~ c(theta1 = 0, theta2 = 0, theta3 = 0, theta4 = 0, #> RSV = 0, eps1 = 0, eta1 = 0, omega.2.1 = 0, eta2 = 0, #> omega.3.1 = 0, omega.3.2 = 0, eta3 = 0, omega.4.1 = 0, #> omega.4.2 = 0) #> omega.4.3 ~ c(theta1 = 0, theta2 = 0, theta3 = 0, theta4 = 0, #> RSV = 0, eps1 = 0, eta1 = 0, omega.2.1 = 0, eta2 = 0, #> omega.3.1 = 0, omega.3.2 = 0, eta3 = 0, omega.4.1 = 0, #> omega.4.2 = 0, omega.4.3 = 0) #> eta4 ~ c(theta1 = -9.49661e-06, theta2 = 0.000110108, #> theta3 = -0.000306537, theta4 = -9.12897e-05, RSV = 3.1877e-06, #> eps1 = 0, eta1 = 1.36628e-05, omega.2.1 = 0, eta2 = -1.95096e-05, #> omega.3.1 = 0, omega.3.2 = 0, eta3 = -0.00012977, #> omega.4.1 = 0, omega.4.2 = 0, omega.4.3 = 0, eta4 = 0.00051019) #> }) #> validation <- c(\"IPRED relative difference compared to Nonmem IPRED: 0%; 95% percentile: (0%,0%); rtol=6.43e-06\", #> \"IPRED absolute difference compared to Nonmem IPRED: 95% percentile: (2.19e-05, 0.0418); atol=0.00167\", #> \"IWRES relative difference compared to Nonmem IWRES: 0%; 95% percentile: (0%,0.01%); rtol=8.99e-06\", #> \"IWRES absolute difference compared to Nonmem IWRES: 95% percentile: (1.82e-07, 4.63e-05); atol=3.65e-06\", #> \"PRED relative difference compared to Nonmem PRED: 0%; 95% percentile: (0%,0%); rtol=6.41e-06\", #> \"PRED absolute difference compared to Nonmem PRED: 95% percentile: (1.41e-07,0.00382) atol=6.41e-06\") #> ini({ #> theta1 <- 1.37034036528946 #> label(\"log Cl\") #> theta2 <- 4.19814911033061 #> label(\"log Vc\") #> theta3 <- 1.38003493562413 #> label(\"log Q\") #> theta4 <- 3.87657341967489 #> label(\"log Vp\") #> RSV <- c(0, 0.196446108190896, 1) #> label(\"RSV\") #> eta1 ~ 0.101251418415006 #> eta2 ~ 0.0993872449483344 #> eta3 ~ 0.101302674763154 #> eta4 ~ 0.0730497519364148 #> }) #> model({ #> cmt(CENTRAL) #> cmt(PERI) #> cl <- exp(theta1 + eta1) #> v <- exp(theta2 + eta2) #> q <- exp(theta3 + eta3) #> v2 <- exp(theta4 + eta4) #> v1 <- v #> scale1 <- v #> k21 <- q/v2 #> k12 <- q/v #> d/dt(CENTRAL) <- k21 * PERI - k12 * CENTRAL - cl * CENTRAL/v1 #> d/dt(PERI) <- -k21 * PERI + k12 * CENTRAL #> f <- CENTRAL/scale1 #> ipred <- f #> rescv <- RSV #> w <- ipred * rescv #> ires <- DV - ipred #> iwres <- ires/w #> y <- ipred + w * eps1 #> }) #> } #> ── nonmem2rx translation notes ($notes): ── #> • there are duplicate eta names, not renaming duplicate parameters #> • there are duplicate theta names, not renaming duplicate parameters #> ── nonmem2rx extra properties: ── #> #> Sigma ($sigma): #> eps1 #> eps1 1 #> #> other properties include: $nonmemData, $etaData #> captured NONMEM table outputs: $predData, $ipredData #> NONMEM/rxode2 comparison data: $iwresCompare, $predCompare, $ipredCompare #> NONMEM/rxode2 composite comparison: $predAtol, $predRtol, $ipredAtol, $ipredRtol, $iwresAtol, $iwresRtol mod2 <-function() { ini({ lcl <- 1.37034036528946 lvc <- 4.19814911033061 lq <- 1.38003493562413 lvp <- 3.87657341967489 RSV <- c(0, 0.196446108190896, 1) eta.cl ~ 0.101251418415006 eta.v ~ 0.0993872449483344 eta.q ~ 0.101302674763154 eta.v2 ~ 0.0730497519364148 }) model({ cmt(CENTRAL) cmt(PERI) cl <- exp(lcl + eta.cl) v <- exp(lvc + eta.v) q <- exp(lq + eta.q) v2 <- exp(lvp + eta.v2) v1 <- v scale1 <- v k21 <- q/v2 k12 <- q/v d/dt(CENTRAL) <- k21 * PERI - k12 * CENTRAL - cl * CENTRAL/v1 d/dt(PERI) <- -k21 * PERI + k12 * CENTRAL f <- CENTRAL/scale1 f ~ prop(RSV) }) } new <- as.nonmem2rx(mod2, mod) #> ℹ parameter labels from comments are typically ignored in non-interactive mode #> ℹ Need to run with the source intact to parse comments #> ℹ copy 'dfSub' to nonmem2rx model #> ℹ copy 'thetaMat' to nonmem2rx model #> ℹ copy 'dfObs' to nonmem2rx model #> ℹ solving ipred problem #> ℹ done #> ℹ solving pred problem #> ℹ done print(new) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> lcl lvc lq lvp RSV #> 1.3703404 4.1981491 1.3800349 3.8765734 0.1964461 #> #> Omega ($omega): #> eta.cl eta.v eta.q eta.v2 #> eta.cl 0.1012514 0.00000000 0.0000000 0.00000000 #> eta.v 0.0000000 0.09938724 0.0000000 0.00000000 #> eta.q 0.0000000 0.00000000 0.1013027 0.00000000 #> eta.v2 0.0000000 0.00000000 0.0000000 0.07304975 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 CENTRAL #> 2 2 PERI #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 lcl eta.cl id #> 2 lvc eta.v id #> 3 lq eta.q id #> 4 lvp eta.v2 id #> #> ── Model (Normalized Syntax): ── #> function() { #> description <- \"BOLUS_2CPT_CLV1QV2 SINGLE DOSE FOCEI (120 Ind/2280 Obs) runODE032\" #> dfObs <- 2280 #> dfSub <- 120 #> thetaMat <- lotri({ #> lcl ~ c(lcl = 0.000887681) #> lvc ~ c(lcl = -0.00010551, lvc = 0.000871409) #> lq ~ c(lcl = 0.000184416, lvc = -0.000106195, lq = 0.00299336) #> lvp ~ c(lcl = -0.000120234, lvc = -5.06663e-05, lq = 0.000165252, #> lvp = 0.00121347) #> RSV ~ c(lcl = 5.2783e-08, lvc = -1.56562e-05, lq = 5.99331e-06, #> lvp = -2.53991e-05, RSV = 9.94218e-06) #> eta.cl ~ c(lcl = -4.71273e-05, lvc = 4.69667e-05, lq = -3.64271e-05, #> lvp = 2.54796e-05, RSV = -8.16885e-06, eta.cl = 0.000169296) #> eta.v ~ c(lcl = -7.37156e-05, lvc = 2.56634e-05, lq = -8.08349e-05, #> lvp = 1.37e-05, RSV = -4.36564e-06, eta.cl = 8.75181e-06, #> eta.v = 0.00015125) #> eta.q ~ c(lcl = 6.63383e-05, lvc = -8.19002e-05, lq = 0.000548985, #> lvp = 0.000168356, RSV = 1.59122e-06, eta.cl = 3.48714e-05, #> eta.v = 4.31593e-07, eta.q = 0.000959029) #> eta.v2 ~ c(lcl = -9.49661e-06, lvc = 0.000110108, lq = -0.000306537, #> lvp = -9.12897e-05, RSV = 3.1877e-06, eta.cl = 1.36628e-05, #> eta.v = -1.95096e-05, eta.q = -0.00012977, eta.v2 = 0.00051019) #> }) #> validation <- c(\"IPRED relative difference compared to Nonmem IPRED: 0%; 95% percentile: (0%,0%); rtol=6.43e-06\", #> \"IPRED absolute difference compared to Nonmem IPRED: 95% percentile: (2.19e-05, 0.0418); atol=0.00167\", #> \"IWRES relative difference compared to Nonmem IWRES: 0%; 95% percentile: (0%,0.01%); rtol=8.99e-06\", #> \"IWRES absolute difference compared to Nonmem IWRES: 95% percentile: (1.82e-07, 4.63e-05); atol=3.65e-06\", #> \"PRED relative difference compared to Nonmem PRED: 0%; 95% percentile: (0%,0%); rtol=6.41e-06\", #> \"PRED absolute difference compared to Nonmem PRED: 95% percentile: (1.41e-07,0.00382) atol=6.41e-06\") #> ini({ #> lcl <- 1.37034036528946 #> lvc <- 4.19814911033061 #> lq <- 1.38003493562413 #> lvp <- 3.87657341967489 #> RSV <- c(0, 0.196446108190896, 1) #> eta.cl ~ 0.101251418415006 #> eta.v ~ 0.0993872449483344 #> eta.q ~ 0.101302674763154 #> eta.v2 ~ 0.0730497519364148 #> }) #> model({ #> cmt(CENTRAL) #> cmt(PERI) #> cl <- exp(lcl + eta.cl) #> v <- exp(lvc + eta.v) #> q <- exp(lq + eta.q) #> v2 <- exp(lvp + eta.v2) #> v1 <- v #> scale1 <- v #> k21 <- q/v2 #> k12 <- q/v #> d/dt(CENTRAL) <- k21 * PERI - k12 * CENTRAL - cl * CENTRAL/v1 #> d/dt(PERI) <- -k21 * PERI + k12 * CENTRAL #> f <- CENTRAL/scale1 #> f ~ prop(RSV) #> }) #> } #> ── nonmem2rx extra properties: ── #> other properties include: $nonmemData, $etaData #> captured NONMEM table outputs: $predData, $ipredData #> NONMEM/rxode2 comparison data: $iwresCompare, $predCompare, $ipredCompare #> NONMEM/rxode2 composite comparison: $predAtol, $predRtol, $ipredAtol, $ipredRtol, $iwresAtol, $iwresRtol"},{"path":"/articles/convert-nlmixr2.html","id":"converting-the-model-to-a-nlmixr2-fit","dir":"Articles","previous_headings":"Example – no error determined","what":"Converting the model to a nlmixr2 fit","title":"Converting a NONMEM fit to a nlmixr2 object","text":"rxode2() model : Qualifies NONMEM model, nlmixr2 compatible residuals can convert nlmixr2 fit object babelmixr2:","code":"library(babelmixr2) fit <- as.nlmixr2(new) #> → loading into symengine environment... #> → pruning branches (`if`/`else`) of full model... #> ✔ done #> → finding duplicate expressions in EBE model... #> [====|====|====|====|====|====|====|====|====|====] 0:00:00 #> → optimizing duplicate expressions in EBE model... #> [====|====|====|====|====|====|====|====|====|====] 0:00:00 #> → compiling EBE model... #> using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’ #> ✔ done #> rxode2 3.0.0 using 2 threads (see ?getRxThreads) #> no cache: create with `rxCreateCache()` #> → Calculating residuals/tables #> ✔ done #> → compress origData in nlmixr2 object, save 204016 #> → compress parHistData in nlmixr2 object, save 2176 fit #> ── nlmixr² nonmem2rx reading NONMEM ver 7.4.3 ── #> #> OBJF AIC BIC Log-likelihood Condition#(Cov) #> nonmem2rx 15977.28 20185.64 20237.23 -10083.82 335.4129 #> Condition#(Cor) #> nonmem2rx 2.096559 #> #> ── Time (sec fit$time): ── #> #> setup table compress NONMEM as.nlmixr2 #> elapsed 0.042002 0.117 0.014 100.95 2.876 #> #> ── Population Parameters (fit$parFixed or fit$parFixedDf): ── #> #> Est. SE %RSE Back-transformed(95%CI) BSV(CV%) Shrink(SD)% #> lcl 1.37 0.0298 2.17 3.94 (3.71, 4.17) 32.6 1.94% #> lvc 4.2 0.0295 0.703 66.6 (62.8, 70.5) 32.3 2.46% #> lq 1.38 0.0547 3.96 3.98 (3.57, 4.42) 32.7 40.5% #> lvp 3.88 0.0348 0.899 48.3 (45.1, 51.7) 27.5 28.4% #> RSV 0.196 0.196 #> #> Covariance Type (fit$covMethod): nonmem2rx #> No correlations in between subject variability (BSV) matrix #> Full BSV covariance (fit$omega) or correlation (fit$omegaR; diagonals=SDs) #> Distribution stats (mean/skewness/kurtosis/p-value) available in fit$shrink #> Censoring (fit$censInformation): No censoring #> Minimization message (fit$message): #> #> #> WARNINGS AND ERRORS (IF ANY) FOR PROBLEM 1 #> #> (WARNING 2) NM-TRAN INFERS THAT THE DATA ARE POPULATION. #> #> #> 0MINIMIZATION SUCCESSFUL #> NO. OF FUNCTION EVALUATIONS USED: 320 #> NO. OF SIG. DIGITS IN FINAL EST.: 2.5 #> #> IPRED relative difference compared to Nonmem IPRED: 0%; 95% percentile: (0%,0%); rtol=6.43e-06 #> PRED relative difference compared to Nonmem PRED: 0%; 95% percentile: (0%,0%); rtol=6.41e-06 #> IPRED absolute difference compared to Nonmem IPRED: 95% percentile: (2.25e-05, 0.0418); atol=0.00167 #> PRED absolute difference compared to Nonmem PRED: 95% percentile: (1.41e-07,0.00382); atol=6.41e-06 #> nonmem2rx model file: '/home/runner/work/_temp/Library/nonmem2rx/mods/cpt/runODE032.ctl' #> #> ── Fit Data (object fit is a modified tibble): ── #> # A tibble: 2,280 × 25 #> ID TIME DV PRED RES IPRED IRES IWRES eta.cl eta.v eta.q eta.v2 #> #> 1 1 0.25 1041. 1750. -710. 1215. -175. -0.732 -0.144 0.375 0.0650 0.241 #> 2 1 0.5 1629 1700. -70.8 1192. 437. 1.87 -0.144 0.375 0.0650 0.241 #> 3 1 0.75 878. 1651. -774. 1169. -291. -1.27 -0.144 0.375 0.0650 0.241 #> # ℹ 2,277 more rows #> # ℹ 13 more variables: f , CENTRAL , PERI , cl , v , #> # q , v2 , v1 , scale1 , k21 , k12 , tad , #> # dosenum "},{"path":"/articles/create-augPred.html","id":"step-1-convert-the-nonmem-model-to-rxode2","dir":"Articles","previous_headings":"","what":"Step 1: Convert the NONMEM model to rxode2:","title":"Created Augmented pred/ipred plots with `augPred()`","text":"","code":"library(babelmixr2) #> Loading required package: nlmixr2 #> Loading required package: nlmixr2data library(nonmem2rx) # First we need the location of the nonmem control stream Since we are running an example, we will use one of the built-in examples in `nonmem2rx` ctlFile <- system.file(\"mods/cpt/runODE032.ctl\", package=\"nonmem2rx\") # You can use a control stream or other file. With the development # version of `babelmixr2`, you can simply point to the listing file mod <- nonmem2rx(ctlFile, lst=\".res\", save=FALSE) #> ℹ getting information from '/home/runner/work/_temp/Library/nonmem2rx/mods/cpt/runODE032.ctl' #> ℹ reading in xml file #> ℹ done #> ℹ reading in ext file #> ℹ done #> ℹ reading in phi file #> ℹ done #> ℹ reading in lst file #> ℹ abbreviated list parsing #> ℹ done #> ℹ done #> ℹ splitting control stream by records #> ℹ done #> ℹ Processing record $INPUT #> ℹ Processing record $MODEL #> ℹ Processing record $gTHETA #> ℹ Processing record $OMEGA #> ℹ Processing record $SIGMA #> ℹ Processing record $PROBLEM #> ℹ Processing record $DATA #> ℹ Processing record $SUBROUTINES #> ℹ Processing record $PK #> ℹ Processing record $DES #> ℹ Processing record $ERROR #> ℹ Processing record $ESTIMATION #> ℹ Ignore record $ESTIMATION #> ℹ Processing record $COVARIANCE #> ℹ Ignore record $COVARIANCE #> ℹ Processing record $TABLE #> ℹ change initial estimate of `theta1` to `1.37034036528946` #> ℹ change initial estimate of `theta2` to `4.19814911033061` #> ℹ change initial estimate of `theta3` to `1.38003493562413` #> ℹ change initial estimate of `theta4` to `3.87657341967489` #> ℹ change initial estimate of `theta5` to `0.196446108190896` #> ℹ change initial estimate of `eta1` to `0.101251418415006` #> ℹ change initial estimate of `eta2` to `0.0993872449483344` #> ℹ change initial estimate of `eta3` to `0.101302674763154` #> ℹ change initial estimate of `eta4` to `0.0730497519364148` #> ℹ read in nonmem input data (for model validation): /home/runner/work/_temp/Library/nonmem2rx/mods/cpt/Bolus_2CPT.csv #> ℹ ignoring lines that begin with a letter (IGNORE=@)' #> ℹ applying names specified by $INPUT #> ℹ subsetting accept/ignore filters code: .data[-which((.data$SD == 0)),] #> ℹ done #> using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’ #> ℹ read in nonmem IPRED data (for model validation): /home/runner/work/_temp/Library/nonmem2rx/mods/cpt/runODE032.csv #> ℹ done #> ℹ changing most variables to lower case #> ℹ done #> ℹ replace theta names #> ℹ done #> ℹ replace eta names #> ℹ done (no labels) #> ℹ renaming compartments #> ℹ done #> ℹ solving ipred problem #> ℹ done #> ℹ solving pred problem #> ℹ done"},{"path":"/articles/create-augPred.html","id":"step-2-convert-the-rxode2-model-to-nlmixr2","dir":"Articles","previous_headings":"","what":"Step 2: convert the rxode2 model to nlmixr2","title":"Created Augmented pred/ipred plots with `augPred()`","text":"step, convert model nlmixr2 .nlmixr2(mod); may need little manual work get residual specification match nlmixr2 NONMEM. residual specification compatible nlmixr2 object, can convert model, mod, nlmixr2 fit object:","code":"fit <- as.nlmixr2(mod) #> → loading into symengine environment... #> → pruning branches (`if`/`else`) of full model... #> ✔ done #> → finding duplicate expressions in EBE model... #> [====|====|====|====|====|====|====|====|====|====] 0:00:00 #> → optimizing duplicate expressions in EBE model... #> [====|====|====|====|====|====|====|====|====|====] 0:00:00 #> → compiling EBE model... #> using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’ #> ✔ done #> rxode2 3.0.0 using 2 threads (see ?getRxThreads) #> no cache: create with `rxCreateCache()` #> → Calculating residuals/tables #> ✔ done #> → compress origData in nlmixr2 object, save 204016 #> → compress parHistData in nlmixr2 object, save 2184 fit #> ── nlmixr² nonmem2rx reading NONMEM ver 7.4.3 ── #> #> OBJF AIC BIC Log-likelihood Condition#(Cov) #> nonmem2rx 15977.28 20185.64 20237.23 -10083.82 335.4129 #> Condition#(Cor) #> nonmem2rx 2.096559 #> #> ── Time (sec fit$time): ── #> #> setup table compress NONMEM as.nlmixr2 #> elapsed 0.042472 0.123 0.013 100.95 2.876 #> #> ── Population Parameters (fit$parFixed or fit$parFixedDf): ── #> #> Parameter Est. SE %RSE Back-transformed(95%CI) BSV(CV%) #> theta1 log Cl 1.37 0.0298 2.17 3.94 (3.71, 4.17) 32.6 #> theta2 log Vc 4.2 0.0295 0.703 66.6 (62.8, 70.5) 32.3 #> theta3 log Q 1.38 0.0547 3.96 3.98 (3.57, 4.42) 32.7 #> theta4 log Vp 3.88 0.0348 0.899 48.3 (45.1, 51.7) 27.5 #> RSV RSV 0.196 0.196 #> Shrink(SD)% #> theta1 1.94% #> theta2 2.46% #> theta3 40.5% #> theta4 28.4% #> RSV #> #> Covariance Type (fit$covMethod): nonmem2rx #> No correlations in between subject variability (BSV) matrix #> Full BSV covariance (fit$omega) or correlation (fit$omegaR; diagonals=SDs) #> Distribution stats (mean/skewness/kurtosis/p-value) available in fit$shrink #> Censoring (fit$censInformation): No censoring #> Minimization message (fit$message): #> #> #> WARNINGS AND ERRORS (IF ANY) FOR PROBLEM 1 #> #> (WARNING 2) NM-TRAN INFERS THAT THE DATA ARE POPULATION. #> #> #> 0MINIMIZATION SUCCESSFUL #> NO. OF FUNCTION EVALUATIONS USED: 320 #> NO. OF SIG. DIGITS IN FINAL EST.: 2.5 #> #> IPRED relative difference compared to Nonmem IPRED: 0%; 95% percentile: (0%,0%); rtol=6.43e-06 #> PRED relative difference compared to Nonmem PRED: 0%; 95% percentile: (0%,0%); rtol=6.41e-06 #> IPRED absolute difference compared to Nonmem IPRED: 95% percentile: (2.25e-05, 0.0418); atol=0.00167 #> PRED absolute difference compared to Nonmem PRED: 95% percentile: (1.41e-07,0.00382); atol=6.41e-06 #> nonmem2rx model file: '/home/runner/work/_temp/Library/nonmem2rx/mods/cpt/runODE032.ctl' #> #> ── Fit Data (object fit is a modified tibble): ── #> # A tibble: 2,280 × 27 #> ID TIME DV PRED RES IPRED IRES IWRES eta1 eta2 eta3 eta4 #> #> 1 1 0.25 1041. 1750. -710. 1215. -175. -0.732 -0.144 0.375 0.0650 0.241 #> 2 1 0.5 1629 1700. -70.8 1192. 437. 1.87 -0.144 0.375 0.0650 0.241 #> 3 1 0.75 878. 1651. -774. 1169. -291. -1.27 -0.144 0.375 0.0650 0.241 #> # ℹ 2,277 more rows #> # ℹ 15 more variables: ipred , CENTRAL , PERI , cl , #> # v , q , v2 , v1 , scale1 , k21 , k12 , #> # f , rescv , tad , dosenum "},{"path":"/articles/create-augPred.html","id":"step-3-create-and-plot-an-augmented-prediction","dir":"Articles","previous_headings":"","what":"Step 3: Create and plot an augmented prediction","title":"Created Augmented pred/ipred plots with `augPred()`","text":"","code":"ap <- augPred(fit) #> using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’ head(ap) #> values ind id time Endpoint #> 1 1239.488 Individual 1 0.0000 CENTRAL #> 2 1215.358 Individual 1 0.2500 CENTRAL #> 3 1191.924 Individual 1 0.5000 CENTRAL #> 4 1169.164 Individual 1 0.7500 CENTRAL #> 5 1147.057 Individual 1 1.0000 CENTRAL #> 6 1109.689 Individual 1 1.4398 CENTRAL plot(ap)"},{"path":"/articles/create-office.html","id":"step-1-import-the-model-into-nonmem2rx","dir":"Articles","previous_headings":"","what":"Step 1: import the model into nonmem2rx","title":"Create PowerPoint and Word documents using nonmem2rx","text":"","code":"library(nonmem2rx) library(babelmixr2) #> Loading required package: nlmixr2 #> Loading required package: nlmixr2data library(nlmixr2rpt) library(onbrand) library(nonmem2rx) # First we need the location of the nonmem control stream Since we are running an example, we will use one of the built-in examples in `nonmem2rx` ctlFile <- system.file(\"mods/cpt/runODE032.ctl\", package=\"nonmem2rx\") # You can use a control stream or other file. With the development # version of `babelmixr2`, you can simply point to the listing file mod <- nonmem2rx(ctlFile, lst=\".res\", save=FALSE) #> ℹ getting information from '/home/runner/work/_temp/Library/nonmem2rx/mods/cpt/runODE032.ctl' #> ℹ reading in xml file #> ℹ done #> ℹ reading in ext file #> ℹ done #> ℹ reading in phi file #> ℹ done #> ℹ reading in lst file #> ℹ abbreviated list parsing #> ℹ done #> ℹ done #> ℹ splitting control stream by records #> ℹ done #> ℹ Processing record $INPUT #> ℹ Processing record $MODEL #> ℹ Processing record $gTHETA #> ℹ Processing record $OMEGA #> ℹ Processing record $SIGMA #> ℹ Processing record $PROBLEM #> ℹ Processing record $DATA #> ℹ Processing record $SUBROUTINES #> ℹ Processing record $PK #> ℹ Processing record $DES #> ℹ Processing record $ERROR #> ℹ Processing record $ESTIMATION #> ℹ Ignore record $ESTIMATION #> ℹ Processing record $COVARIANCE #> ℹ Ignore record $COVARIANCE #> ℹ Processing record $TABLE #> ℹ change initial estimate of `theta1` to `1.37034036528946` #> ℹ change initial estimate of `theta2` to `4.19814911033061` #> ℹ change initial estimate of `theta3` to `1.38003493562413` #> ℹ change initial estimate of `theta4` to `3.87657341967489` #> ℹ change initial estimate of `theta5` to `0.196446108190896` #> ℹ change initial estimate of `eta1` to `0.101251418415006` #> ℹ change initial estimate of `eta2` to `0.0993872449483344` #> ℹ change initial estimate of `eta3` to `0.101302674763154` #> ℹ change initial estimate of `eta4` to `0.0730497519364148` #> ℹ read in nonmem input data (for model validation): /home/runner/work/_temp/Library/nonmem2rx/mods/cpt/Bolus_2CPT.csv #> ℹ ignoring lines that begin with a letter (IGNORE=@)' #> ℹ applying names specified by $INPUT #> ℹ subsetting accept/ignore filters code: .data[-which((.data$SD == 0)),] #> ℹ done #> ℹ read in nonmem IPRED data (for model validation): /home/runner/work/_temp/Library/nonmem2rx/mods/cpt/runODE032.csv #> ℹ done #> ℹ changing most variables to lower case #> ℹ done #> ℹ replace theta names #> ℹ done #> ℹ replace eta names #> ℹ done (no labels) #> ℹ renaming compartments #> ℹ done #> ℹ solving ipred problem #> ℹ done #> ℹ solving pred problem #> ℹ done"},{"path":"/articles/create-office.html","id":"step-2-convert-the-rxode2-model-to-nlmixr2","dir":"Articles","previous_headings":"","what":"Step 2: convert the rxode2 model to nlmixr2","title":"Create PowerPoint and Word documents using nonmem2rx","text":"step, convert model nlmixr2 .nlmixr2(mod); may need little manual work get residual specification match nlmixr2 NONMEM. residual specification compatible nlmixr2 object, can convert model, mod, nlmixr2 fit object: cmt(CENTRAL)cmt(PERI)cl=exp(theta1+eta1)v=exp(theta2+eta2)q=exp(theta3+eta3)v2=exp(theta4+eta4)v1=vscale1=vk21=qv2k12=qvdCENTRALdt=k21×PERI−k12×CENTRAL−cl×CENTRALv1dPERIdt=−k21×PERI+k12×CENTRALf=CENTRALscale1ipred=frescv=RSVipred∼prop(RSV)\\begin{align*} cmt({CENTRAL}) \\\\ cmt({PERI}) \\\\ {cl} & = \\exp\\left({theta1}+{eta1}\\right) \\\\ {v} & = \\exp\\left({theta2}+{eta2}\\right) \\\\ {q} & = \\exp\\left({theta3}+{eta3}\\right) \\\\ {v2} & = \\exp\\left({theta4}+{eta4}\\right) \\\\ {v1} & = {v} \\\\ {scale1} & = {v} \\\\ {k21} & = \\frac{{q}}{{v2}} \\\\ {k12} & = \\frac{{q}}{{v}} \\\\ \\frac{d \\: CENTRAL}{dt} & = {k21} {\\times} {PERI}-{k12} {\\times} {CENTRAL}-\\frac{{cl} {\\times} {CENTRAL}}{{v1}} \\\\ \\frac{d \\: PERI}{dt} & = -{k21} {\\times} {PERI}+{k12} {\\times} {CENTRAL} \\\\ {f} & = \\frac{{CENTRAL}}{{scale1}} \\\\ {ipred} & = {f} \\\\ {rescv} & = {RSV} \\\\ {ipred} & \\sim prop({RSV}) \\end{align*}","code":"fit <- as.nlmixr2(mod) #> → loading into symengine environment... #> → pruning branches (`if`/`else`) of full model... #> ✔ done #> → finding duplicate expressions in EBE model... #> [====|====|====|====|====|====|====|====|====|====] 0:00:00 #> → optimizing duplicate expressions in EBE model... #> [====|====|====|====|====|====|====|====|====|====] 0:00:00 #> → compiling EBE model... #> ✔ done #> rxode2 3.0.0 using 2 threads (see ?getRxThreads) #> no cache: create with `rxCreateCache()` #> → Calculating residuals/tables #> ✔ done #> → compress origData in nlmixr2 object, save 204016 #> → compress parHistData in nlmixr2 object, save 2184 fit"},{"path":"/articles/create-office.html","id":"step-3-create-a-powerpoint-file","dir":"Articles","previous_headings":"","what":"Step 3: Create a PowerPoint file","title":"Create PowerPoint and Word documents using nonmem2rx","text":"PowerPoint can created custom powerpoint templates, example use ones come nlmixr2rpt directly: gives powerpoint ","code":"obnd_pptx = read_template( template = system.file(package=\"nlmixr2rpt\", \"templates\",\"nlmixr_obnd_template.pptx\"), mapping = system.file(package=\"nlmixr2rpt\", \"templates\",\"nlmixr_obnd_template.yaml\")) obnd_pptx = report_fit( fit = fit, obnd = obnd_pptx) #> #> Attaching package: 'xpose' #> The following object is masked from 'package:stats': #> #> filter #> Registered S3 method overwritten by 'GGally': #> method from #> +.gg ggplot2 #> #> Attaching package: 'ggPMX' #> The following object is masked from 'package:xpose': #> #> get_data #> → loading into symengine environment... #> → pruning branches (`if`/`else`) of full model... #> ✔ done #> → calculate jacobian #> [====|====|====|====|====|====|====|====|====|====] 0:00:00 #> → calculate sensitivities #> [====|====|====|====|====|====|====|====|====|====] 0:00:00 #> → calculate ∂(f)/∂(η) #> [====|====|====|====|====|====|====|====|====|====] 0:00:00 #> → calculate ∂(R²)/∂(η) #> [====|====|====|====|====|====|====|====|====|====] 0:00:00 #> → finding duplicate expressions in inner model... #> [====|====|====|====|====|====|====|====|====|====] 0:00:00 #> → optimizing duplicate expressions in inner model... #> [====|====|====|====|====|====|====|====|====|====] 0:00:00 #> → finding duplicate expressions in EBE model... #> [====|====|====|====|====|====|====|====|====|====] 0:00:00 #> → optimizing duplicate expressions in EBE model... #> [====|====|====|====|====|====|====|====|====|====] 0:00:00 #> → compiling inner model... #> using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’ #> ✔ done #> → finding duplicate expressions in FD model... #> [====|====|====|====|====|====|====|====|====|====] 0:00:00 #> → optimizing duplicate expressions in FD model... #> [====|====|====|====|====|====|====|====|====|====] 0:00:00 #> → compiling EBE model... #> using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’ #> ✔ done #> → compiling events FD model... #> using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’ #> ✔ done #> → Calculating residuals/tables #> ✔ done #> Warning in xpose.nlmixr2::xpose_data_nlmixr(fit): Added CWRES to fit (using #> nlmixr2::addCwres)... #> Skipping table: skip_table (NA found, not generated) #> Skipping figure: res_vs_pred_idv (NA found, not generated) #> Skipping figure: eta_cont (NA found, not generated) #> Skipping figure: eta_cat (NA found, not generated) #> Skipping figure: skip_figure (NA found, not generated) save_report(obnd_pptx, \"mod-PowerPoint.pptx\") #> $isgood #> [1] TRUE #> #> $msgs #> NULL"},{"path":"/articles/create-office.html","id":"step-4-create-a-word-file","dir":"Articles","previous_headings":"","what":"Step 4: Create a Word file","title":"Create PowerPoint and Word documents using nonmem2rx","text":"Just like PowerPoint, can customizeown custom word templates, example use ones come nlmixr2rpt directly: gives word document ","code":"obnd_docx = read_template( template = system.file(package=\"nlmixr2rpt\", \"templates\",\"nlmixr_obnd_template.docx\"), mapping = system.file(package=\"nlmixr2rpt\", \"templates\",\"nlmixr_obnd_template.yaml\")) obnd_docx = report_fit( fit = fit, obnd = obnd_docx) #> → Calculating residuals/tables #> ✔ done #> Warning in xpose.nlmixr2::xpose_data_nlmixr(fit): Added CWRES to fit (using #> nlmixr2::addCwres)... #> Skipping figure: res_vs_pred_idv (NA found, not generated) #> Skipping figure: skip_figure (NA found, not generated) #> Skipping figure: eta_cont (NA found, not generated) #> Skipping figure: eta_cat (NA found, not generated) save_report(obnd_docx, \"mod-Word.docx\") #> $isgood #> [1] TRUE #> #> $msgs #> NULL"},{"path":"/articles/create-vpc.html","id":"step-1-convert-the-nonmem-model-to-rxode2","dir":"Articles","previous_headings":"","what":"Step 1: Convert the NONMEM model to rxode2:","title":"Easily Create a VPC using nonmem2rx","text":"","code":"library(babelmixr2) #> Loading required package: nlmixr2 #> Loading required package: nlmixr2data library(nonmem2rx) # First we need the location of the nonmem control stream Since we are running an example, we will use one of the built-in examples in `nonmem2rx` ctlFile <- system.file(\"mods/cpt/runODE032.ctl\", package=\"nonmem2rx\") # You can use a control stream or other file. With the development # version of `babelmixr2`, you can simply point to the listing file mod <- nonmem2rx(ctlFile, lst=\".res\", save=FALSE) #> ℹ getting information from '/home/runner/work/_temp/Library/nonmem2rx/mods/cpt/runODE032.ctl' #> ℹ reading in xml file #> ℹ done #> ℹ reading in ext file #> ℹ done #> ℹ reading in phi file #> ℹ done #> ℹ reading in lst file #> ℹ abbreviated list parsing #> ℹ done #> ℹ done #> ℹ splitting control stream by records #> ℹ done #> ℹ Processing record $INPUT #> ℹ Processing record $MODEL #> ℹ Processing record $gTHETA #> ℹ Processing record $OMEGA #> ℹ Processing record $SIGMA #> ℹ Processing record $PROBLEM #> ℹ Processing record $DATA #> ℹ Processing record $SUBROUTINES #> ℹ Processing record $PK #> ℹ Processing record $DES #> ℹ Processing record $ERROR #> ℹ Processing record $ESTIMATION #> ℹ Ignore record $ESTIMATION #> ℹ Processing record $COVARIANCE #> ℹ Ignore record $COVARIANCE #> ℹ Processing record $TABLE #> ℹ change initial estimate of `theta1` to `1.37034036528946` #> ℹ change initial estimate of `theta2` to `4.19814911033061` #> ℹ change initial estimate of `theta3` to `1.38003493562413` #> ℹ change initial estimate of `theta4` to `3.87657341967489` #> ℹ change initial estimate of `theta5` to `0.196446108190896` #> ℹ change initial estimate of `eta1` to `0.101251418415006` #> ℹ change initial estimate of `eta2` to `0.0993872449483344` #> ℹ change initial estimate of `eta3` to `0.101302674763154` #> ℹ change initial estimate of `eta4` to `0.0730497519364148` #> ℹ read in nonmem input data (for model validation): /home/runner/work/_temp/Library/nonmem2rx/mods/cpt/Bolus_2CPT.csv #> ℹ ignoring lines that begin with a letter (IGNORE=@)' #> ℹ applying names specified by $INPUT #> ℹ subsetting accept/ignore filters code: .data[-which((.data$SD == 0)),] #> ℹ done #> ℹ read in nonmem IPRED data (for model validation): /home/runner/work/_temp/Library/nonmem2rx/mods/cpt/runODE032.csv #> ℹ done #> ℹ changing most variables to lower case #> ℹ done #> ℹ replace theta names #> ℹ done #> ℹ replace eta names #> ℹ done (no labels) #> ℹ renaming compartments #> ℹ done #> ℹ solving ipred problem #> ℹ done #> ℹ solving pred problem #> ℹ done"},{"path":"/articles/create-vpc.html","id":"step-2-convert-the-rxode2-model-to-nlmixr2","dir":"Articles","previous_headings":"","what":"Step 2: convert the rxode2 model to nlmixr2","title":"Easily Create a VPC using nonmem2rx","text":"step, convert model nlmixr2 .nlmixr2(mod); may need little manual work get residual specification match nlmixr2 NONMEM. residual specification compatible nlmixr2 object, can convert model, mod, nlmixr2 fit object:","code":"fit <- as.nlmixr2(mod) #> → loading into symengine environment... #> → pruning branches (`if`/`else`) of full model... #> ✔ done #> → finding duplicate expressions in EBE model... #> [====|====|====|====|====|====|====|====|====|====] 0:00:00 #> → optimizing duplicate expressions in EBE model... #> [====|====|====|====|====|====|====|====|====|====] 0:00:00 #> → compiling EBE model... #> ✔ done #> rxode2 3.0.0 using 2 threads (see ?getRxThreads) #> no cache: create with `rxCreateCache()` #> → Calculating residuals/tables #> ✔ done #> → compress origData in nlmixr2 object, save 204016 #> → compress parHistData in nlmixr2 object, save 2184 fit #> ── nlmixr² nonmem2rx reading NONMEM ver 7.4.3 ── #> #> OBJF AIC BIC Log-likelihood Condition#(Cov) #> nonmem2rx 15977.28 20185.64 20237.23 -10083.82 335.4129 #> Condition#(Cor) #> nonmem2rx 2.096559 #> #> ── Time (sec fit$time): ── #> #> setup table compress NONMEM as.nlmixr2 #> elapsed 0.042329 0.093 0.011 100.95 2.473 #> #> ── Population Parameters (fit$parFixed or fit$parFixedDf): ── #> #> Parameter Est. SE %RSE Back-transformed(95%CI) BSV(CV%) #> theta1 log Cl 1.37 0.0298 2.17 3.94 (3.71, 4.17) 32.6 #> theta2 log Vc 4.2 0.0295 0.703 66.6 (62.8, 70.5) 32.3 #> theta3 log Q 1.38 0.0547 3.96 3.98 (3.57, 4.42) 32.7 #> theta4 log Vp 3.88 0.0348 0.899 48.3 (45.1, 51.7) 27.5 #> RSV RSV 0.196 0.196 #> Shrink(SD)% #> theta1 1.94% #> theta2 2.46% #> theta3 40.5% #> theta4 28.4% #> RSV #> #> Covariance Type (fit$covMethod): nonmem2rx #> No correlations in between subject variability (BSV) matrix #> Full BSV covariance (fit$omega) or correlation (fit$omegaR; diagonals=SDs) #> Distribution stats (mean/skewness/kurtosis/p-value) available in fit$shrink #> Censoring (fit$censInformation): No censoring #> Minimization message (fit$message): #> #> #> WARNINGS AND ERRORS (IF ANY) FOR PROBLEM 1 #> #> (WARNING 2) NM-TRAN INFERS THAT THE DATA ARE POPULATION. #> #> #> 0MINIMIZATION SUCCESSFUL #> NO. OF FUNCTION EVALUATIONS USED: 320 #> NO. OF SIG. DIGITS IN FINAL EST.: 2.5 #> #> IPRED relative difference compared to Nonmem IPRED: 0%; 95% percentile: (0%,0%); rtol=6.43e-06 #> PRED relative difference compared to Nonmem PRED: 0%; 95% percentile: (0%,0%); rtol=6.41e-06 #> IPRED absolute difference compared to Nonmem IPRED: 95% percentile: (2.25e-05, 0.0418); atol=0.00167 #> PRED absolute difference compared to Nonmem PRED: 95% percentile: (1.41e-07,0.00382); atol=6.41e-06 #> nonmem2rx model file: '/home/runner/work/_temp/Library/nonmem2rx/mods/cpt/runODE032.ctl' #> #> ── Fit Data (object fit is a modified tibble): ── #> # A tibble: 2,280 × 27 #> ID TIME DV PRED RES IPRED IRES IWRES eta1 eta2 eta3 eta4 #> #> 1 1 0.25 1041. 1750. -710. 1215. -175. -0.732 -0.144 0.375 0.0650 0.241 #> 2 1 0.5 1629 1700. -70.8 1192. 437. 1.87 -0.144 0.375 0.0650 0.241 #> 3 1 0.75 878. 1651. -774. 1169. -291. -1.27 -0.144 0.375 0.0650 0.241 #> # ℹ 2,277 more rows #> # ℹ 15 more variables: ipred , CENTRAL , PERI , cl , #> # v , q , v2 , v1 , scale1 , k21 , k12 , #> # f , rescv , tad , dosenum "},{"path":"/articles/create-vpc.html","id":"step-3-perform-the-vpc","dir":"Articles","previous_headings":"","what":"Step 3: Perform the VPC","title":"Easily Create a VPC using nonmem2rx","text":"simply use vpcPlot() conjunction vpc package get regular prediction-corrected VPCs arrange single plot:","code":"library(ggplot2) p1 <- vpcPlot(fit, show=list(obs_dv=TRUE)) #> using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’ #> [====|====|====|====|====|====|====|====|====|====] 0:00:00 p1 <- p1 + ylab(\"Concentrations\") + rxode2::rxTheme() + xlab(\"Time (hr)\") + xgxr::xgx_scale_x_time_units(\"hour\", \"hour\") p1a <- p1 + xgxr::xgx_scale_y_log10() ## A prediction-corrected VPC p2 <- vpcPlot(fit, pred_corr = TRUE, show=list(obs_dv=TRUE)) #> [====|====|====|====|====|====|====|====|====|====] 0:00:00 p2 <- p2 + ylab(\"Prediction-Corrected Concentrations\") + rxode2::rxTheme() + xlab(\"Time (hr)\") + xgxr::xgx_scale_x_time_units(\"hour\", \"hour\") p2a <- p2 + xgxr::xgx_scale_y_log10() library(patchwork) (p1 * p1a) / (p2 * p2a)"},{"path":"/articles/import-nonmem.html","id":"setting-up-nonmem2rx-for-your-model","dir":"Articles","previous_headings":"","what":"Setting up nonmem2rx for your model","title":"Importing NONMEM into rxode2","text":"common options may want change importing NONMEM control stream : default NONMEM output extension; default .lst. can set something else, like .res, using following option: options(nonmem2rx.lst=\".res\"). Turn extended control stream support. can turn options(nonmem2rx.extended=TRUE) probably also want change name parameters compartments. easiest way name parameters whatever want pre-specify names. example: checks parameter names make sure length input names, , model skip parameter renaming keep default translation names theta# eta#. note, sigma parameters currently renamed; following model (grabs parameter automatically labels generate variables), sigma simply eps#. can still rename however wish, though, using model piping (rxRename() dplyr::rename() work): model specify residuals way makes sense nlmixr2. want, can still convert rxode2 model nlmixr2 fit.","code":"mod <- nonmem2rx(system.file(\"mods/cpt/runODE032.ctl\", package=\"nonmem2rx\"), lst=\".res\", save=FALSE, thetaNames=c(\"lcl\", \"lvc\", \"lq\", \"lvp\", \"prop.sd\"), etaNames=c(\"eta.cl\", \"eta.vc\", \"eta.q\",\"eta.vp\"), cmtNames = c(\"central\", \"perip\")) #> ℹ getting information from '/home/runner/work/_temp/Library/nonmem2rx/mods/cpt/runODE032.ctl' #> ℹ reading in xml file #> ℹ done #> ℹ reading in ext file #> ℹ done #> ℹ reading in phi file #> ℹ done #> ℹ reading in lst file #> ℹ abbreviated list parsing #> ℹ done #> ℹ done #> ℹ splitting control stream by records #> ℹ done #> ℹ Processing record $INPUT #> ℹ Processing record $MODEL #> ℹ Processing record $gTHETA #> ℹ Processing record $OMEGA #> ℹ Processing record $SIGMA #> ℹ Processing record $PROBLEM #> ℹ Processing record $DATA #> ℹ Processing record $SUBROUTINES #> ℹ Processing record $PK #> ℹ Processing record $DES #> ℹ Processing record $ERROR #> ℹ Processing record $ESTIMATION #> ℹ Ignore record $ESTIMATION #> ℹ Processing record $COVARIANCE #> ℹ Ignore record $COVARIANCE #> ℹ Processing record $TABLE #> ℹ change initial estimate of `theta1` to `1.37034036528946` #> ℹ change initial estimate of `theta2` to `4.19814911033061` #> ℹ change initial estimate of `theta3` to `1.38003493562413` #> ℹ change initial estimate of `theta4` to `3.87657341967489` #> ℹ change initial estimate of `theta5` to `0.196446108190896` #> ℹ change initial estimate of `eta1` to `0.101251418415006` #> ℹ change initial estimate of `eta2` to `0.0993872449483344` #> ℹ change initial estimate of `eta3` to `0.101302674763154` #> ℹ change initial estimate of `eta4` to `0.0730497519364148` #> ℹ read in nonmem input data (for model validation): /home/runner/work/_temp/Library/nonmem2rx/mods/cpt/Bolus_2CPT.csv #> ℹ ignoring lines that begin with a letter (IGNORE=@)' #> ℹ applying names specified by $INPUT #> ℹ subsetting accept/ignore filters code: .data[-which((.data$SD == 0)),] #> ℹ done #> using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’ #> ℹ read in nonmem IPRED data (for model validation): /home/runner/work/_temp/Library/nonmem2rx/mods/cpt/runODE032.csv #> ℹ done #> ℹ changing most variables to lower case #> ℹ done #> ℹ replace theta names #> ℹ done #> ℹ replace eta names #> ℹ done #> ℹ renaming compartments #> ℹ done #> using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’ #> ℹ solving ipred problem #> ℹ done #> ℹ solving pred problem #> ℹ done mod #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> lcl lvc lq lvp prop.sd #> 1.3703404 4.1981491 1.3800349 3.8765734 0.1964461 #> #> Omega ($omega): #> eta.cl eta.vc eta.q eta.vp #> eta.cl 0.1012514 0.00000000 0.0000000 0.00000000 #> eta.vc 0.0000000 0.09938724 0.0000000 0.00000000 #> eta.q 0.0000000 0.00000000 0.1013027 0.00000000 #> eta.vp 0.0000000 0.00000000 0.0000000 0.07304975 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 central #> 2 2 perip #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 lcl eta.cl id #> 2 lvc eta.vc id #> 3 lq eta.q id #> 4 lvp eta.vp id #> #> ── Model (Normalized Syntax): ── #> function() { #> description <- \"BOLUS_2CPT_CLV1QV2 SINGLE DOSE FOCEI (120 Ind/2280 Obs) runODE032\" #> dfObs <- 2280 #> dfSub <- 120 #> sigma <- lotri({ #> eps1 ~ 1 #> }) #> thetaMat <- lotri({ #> lcl ~ c(lcl = 0.000887681) #> lvc ~ c(lcl = -0.00010551, lvc = 0.000871409) #> lq ~ c(lcl = 0.000184416, lvc = -0.000106195, lq = 0.00299336) #> lvp ~ c(lcl = -0.000120234, lvc = -5.06663e-05, lq = 0.000165252, #> lvp = 0.00121347) #> prop.sd ~ c(lcl = 5.2783e-08, lvc = -1.56562e-05, lq = 5.99331e-06, #> lvp = -2.53991e-05, prop.sd = 9.94218e-06) #> eps1 ~ c(lcl = 0, lvc = 0, lq = 0, lvp = 0, prop.sd = 0, #> eps1 = 0) #> eta.cl ~ c(lcl = -4.71273e-05, lvc = 4.69667e-05, lq = -3.64271e-05, #> lvp = 2.54796e-05, prop.sd = -8.16885e-06, eps1 = 0, #> eta.cl = 0.000169296) #> omega.2.1 ~ c(lcl = 0, lvc = 0, lq = 0, lvp = 0, prop.sd = 0, #> eps1 = 0, eta.cl = 0, omega.2.1 = 0) #> eta.vc ~ c(lcl = -7.37156e-05, lvc = 2.56634e-05, lq = -8.08349e-05, #> lvp = 1.37e-05, prop.sd = -4.36564e-06, eps1 = 0, #> eta.cl = 8.75181e-06, omega.2.1 = 0, eta.vc = 0.00015125) #> omega.3.1 ~ c(lcl = 0, lvc = 0, lq = 0, lvp = 0, prop.sd = 0, #> eps1 = 0, eta.cl = 0, omega.2.1 = 0, eta.vc = 0, #> omega.3.1 = 0) #> omega.3.2 ~ c(lcl = 0, lvc = 0, lq = 0, lvp = 0, prop.sd = 0, #> eps1 = 0, eta.cl = 0, omega.2.1 = 0, eta.vc = 0, #> omega.3.1 = 0, omega.3.2 = 0) #> eta.q ~ c(lcl = 6.63383e-05, lvc = -8.19002e-05, lq = 0.000548985, #> lvp = 0.000168356, prop.sd = 1.59122e-06, eps1 = 0, #> eta.cl = 3.48714e-05, omega.2.1 = 0, eta.vc = 4.31593e-07, #> omega.3.1 = 0, omega.3.2 = 0, eta.q = 0.000959029) #> omega.4.1 ~ c(lcl = 0, lvc = 0, lq = 0, lvp = 0, prop.sd = 0, #> eps1 = 0, eta.cl = 0, omega.2.1 = 0, eta.vc = 0, #> omega.3.1 = 0, omega.3.2 = 0, eta.q = 0, omega.4.1 = 0) #> omega.4.2 ~ c(lcl = 0, lvc = 0, lq = 0, lvp = 0, prop.sd = 0, #> eps1 = 0, eta.cl = 0, omega.2.1 = 0, eta.vc = 0, #> omega.3.1 = 0, omega.3.2 = 0, eta.q = 0, omega.4.1 = 0, #> omega.4.2 = 0) #> omega.4.3 ~ c(lcl = 0, lvc = 0, lq = 0, lvp = 0, prop.sd = 0, #> eps1 = 0, eta.cl = 0, omega.2.1 = 0, eta.vc = 0, #> omega.3.1 = 0, omega.3.2 = 0, eta.q = 0, omega.4.1 = 0, #> omega.4.2 = 0, omega.4.3 = 0) #> eta.vp ~ c(lcl = -9.49661e-06, lvc = 0.000110108, lq = -0.000306537, #> lvp = -9.12897e-05, prop.sd = 3.1877e-06, eps1 = 0, #> eta.cl = 1.36628e-05, omega.2.1 = 0, eta.vc = -1.95096e-05, #> omega.3.1 = 0, omega.3.2 = 0, eta.q = -0.00012977, #> omega.4.1 = 0, omega.4.2 = 0, omega.4.3 = 0, eta.vp = 0.00051019) #> }) #> validation <- c(\"IPRED relative difference compared to Nonmem IPRED: 0%; 95% percentile: (0%,0%); rtol=6.43e-06\", #> \"IPRED absolute difference compared to Nonmem IPRED: 95% percentile: (2.19e-05, 0.0418); atol=0.00167\", #> \"IWRES relative difference compared to Nonmem IWRES: 0%; 95% percentile: (0%,0.01%); rtol=8.99e-06\", #> \"IWRES absolute difference compared to Nonmem IWRES: 95% percentile: (1.82e-07, 4.63e-05); atol=3.65e-06\", #> \"PRED relative difference compared to Nonmem PRED: 0%; 95% percentile: (0%,0%); rtol=6.41e-06\", #> \"PRED absolute difference compared to Nonmem PRED: 95% percentile: (1.41e-07,0.00382) atol=6.41e-06\") #> ini({ #> lcl <- 1.37034036528946 #> label(\"log Cl\") #> lvc <- 4.19814911033061 #> label(\"log Vc\") #> lq <- 1.38003493562413 #> label(\"log Q\") #> lvp <- 3.87657341967489 #> label(\"log Vp\") #> prop.sd <- c(0, 0.196446108190896, 1) #> label(\"RSV\") #> eta.cl ~ 0.101251418415006 #> eta.vc ~ 0.0993872449483344 #> eta.q ~ 0.101302674763154 #> eta.vp ~ 0.0730497519364148 #> }) #> model({ #> cmt(central) #> cmt(perip) #> cl <- exp(lcl + eta.cl) #> v <- exp(lvc + eta.vc) #> q <- exp(lq + eta.q) #> v2 <- exp(lvp + eta.vp) #> v1 <- v #> scale1 <- v #> k21 <- q/v2 #> k12 <- q/v #> d/dt(central) <- k21 * perip - k12 * central - cl * central/v1 #> d/dt(perip) <- -k21 * perip + k12 * central #> f <- central/scale1 #> ipred <- f #> rescv <- prop.sd #> ipred ~ prop(prop.sd) #> }) #> } #> ── nonmem2rx extra properties: ── #> other properties include: $nonmemData, $etaData #> captured NONMEM table outputs: $predData, $ipredData #> NONMEM/rxode2 comparison data: $iwresCompare, $predCompare, $ipredCompare #> NONMEM/rxode2 composite comparison: $predAtol, $predRtol, $ipredAtol, $ipredRtol, $iwresAtol, $iwresRtol mod <- nonmem2rx(system.file(\"Theopd.ctl\", package=\"nonmem2rx\"), save=FALSE) #> ℹ getting information from '/home/runner/work/_temp/Library/nonmem2rx/Theopd.ctl' #> ℹ reading in lst file #> ℹ seeing if file argument is actually lst file #> ℹ not list file, control stream #> ℹ done #> ℹ splitting control stream by records #> ℹ done #> ℹ Processing record $INPUT #> ℹ Processing record $gTHETA #> ℹ Processing record $OMEGA #> ℹ Processing record $SIGMA #> ℹ Processing record $PROBLEM #> ℹ Processing record $DATA #> ℹ Processing record $ESTIMATION #> ℹ Ignore record $ESTIMATION #> ℹ Processing record $COVARIANCE #> ℹ Ignore record $COVARIANCE #> ℹ Processing record $PRED #> ℹ Processing record $TABLE #> ℹ final parameters not updated, will skip validation #> ℹ changing most variables to lower case #> ℹ done #> ℹ replace theta names #> ℹ done #> ℹ replace eta names #> ℹ done mod #> ── rxode2-based Pred model ───────────────────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> POP_E0 POP_EMAX POP_C50 #> 150 200 10 #> #> Omega ($omega): #> PPV_E0 PPV_EMAX PPV_C50 #> PPV_E0 0.5 0.0 0.0 #> PPV_EMAX 0.0 0.5 0.0 #> PPV_C50 0.0 0.0 0.5 #> ── Model (Normalized Syntax): ── #> function() { #> description <- \"theophylline pharmacodynamics standard control stream\" #> sigma <- lotri({ #> eps1 ~ 100 #> }) #> validation <- \"final parameters not updated, validation skipped\" #> ini({ #> POP_E0 <- c(0, 150) #> label(\"POP_E0 1\") #> POP_EMAX <- c(0, 200) #> label(\"POP_EMAX 2\") #> POP_C50 <- c(0.001, 10) #> label(\"POP_C50 3\") #> PPV_E0 ~ 0.5 #> PPV_EMAX ~ 0.5 #> PPV_C50 ~ 0.5 #> }) #> model({ #> e0 <- POP_E0 * exp(PPV_E0) #> emax <- POP_EMAX * exp(PPV_EMAX) #> ec50 <- POP_C50 * exp(PPV_C50) #> y <- e0 + emax * THEO/(THEO + ec50) + eps1 #> }) #> } #> ── nonmem2rx extra properties: ── #> #> Sigma ($sigma): #> eps1 #> eps1 100 #> #> other properties include: $etaData #> captured NONMEM table outputs: $predData, $ipredData #> NONMEM/rxode2 comparison data: $iwresCompare, $predCompare, $ipredCompare #> NONMEM/rxode2 composite comparison: $predAtol, $predRtol, $ipredAtol, $ipredRtol, $iwresAtol, $iwresRtol mod <- mod %>% rxRename(add.var=eps1) mod #> ── rxode2-based Pred model ───────────────────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> POP_E0 POP_EMAX POP_C50 #> 150 200 10 #> #> Omega ($omega): #> PPV_E0 PPV_EMAX PPV_C50 #> PPV_E0 0.5 0.0 0.0 #> PPV_EMAX 0.0 0.5 0.0 #> PPV_C50 0.0 0.0 0.5 #> ── Model (Normalized Syntax): ── #> function() { #> description <- \"theophylline pharmacodynamics standard control stream\" #> sigma <- lotri({ #> add.var ~ 100 #> }) #> validation <- \"final parameters not updated, validation skipped\" #> ini({ #> POP_E0 <- c(0, 150) #> label(\"POP_E0 1\") #> POP_EMAX <- c(0, 200) #> label(\"POP_EMAX 2\") #> POP_C50 <- c(0.001, 10) #> label(\"POP_C50 3\") #> PPV_E0 ~ 0.5 #> PPV_EMAX ~ 0.5 #> PPV_C50 ~ 0.5 #> }) #> model({ #> e0 <- POP_E0 * exp(PPV_E0) #> emax <- POP_EMAX * exp(PPV_EMAX) #> ec50 <- POP_C50 * exp(PPV_C50) #> y <- e0 + emax * THEO/(THEO + ec50) + add.var #> }) #> } #> ── nonmem2rx extra properties: ── #> #> Sigma ($sigma): #> add.var #> add.var 100 #> #> other properties include: $etaData #> captured NONMEM table outputs: $predData, $ipredData #> NONMEM/rxode2 comparison data: $iwresCompare, $predCompare, $ipredCompare #> NONMEM/rxode2 composite comparison: $predAtol, $predRtol, $ipredAtol, $ipredRtol, $iwresAtol, $iwresRtol"},{"path":"/articles/import-nonmem.html","id":"technical-details-about-reading-nonmem-to-rxode2","dir":"Articles","previous_headings":"","what":"Technical details about reading NONMEM to rxode2","title":"Importing NONMEM into rxode2","text":"key files import NONMEM control stream (related file) NONMEM output (often .lst .res extension). import process steps : Read nonmem control stream convert model rxode2 ui function. Try determine endpoint/residual specification model (possible), convert fully qualified ui model can used nlmixr2 rxode2. determined automatically, can manually fix still convert nlmixr2 object (data/estimates available course). available, nonmem2rx read final parameter estimates update model. converter read nonmem input dataset, search output files IPRED, PRED ETA values. translated rxode2 model run population parameters individual parameters. compare results NONMEM rxode2 make sure translation makes sense. works nonmem2rx access input data output IWRES, IPRED, PRED ETA values. Converts upper case NONMEM variables lower case (can turned nonmem2rx(..., toLowerLhs=FALSE))) Replaces NONMEM theta / eta names label-based names like extended control stream (can turned nonmem2rx(thetaNames=FALSE, etaNames=FALSE)) Replaces compartment names defined compartment names control stream (ie COMP=(compartmenName))","code":""},{"path":"/articles/read-rounding.html","id":"step-1-have-a-nonmem-model-with-rounding-errors-and--phi-or-other-information-about-the-etas","dir":"Articles","previous_headings":"","what":"Step 1: Have a NONMEM model with rounding errors (and .phi or other information about the etas)","title":"Reading rounding from NONMEM","text":"first step load model rounding errors using nonmem2rx():","code":"# Unzip example with rounding error # included, but can be accessed with nlmixr2 # # unzip(system.file(\"tests/testthat/pk.turnover.emax3-nonmem.zip\", package=\"babelmixr2\")) # Load the model with `nonmem2rx`: mod <- nonmem2rx(\"pk.turnover.emax3-nonmem/pk.turnover.emax3.nmctl\") #> ℹ getting information from 'pk.turnover.emax3-nonmem/pk.turnover.emax3.nmctl' #> ℹ reading in xml file #> ℹ done #> ℹ reading in ext file #> ℹ done #> ℹ reading in phi file #> ℹ done #> ℹ reading in lst file #> ℹ abbreviated list parsing #> ℹ done #> ℹ done #> ℹ splitting control stream by records #> ℹ done #> ℹ Processing record $INPUT #> ℹ Processing record $MODEL #> ℹ Processing record $gTHETA #> ℹ Processing record $OMEGA #> ℹ Processing record $SIGMA #> ℹ Processing record $PROBLEM #> ℹ Processing record $DATA #> ℹ Processing record $SUBROUTINES #> ℹ Processing record $PK #> ℹ Processing record $DES #> ℹ Processing record $ERROR #> ℹ Processing record $ESTIMATION #> ℹ Ignore record $ESTIMATION #> ℹ Processing record $COVARIANCE #> ℹ Ignore record $COVARIANCE #> ℹ Processing record $TABLE #> ℹ change initial estimate of `theta1` to `6.24053043162953e-07` #> ℹ change initial estimate of `theta2` to `-3.00642760553675e-06` #> ℹ change initial estimate of `theta3` to `-2.00405074386117` #> ℹ change initial estimate of `theta4` to `2.05188410700476` #> ℹ change initial estimate of `theta5` to `0.0985804613565218` #> ℹ change initial estimate of `theta6` to `0.511625249037084` #> ℹ change initial estimate of `theta7` to `6.4184983102259` #> ℹ change initial estimate of `theta8` to `0.140763261319656` #> ℹ change initial estimate of `theta9` to `-2.9534704318737` #> ℹ change initial estimate of `theta10` to `4.57045413136592` #> ℹ change initial estimate of `theta11` to `3.71714384851537` #> ℹ change initial estimate of `eta1` to `0.558129815059436` #> ℹ change initial estimate of `eta2` to `0.558402321309217` #> ℹ change initial estimate of `eta3` to `0.0785849119252598` #> ℹ change initial estimate of `eta4` to `0.0508226905750953` #> ℹ change initial estimate of `eta5` to `5e-05` #> ℹ change initial estimate of `eta6` to `0.18426809257979` #> ℹ change initial estimate of `eta7` to `0.0083631531443303` #> ℹ change initial estimate of `eta8` to `0.00274561514766752` #> ℹ read in nonmem input data (for model validation): /home/runner/work/nonmem2rx/nonmem2rx/vignettes/articles/pk.turnover.emax3-nonmem/pk.turnover.emax3.csv #> ℹ ignoring lines that begin with a letter (IGNORE=@)' #> ℹ applying names specified by $INPUT #> ℹ renaming 'dvid' to 'nmdvid' #> ℹ done #> using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’ #> ℹ read in nonmem IPRED data (for model validation): /home/runner/work/nonmem2rx/nonmem2rx/vignettes/articles/pk.turnover.emax3-nonmem/pk.turnover.emax3.pred #> ℹ done #> ℹ changing most variables to lower case #> ℹ done #> ℹ replace theta names #> ℹ done #> ℹ replace eta names #> ℹ done #> ℹ renaming compartments #> ℹ done #> using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’ #> ℹ solving ipred problem #> ℹ done #> ℹ solving pred problem #> ℹ done mod #> ── rxode2-based free-form 4-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tktr tka tcl tv prop.err #> 6.240530e-07 -3.006428e-06 -2.004051e+00 2.051884e+00 9.858046e-02 #> pkadd.err temax tec50 tkout te0 #> 5.116252e-01 6.418498e+00 1.407633e-01 -2.953470e+00 4.570454e+00 #> pdadd.err #> 3.717144e+00 #> #> Omega ($omega): #> eta.ktr eta.ka eta.cl eta.v eta.emax eta.ec50 #> eta.ktr 0.5581298 0.0000000 0.00000000 0.00000000 0e+00 0.0000000 #> eta.ka 0.0000000 0.5584023 0.00000000 0.00000000 0e+00 0.0000000 #> eta.cl 0.0000000 0.0000000 0.07858491 0.00000000 0e+00 0.0000000 #> eta.v 0.0000000 0.0000000 0.00000000 0.05082269 0e+00 0.0000000 #> eta.emax 0.0000000 0.0000000 0.00000000 0.00000000 5e-05 0.0000000 #> eta.ec50 0.0000000 0.0000000 0.00000000 0.00000000 0e+00 0.1842681 #> eta.kout 0.0000000 0.0000000 0.00000000 0.00000000 0e+00 0.0000000 #> eta.e0 0.0000000 0.0000000 0.00000000 0.00000000 0e+00 0.0000000 #> eta.kout eta.e0 #> eta.ktr 0.000000000 0.000000000 #> eta.ka 0.000000000 0.000000000 #> eta.cl 0.000000000 0.000000000 #> eta.v 0.000000000 0.000000000 #> eta.emax 0.000000000 0.000000000 #> eta.ec50 0.000000000 0.000000000 #> eta.kout 0.008363153 0.000000000 #> eta.e0 0.000000000 0.002745615 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 DEPOT #> 2 2 GUT #> 3 3 CENTER #> 4 4 EFFECT #> ── Model (Normalized Syntax): ── #> function() { #> description <- c(\"translated from babelmixr2\", \"; comments show mu referenced model in ui$getSplitMuModel\") #> dfObs <- 483 #> dfSub <- 32 #> sigma <- lotri({ #> eps1 ~ 1 #> }) #> validation <- c(\"IPRED relative difference compared to Nonmem IPRED: 0%; 95% percentile: (0%,0%); rtol=6.13e-06\", #> \"IPRED absolute difference compared to Nonmem IPRED: 95% percentile: (3.12e-06, 0.000497); atol=6.17e-05\", #> \"PRED relative difference compared to Nonmem PRED: 0%; 95% percentile: (0%,0%); rtol=6.18e-06\", #> \"PRED absolute difference compared to Nonmem PRED: 95% percentile: (3.79e-07,0.00313) atol=6.18e-06\") #> ini({ #> tktr <- 6.24053043162953e-07 #> label(\"1 - tktr\") #> tka <- -3.00642760553675e-06 #> label(\"2 - tka\") #> tcl <- -2.00405074386117 #> label(\"3 - tcl\") #> tv <- 2.05188410700476 #> label(\"4 - tv\") #> prop.err <- c(0, 0.0985804613565218) #> label(\"5 - prop.err\") #> pkadd.err <- c(0, 0.511625249037084) #> label(\"6 - pkadd.err\") #> temax <- 6.4184983102259 #> label(\"7 - temax\") #> tec50 <- 0.140763261319656 #> label(\"8 - tec50\") #> tkout <- -2.9534704318737 #> label(\"9 - tkout\") #> te0 <- 4.57045413136592 #> label(\"10 - te0\") #> pdadd.err <- c(0, 3.71714384851537) #> label(\"11 - pdadd.err\") #> eta.ktr ~ 0.558129815059436 #> eta.ka ~ 0.558402321309217 #> eta.cl ~ 0.0785849119252598 #> eta.v ~ 0.0508226905750953 #> eta.emax ~ 5e-05 #> eta.ec50 ~ 0.18426809257979 #> eta.kout ~ 0.0083631531443303 #> eta.e0 ~ 0.00274561514766752 #> }) #> model({ #> cmt(DEPOT) #> cmt(GUT) #> cmt(CENTER) #> cmt(EFFECT) #> mu_1 <- tktr #> mu_2 <- tka #> mu_3 <- tcl #> mu_4 <- tv #> mu_5 <- temax #> mu_6 <- tec50 #> mu_7 <- tkout #> mu_8 <- te0 #> ktr <- exp(mu_1 + eta.ktr) #> ka <- exp(mu_2 + eta.ka) #> cl <- exp(mu_3 + eta.cl) #> v <- exp(mu_4 + eta.v) #> emax <- ((1) - (0)) * (1/(1 + exp(-(mu_5 + eta.emax)))) + #> (0) #> ec50 <- exp(mu_6 + eta.ec50) #> kout <- exp(mu_7 + eta.kout) #> e0 <- exp(mu_8 + eta.e0) #> rxini.rxddta4. <- e0 #> EFFECT(0) <- rxini.rxddta4. #> dcp <- CENTER/v #> rxdz001 <- (ec50 + dcp) #> if (rxdz001 >= 0 && rxdz001 <= 1e-06) { #> rxdz001 <- 1e-06 #> } #> if (rxdz001 >= -1e-06 && rxdz001 < 0) { #> rxdz001 <- -1e-06 #> } #> pd <- 1 - emax * dcp/rxdz001 #> kin <- e0 * kout #> d/dt(DEPOT) <- -ktr * DEPOT #> d/dt(GUT) <- ktr * DEPOT - ka * GUT #> d/dt(CENTER) <- ka * GUT - cl/v * CENTER #> d/dt(EFFECT) <- kin * pd - kout * EFFECT #> cp <- CENTER/v #> f <- DEPOT #> rxe_dcp <- CENTER/v #> rxdze001 <- (ec50 + rxe_dcp) #> if (rxdze001 >= 0 && rxdze001 <= 1e-06) { #> rxdze001 <- 1e-06 #> } #> if (rxdze001 >= -1e-06 && rxdze001 < 0) { #> rxdze001 <- -1e-06 #> } #> rxe_pd <- 1 - emax * rxe_dcp/rxdze001 #> rxe_kin <- e0 * kout #> rxe_cp <- CENTER/v #> rx_pf1 <- rxe_cp #> rx_pf2 <- EFFECT #> rx_ip1 <- rx_pf1 #> rx_p1 <- rx_ip1 #> w1 <- sqrt((pkadd.err)^2 + (rx_pf1)^2 * (prop.err)^2) #> if (w1 == 0) #> w1 <- 1 #> rx_ip2 <- rx_pf2 #> rx_p2 <- rx_ip2 #> w2 <- sqrt((pdadd.err)^2) #> if (w2 == 0) #> w2 <- 1 #> ipred <- rx_ip1 #> w <- w1 #> if (nmdvid == 2) { #> ipred <- rx_ip2 #> w <- w2 #> } #> y <- ipred + w * eps1 #> }) #> } #> ── nonmem2rx translation notes ($notes): ── #> • some etas defaulted to non-mu referenced, possible parsing error: eta.emax as a work-around try putting the mu-referenced expression on a simple line #> • some etas defaulted to non-mu referenced, possible parsing error: eta5 as a work-around try putting the mu-referenced expression on a simple line #> • some NONMEM input has tied times; they are offset by a small offset #> • is.na() applied to non-(list or vector) of type 'language' #> • 'dvid' variable has special meaning in rxode2, renamed to 'nmdvid', rename/copy in your data too #> • $MODEL NCOMPARTMENTS/NEQUILIBRIUM/NPARAMETERS statement(s) ignored #> ── nonmem2rx extra properties: ── #> #> Sigma ($sigma): #> eps1 #> eps1 1 #> #> other properties include: $nonmemData, $etaData #> captured NONMEM table outputs: $predData, $ipredData #> NONMEM/rxode2 comparison data: $iwresCompare, $predCompare, $ipredCompare #> NONMEM/rxode2 composite comparison: $predAtol, $predRtol, $ipredAtol, $ipredRtol, $iwresAtol, $iwresRtol"},{"path":"/articles/read-rounding.html","id":"step-2-convert-rxode2-model-to-model-with-endpointsresiduals-specified-like-nlmixr2","dir":"Articles","previous_headings":"","what":"Step 2: Convert rxode2 model to model with endpoints/residuals specified like nlmixr2","title":"Reading rounding from NONMEM","text":"example rounding errors isn’t fully qualified nlmixr2 model (even though generated nlmixr2). can use model create equivalent model .nonmem2rx() model , following modifications made: code protecting rounding errors removed Endpoints/residual specifications added Duplicate code NONMEM’s $ERROR block removed imported model rx nlmixr prefixed items removed model. possible removing variables can causenlmixr2 conversion fail. best practice remove completely. Also, good practice make sure model parses correctly trying validate/convert model. find model doesn’t parse correctly definitely won’t validate (error may easy track-). first step validate translation correct. done :","code":"mod2 <- function() { ini({ tktr <- 6.24053043162953e-07 label(\"1 - tktr\") tka <- -3.00642760553675e-06 label(\"2 - tka\") tcl <- -2.00405074386117 label(\"3 - tcl\") tv <- 2.05188410700476 label(\"4 - tv\") prop.err <- c(0, 0.0985804613565218) label(\"5 - prop.err\") pkadd.err <- c(0, 0.511625249037084) label(\"6 - pkadd.err\") temax <- 6.4184983102259 label(\"7 - temax\") tec50 <- 0.140763261319656 label(\"8 - tec50\") tkout <- -2.9534704318737 label(\"9 - tkout\") te0 <- 4.57045413136592 label(\"10 - te0\") pdadd.err <- c(0, 3.71714384851537) label(\"11 - pdadd.err\") eta.ktr ~ 0.558129815059436 eta.ka ~ 0.558402321309217 eta.cl ~ 0.0785849119252598 eta.v ~ 0.0508226905750953 eta.emax ~ 5e-05 eta.ec50 ~ 0.18426809257979 eta.kout ~ 0.0083631531443303 eta.e0 ~ 0.00274561514766752 }) model({ cmt(DEPOT) cmt(GUT) cmt(CENTER) cmt(EFFECT) ktr <- exp(tktr + eta.ktr) ka <- exp(tka + eta.ka) cl <- exp(tcl + eta.cl) v <- exp(tv + eta.v) emax <- expit(temax + eta.emax) ec50 <- exp(tec50 + eta.ec50) kout <- exp(tkout + eta.kout) e0 <- exp(te0 + eta.e0) EFFECT(0) <- e0 dcp <- CENTER/v pd <- 1 - emax * dcp/(ec50 + dcp) kin <- e0 * kout d/dt(DEPOT) <- -ktr * DEPOT d/dt(GUT) <- ktr * DEPOT - ka * GUT d/dt(CENTER) <- ka * GUT - cl/v * CENTER d/dt(EFFECT) <- kin * pd - kout * EFFECT eff <- EFFECT dcp ~ add(pkadd.err)+prop(prop.err) eff ~ add(pdadd.err) }) } new <- as.nonmem2rx(mod, mod2) #> ℹ parameter labels from comments are typically ignored in non-interactive mode #> ℹ Need to run with the source intact to parse comments #> ℹ copy 'dfSub' to nonmem2rx model #> ℹ copy 'dfObs' to nonmem2rx model #> ℹ merging 'dvid' with nlmixr2 'cmt' definition #> using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’ #> ℹ solving ipred problem #> ℹ done #> ℹ solving pred problem #> ℹ done print(new) #> ── rxode2-based free-form 4-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tktr tka tcl tv prop.err #> 6.240530e-07 -3.006428e-06 -2.004051e+00 2.051884e+00 9.858046e-02 #> pkadd.err temax tec50 tkout te0 #> 5.116252e-01 6.418498e+00 1.407633e-01 -2.953470e+00 4.570454e+00 #> pdadd.err #> 3.717144e+00 #> #> Omega ($omega): #> eta.ktr eta.ka eta.cl eta.v eta.emax eta.ec50 #> eta.ktr 0.5581298 0.0000000 0.00000000 0.00000000 0e+00 0.0000000 #> eta.ka 0.0000000 0.5584023 0.00000000 0.00000000 0e+00 0.0000000 #> eta.cl 0.0000000 0.0000000 0.07858491 0.00000000 0e+00 0.0000000 #> eta.v 0.0000000 0.0000000 0.00000000 0.05082269 0e+00 0.0000000 #> eta.emax 0.0000000 0.0000000 0.00000000 0.00000000 5e-05 0.0000000 #> eta.ec50 0.0000000 0.0000000 0.00000000 0.00000000 0e+00 0.1842681 #> eta.kout 0.0000000 0.0000000 0.00000000 0.00000000 0e+00 0.0000000 #> eta.e0 0.0000000 0.0000000 0.00000000 0.00000000 0e+00 0.0000000 #> eta.kout eta.e0 #> eta.ktr 0.000000000 0.000000000 #> eta.ka 0.000000000 0.000000000 #> eta.cl 0.000000000 0.000000000 #> eta.v 0.000000000 0.000000000 #> eta.emax 0.000000000 0.000000000 #> eta.ec50 0.000000000 0.000000000 #> eta.kout 0.008363153 0.000000000 #> eta.e0 0.000000000 0.002745615 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 DEPOT #> 2 2 GUT #> 3 3 CENTER #> 4 4 EFFECT #> ── Multiple Endpoint Model ($multipleEndpoint): ── #> variable cmt dvid* #> 1 dcp ~ … cmt='dcp' or cmt=5 dvid='dcp' or dvid=1 #> 2 eff ~ … cmt='eff' or cmt=6 dvid='eff' or dvid=2 #> * If dvids are outside this range, all dvids are re-numered sequentially, ie 1,7, 10 becomes 1,2,3 etc #> #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 tktr eta.ktr id #> 2 tka eta.ka id #> 3 tcl eta.cl id #> 4 tv eta.v id #> 5 temax eta.emax id #> 6 tec50 eta.ec50 id #> 7 tkout eta.kout id #> 8 te0 eta.e0 id #> #> ── Model (Normalized Syntax): ── #> function() { #> description <- c(\"translated from babelmixr2\", \"; comments show mu referenced model in ui$getSplitMuModel\") #> dfObs <- 483 #> dfSub <- 32 #> validation <- c(\"IPRED relative difference compared to Nonmem IPRED: 0%; 95% percentile: (0%,0%); rtol=6.13e-06\", #> \"IPRED absolute difference compared to Nonmem IPRED: 95% percentile: (3.12e-06, 0.000497); atol=6.17e-05\", #> \"PRED relative difference compared to Nonmem PRED: 0%; 95% percentile: (0%,0%); rtol=6.18e-06\", #> \"PRED absolute difference compared to Nonmem PRED: 95% percentile: (3.79e-07,0.00313) atol=6.18e-06\") #> ini({ #> tktr <- 6.24053043162953e-07 #> label(\"1 - tktr\") #> tka <- -3.00642760553675e-06 #> label(\"2 - tka\") #> tcl <- -2.00405074386117 #> label(\"3 - tcl\") #> tv <- 2.05188410700476 #> label(\"4 - tv\") #> prop.err <- c(0, 0.0985804613565218) #> label(\"5 - prop.err\") #> pkadd.err <- c(0, 0.511625249037084) #> label(\"6 - pkadd.err\") #> temax <- 6.4184983102259 #> label(\"7 - temax\") #> tec50 <- 0.140763261319656 #> label(\"8 - tec50\") #> tkout <- -2.9534704318737 #> label(\"9 - tkout\") #> te0 <- 4.57045413136592 #> label(\"10 - te0\") #> pdadd.err <- c(0, 3.71714384851537) #> label(\"11 - pdadd.err\") #> eta.ktr ~ 0.558129815059436 #> eta.ka ~ 0.558402321309217 #> eta.cl ~ 0.0785849119252598 #> eta.v ~ 0.0508226905750953 #> eta.emax ~ 5e-05 #> eta.ec50 ~ 0.18426809257979 #> eta.kout ~ 0.0083631531443303 #> eta.e0 ~ 0.00274561514766752 #> }) #> model({ #> cmt(DEPOT) #> cmt(GUT) #> cmt(CENTER) #> cmt(EFFECT) #> ktr <- exp(tktr + eta.ktr) #> ka <- exp(tka + eta.ka) #> cl <- exp(tcl + eta.cl) #> v <- exp(tv + eta.v) #> emax <- expit(temax + eta.emax) #> ec50 <- exp(tec50 + eta.ec50) #> kout <- exp(tkout + eta.kout) #> e0 <- exp(te0 + eta.e0) #> EFFECT(0) <- e0 #> dcp <- CENTER/v #> pd <- 1 - emax * dcp/(ec50 + dcp) #> kin <- e0 * kout #> d/dt(DEPOT) <- -ktr * DEPOT #> d/dt(GUT) <- ktr * DEPOT - ka * GUT #> d/dt(CENTER) <- ka * GUT - cl/v * CENTER #> d/dt(EFFECT) <- kin * pd - kout * EFFECT #> eff <- EFFECT #> dcp ~ add(pkadd.err) + prop(prop.err) #> eff ~ add(pdadd.err) #> }) #> } #> ── nonmem2rx extra properties: ── #> other properties include: $nonmemData, $etaData, $thetaMat #> captured NONMEM table outputs: $predData, $ipredData #> NONMEM/rxode2 comparison data: $iwresCompare, $predCompare, $ipredCompare #> NONMEM/rxode2 composite comparison: $predAtol, $predRtol, $ipredAtol, $ipredRtol, $iwresAtol, $iwresRtol"},{"path":"/articles/read-rounding.html","id":"step-3-convert-new-model-to-nlmixr2-fit-with-as-nlmixr2","dir":"Articles","previous_headings":"","what":"Step 3: Convert new model to nlmixr2 fit with as.nlmixr2()","title":"Reading rounding from NONMEM","text":"translation complete, validated, can convert fit full nlmixr2 fit object. Note object rerun estimation, rather imports everything knows fit rerun nlmixr2 table steps calculate things need.","code":"fit <- as.nlmixr2(new) #> → loading into symengine environment... #> → pruning branches (`if`/`else`) of full model... #> ✔ done #> → finding duplicate expressions in EBE model... #> [====|====|====|====|====|====|====|====|====|====] 0:00:00 #> → optimizing duplicate expressions in EBE model... #> [====|====|====|====|====|====|====|====|====|====] 0:00:00 #> → compiling EBE model... #> using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’ #> ✔ done #> rxode2 3.0.0 using 2 threads (see ?getRxThreads) #> no cache: create with `rxCreateCache()` #> → Calculating residuals/tables #> ✔ done #> → compress origData in nlmixr2 object, save 21592 #> → compress parHistData in nlmixr2 object, save 5536 # Once it is loaded remove the directory (we don't need the files any # more for this example) # # In this example, we don't remove, but note where it can be removed # # unlink(\"pk.turnover.emax3-nonmem\", recursive = TRUE)"},{"path":"/articles/read-rounding.html","id":"step-4-explore-the-datafit-as-if-it-came-from-nlmixr2","dir":"Articles","previous_headings":"","what":"Step 4: Explore the data/fit as if it came from nlmixr2","title":"Reading rounding from NONMEM","text":"information can see properties model: model can see: High shrinkage temax, ktr, ka moderate shrinkage kout removing parameters, possibly get successful NONMEM run. want, can use model piping remove parameters follows: Since babelmixr2 use babelmixr2 run model NONMEM (setup run NONMEM), even run model nlmixr2 . example choose use nlmixr2 (since babelmixr2 example runs NONMEM shows reduction shrinkage) modifications shrinkage also reduced (just like NONMEM case)","code":"print(fit) #> ── nlmixr² nonmem2rx reading NONMEM ver 7.4.3 ── #> #> OBJF AIC BIC Log-likelihood #> nonmem2rx 439.2156 1364.91 1444.331 -663.4551 #> #> ── Time (sec $time): ── #> #> setup table compress NONMEM as.nlmixr2 #> elapsed 0.033591 0.078 0.01 320.27 3.673 #> #> ── Population Parameters ($parFixed or $parFixedDf): ── #> #> Parameter Est. Back-transformed BSV(CV% or SD) Shrink(SD)% #> tktr 1 - tktr 6.24e-07 1 86.5 59.8% #> tka 2 - tka -3.01e-06 1 86.5 59.8% #> tcl 3 - tcl -2 0.135 28.6 1.34% #> tv 4 - tv 2.05 7.78 22.8 6.44% #> prop.err 5 - prop.err 0.0986 0.0986 #> pkadd.err 6 - pkadd.err 0.512 0.512 #> temax 7 - temax 6.42 0.998 0.00707 100.% #> tec50 8 - tec50 0.141 1.15 45.0 6.06% #> tkout 9 - tkout -2.95 0.0522 9.16 32.4% #> te0 10 - te0 4.57 96.6 5.24 18.1% #> pdadd.err 11 - pdadd.err 3.72 3.72 #> #> No correlations in between subject variability (BSV) matrix #> Full BSV covariance ($omega) or correlation ($omegaR; diagonals=SDs) #> Distribution stats (mean/skewness/kurtosis/p-value) available in $shrink #> Censoring ($censInformation): No censoring #> Minimization message ($message): #> #> #> WARNINGS AND ERRORS (IF ANY) FOR PROBLEM 1 #> #> (WARNING 2) NM-TRAN INFERS THAT THE DATA ARE POPULATION. #> #> #> 0MINIMIZATION TERMINATED #> DUE TO ROUNDING ERRORS (ERROR=134) #> NO. OF FUNCTION EVALUATIONS USED: 1088 #> NO. OF SIG. DIGITS UNREPORTABLE #> 0PARAMETER ESTIMATE IS NEAR ITS BOUNDARY #> #> IPRED relative difference compared to Nonmem IPRED: 0%; 95% percentile: (0%,0%); rtol=5.09e-06 #> PRED relative difference compared to Nonmem PRED: 0%; 95% percentile: (0%,0%); rtol=5.29e-06 #> IPRED absolute difference compared to Nonmem IPRED: 95% percentile: (2.2e-06, 0.000454); atol=3.03e-05 #> PRED absolute difference compared to Nonmem PRED: 95% percentile: (4.72e-07,0.00361); atol=5.29e-06 #> there are solving errors during optimization (see '$prderr') #> nonmem2rx model file: 'pk.turnover.emax3-nonmem/pk.turnover.emax3.nmctl' #> #> ── Fit Data (object is a modified tibble): ── #> # A tibble: 483 × 35 #> ID TIME CMT DV PRED RES IPRED IRES IWRES eta.ktr eta.ka eta.cl #> #> 1 1 0.5 dcp 0 1.16 -1.16 0.444 -0.444 -0.864 -0.506 -0.506 0.699 #> 2 1 1 dcp 1.9 3.37 -1.47 1.45 0.446 0.840 -0.506 -0.506 0.699 #> 3 1 2 dcp 3.3 7.51 -4.21 3.96 -0.660 -1.03 -0.506 -0.506 0.699 #> # ℹ 480 more rows #> # ℹ 23 more variables: eta.v , eta.emax , eta.ec50 , #> # eta.kout , eta.e0 , dcp , eff , DEPOT , GUT , #> # CENTER , EFFECT , ktr , ka , cl , v , #> # emax , ec50 , kout , e0 , pd , kin , #> # tad , dosenum mod3 <- fit %>% model(ktr <- exp(tktr)) %>% model(ka <- exp(tka)) %>% model(emax <- expit(temax)) %>% model(kout <- exp(tkout)) #> ! remove between subject variability `eta.ktr` #> ! remove between subject variability `eta.ka` #> ! remove between subject variability `eta.emax` #> ! remove between subject variability `eta.kout` mod3 #> ── rxode2-based free-form 4-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tktr tka tcl tv prop.err #> 6.240530e-07 -3.006428e-06 -2.004051e+00 2.051884e+00 9.858046e-02 #> pkadd.err temax tec50 tkout te0 #> 5.116252e-01 6.418498e+00 1.407633e-01 -2.953470e+00 4.570454e+00 #> pdadd.err #> 3.717144e+00 #> #> Omega ($omega): #> eta.cl eta.v eta.ec50 eta.e0 #> eta.cl 0.07858491 0.00000000 0.0000000 0.000000000 #> eta.v 0.00000000 0.05082269 0.0000000 0.000000000 #> eta.ec50 0.00000000 0.00000000 0.1842681 0.000000000 #> eta.e0 0.00000000 0.00000000 0.0000000 0.002745615 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 DEPOT #> 2 2 GUT #> 3 3 CENTER #> 4 4 EFFECT #> ── Multiple Endpoint Model ($multipleEndpoint): ── #> variable cmt dvid* #> 1 dcp ~ … cmt='dcp' or cmt=5 dvid='dcp' or dvid=1 #> 2 eff ~ … cmt='eff' or cmt=6 dvid='eff' or dvid=2 #> * If dvids are outside this range, all dvids are re-numered sequentially, ie 1,7, 10 becomes 1,2,3 etc #> #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 tcl eta.cl id #> 2 tv eta.v id #> 3 tec50 eta.ec50 id #> 4 te0 eta.e0 id #> #> ── Model (Normalized Syntax): ── #> function() { #> description <- c(\"translated from babelmixr2\", \"; comments show mu referenced model in ui$getSplitMuModel\") #> dfObs <- 483 #> dfSub <- 32 #> validation <- c(\"IPRED relative difference compared to Nonmem IPRED: 0%; 95% percentile: (0%,0%); rtol=6.13e-06\", #> \"IPRED absolute difference compared to Nonmem IPRED: 95% percentile: (3.12e-06, 0.000497); atol=6.17e-05\", #> \"PRED relative difference compared to Nonmem PRED: 0%; 95% percentile: (0%,0%); rtol=6.18e-06\", #> \"PRED absolute difference compared to Nonmem PRED: 95% percentile: (3.79e-07,0.00313) atol=6.18e-06\") #> ini({ #> tktr <- 6.24053043162953e-07 #> label(\"1 - tktr\") #> tka <- -3.00642760553675e-06 #> label(\"2 - tka\") #> tcl <- -2.00405074386117 #> label(\"3 - tcl\") #> tv <- 2.05188410700476 #> label(\"4 - tv\") #> prop.err <- c(0, 0.0985804613565218) #> label(\"5 - prop.err\") #> pkadd.err <- c(0, 0.511625249037084) #> label(\"6 - pkadd.err\") #> temax <- 6.4184983102259 #> label(\"7 - temax\") #> tec50 <- 0.140763261319656 #> label(\"8 - tec50\") #> tkout <- -2.9534704318737 #> label(\"9 - tkout\") #> te0 <- 4.57045413136592 #> label(\"10 - te0\") #> pdadd.err <- c(0, 3.71714384851537) #> label(\"11 - pdadd.err\") #> eta.cl ~ 0.0785849119252598 #> eta.v ~ 0.0508226905750953 #> eta.ec50 ~ 0.18426809257979 #> eta.e0 ~ 0.00274561514766752 #> }) #> model({ #> cmt(DEPOT) #> cmt(GUT) #> cmt(CENTER) #> cmt(EFFECT) #> ktr <- exp(tktr) #> ka <- exp(tka) #> cl <- exp(tcl + eta.cl) #> v <- exp(tv + eta.v) #> emax <- expit(temax) #> ec50 <- exp(tec50 + eta.ec50) #> kout <- exp(tkout) #> e0 <- exp(te0 + eta.e0) #> EFFECT(0) <- e0 #> dcp <- CENTER/v #> pd <- 1 - emax * dcp/(ec50 + dcp) #> kin <- e0 * kout #> d/dt(DEPOT) <- -ktr * DEPOT #> d/dt(GUT) <- ktr * DEPOT - ka * GUT #> d/dt(CENTER) <- ka * GUT - cl/v * CENTER #> d/dt(EFFECT) <- kin * pd - kout * EFFECT #> eff <- EFFECT #> dcp ~ add(pkadd.err) + prop(prop.err) #> eff ~ add(pdadd.err) #> }) #> } fit2 <- nlmixr(mod3, new$nonmemData, \"focei\", foceiControl(print=0)) #> → loading into symengine environment... #> → pruning branches (`if`/`else`) of full model... #> ✔ done #> → calculate jacobian #> [====|====|====|====|====|====|====|====|====|====] 0:00:00 #> → calculate sensitivities #> [====|====|====|====|====|====|====|====|====|====] 0:00:00 #> → calculate ∂(f)/∂(η) #> [====|====|====|====|====|====|====|====|====|====] 0:00:00 #> → calculate ∂(R²)/∂(η) #> [====|====|====|====|====|====|====|====|====|====] 0:00:00 #> → finding duplicate expressions in inner model... #> [====|====|====|====|====|====|====|====|====|====] 0:00:00 #> → optimizing duplicate expressions in inner model... #> [====|====|====|====|====|====|====|====|====|====] 0:00:00 #> → finding duplicate expressions in EBE model... #> [====|====|====|====|====|====|====|====|====|====] 0:00:00 #> → optimizing duplicate expressions in EBE model... #> [====|====|====|====|====|====|====|====|====|====] 0:00:00 #> → compiling inner model... #> using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’ #> ✔ done #> → finding duplicate expressions in FD model... #> [====|====|====|====|====|====|====|====|====|====] 0:00:00 #> → optimizing duplicate expressions in FD model... #> [====|====|====|====|====|====|====|====|====|====] 0:00:00 #> → compiling EBE model... #> using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’ #> ✔ done #> → compiling events FD model... #> using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’ #> ✔ done #> calculating covariance matrix #> [====|====|====|====|====|====|====|====|====|====] 0:00:35 #> done #> → Calculating residuals/tables #> ✔ done #> → compress origData in nlmixr2 object, save 21592 #> → compress parHistData in nlmixr2 object, save 14920 fit2 #> ── nlmixr² FOCEi (outer: nlminb) ── #> #> OBJF AIC BIC Log-likelihood Condition#(Cov) Condition#(Cor) #> FOCEi 1425.005 2342.699 2405.399 -1156.35 896101.4 262.0511 #> #> ── Time (sec fit2$time): ── #> #> setup optimize covariance table compress other #> elapsed 0.003448 35.97675 35.97676 0.113 0.014 91.73504 #> #> ── Population Parameters (fit2$parFixed or fit2$parFixedDf): ── #> #> Parameter Est. SE %RSE Back-transformed(95%CI) BSV(CV%) #> tktr 1 - tktr 0.0978 0.147 150 1.1 (0.827, 1.47) #> tka 2 - tka 0.0229 0.0978 427 1.02 (0.845, 1.24) #> tcl 3 - tcl -2.01 0.05 2.49 0.134 (0.122, 0.148) 27.8 #> tv 4 - tv 2.05 0.0425 2.07 7.79 (7.17, 8.47) 22.7 #> prop.err 5 - prop.err 0.144 0.144 #> pkadd.err 6 - pkadd.err 0.616 0.616 #> temax 7 - temax 188 5.75 3.06 1 (1, 1) #> tec50 8 - tec50 0.143 0.0875 61.1 1.15 (0.972, 1.37) 43.0 #> tkout 9 - tkout -2.96 0.028 0.945 0.0516 (0.0488, 0.0545) #> te0 10 - te0 4.57 0.0105 0.23 96.8 (94.8, 98.8) 5.24 #> pdadd.err 11 - pdadd.err 3.86 3.86 #> Shrink(SD)% #> tktr #> tka #> tcl 1.95% #> tv 6.61% #> prop.err #> pkadd.err #> temax #> tec50 7.90% #> tkout #> te0 19.4% #> pdadd.err #> #> Covariance Type (fit2$covMethod): |r|,|s| #> No correlations in between subject variability (BSV) matrix #> Full BSV covariance (fit2$omega) or correlation (fit2$omegaR; diagonals=SDs) #> Distribution stats (mean/skewness/kurtosis/p-value) available in fit2$shrink #> Information about run found (fit2$runInfo): #> • gradient problems with initial estimate and covariance; see $scaleInfo #> • since sandwich matrix is corrected, you may compare to $covR or $covS if you wish #> • S matrix non-positive definite but corrected by S = sqrtm(S%*%S) #> • R matrix non-positive definite but corrected by R = sqrtm(R%*%R) #> • last objective function was not at minimum, possible problems in optimization #> • ETAs were reset to zero during optimization; (Can control by foceiControl(resetEtaP=.)) #> • initial ETAs were nudged; (can control by foceiControl(etaNudge=., etaNudge2=)) #> Censoring (fit2$censInformation): No censoring #> Minimization message (fit2$message): #> false convergence (8) #> In an ODE system, false convergence may mean \"useless\" evaluations were performed. #> See https://tinyurl.com/yyrrwkce #> It could also mean the convergence is poor, check results before accepting fit #> You may also try a good derivative free optimization: #> nlmixr2(...,control=list(outerOpt=\"bobyqa\")) #> #> ── Fit Data (object fit2 is a modified tibble): ── #> # A tibble: 483 × 33 #> ID TIME CMT DV PRED RES WRES IPRED IRES IWRES CPRED CRES CWRES #> #> 1 1 0.5 dcp 0 1.28 -1.28 -1.82 1.01 -1.01 -1.60 1.25 -1.25 -1.86 #> 2 1 1 dcp 1.9 3.66 -1.76 -1.53 2.89 -0.991 -1.33 3.58 -1.68 -1.71 #> 3 1 2 dcp 3.3 7.91 -4.61 -2.12 6.22 -2.92 -2.68 7.73 -4.43 -2.55 #> # ℹ 480 more rows #> # ℹ 20 more variables: eta.cl , eta.v , eta.ec50 , eta.e0 , #> # DEPOT , GUT , CENTER , EFFECT , ktr , ka , #> # cl , v , emax , ec50 , kout , e0 , pd , #> # kin , tad , dosenum "},{"path":"/articles/read-rounding.html","id":"step-5-get-the-covariance-of-the-model","dir":"Articles","previous_headings":"","what":"Step 5: Get the covariance of the model","title":"Reading rounding from NONMEM","text":"Another thing can helpful fit imported nlmixr2 fit get variance/covariance matrix. can especially helpful diagnose things help simplify model Note covariance step 100% successful since r, s. However, can give insights parameters estimated well. case can see emax parameter poorly estimated parameters, means fixing parameter reducing parameters may help estimate progress NONMEM.","code":"getVarCov(fit) #> → loading into symengine environment... #> → pruning branches (`if`/`else`) of full model... #> ✔ done #> → calculate jacobian #> [====|====|====|====|====|====|====|====|====|====] 0:00:00 #> → calculate sensitivities #> [====|====|====|====|====|====|====|====|====|====] 0:00:00 #> → calculate ∂(f)/∂(η) #> [====|====|====|====|====|====|====|====|====|====] 0:00:00 #> → finding duplicate expressions in inner model... #> [====|====|====|====|====|====|====|====|====|====] 0:00:00 #> → optimizing duplicate expressions in inner model... #> [====|====|====|====|====|====|====|====|====|====] 0:00:00 #> → finding duplicate expressions in EBE model... #> [====|====|====|====|====|====|====|====|====|====] 0:00:00 #> → optimizing duplicate expressions in EBE model... #> [====|====|====|====|====|====|====|====|====|====] 0:00:00 #> → compiling inner model... #> using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’ #> ✔ done #> → finding duplicate expressions in FD model... #> [====|====|====|====|====|====|====|====|====|====] 0:00:00 #> → optimizing duplicate expressions in FD model... #> [====|====|====|====|====|====|====|====|====|====] 0:00:00 #> → compiling EBE model... #> using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’ #> ✔ done #> → compiling events FD model... #> using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’ #> ✔ done #> calculating covariance matrix #> [====|====|====|====|====|====|====|====|====|====] 0:00:05 #> Warning in foceiFitCpp_(.ret): using R matrix to calculate covariance, can #> check sandwich or S matrix with $covRS and $covS #> Warning in foceiFitCpp_(.ret): gradient problems with covariance; see #> $scaleInfo #> → compress origData in nlmixr2 object, save 21592 #> Updated original fit object fit #> tktr tka tcl tv temax #> tktr 1.830060e-02 -1.523057e-02 -2.404755e-05 3.183949e-04 0.0011992673 #> tka -1.523057e-02 1.828061e-02 -2.125855e-05 3.195745e-04 0.0014273042 #> tcl -2.404755e-05 -2.125855e-05 2.479870e-04 1.184906e-05 -0.0008486078 #> tv 3.183949e-04 3.195745e-04 1.184906e-05 3.183331e-04 0.0011376028 #> temax 1.199267e-03 1.427304e-03 -8.486078e-04 1.137603e-03 7.5951592101 #> tec50 1.333848e-04 1.362464e-04 -3.585788e-04 1.232516e-04 0.0485635015 #> tkout 9.641362e-05 1.069037e-04 -9.755546e-05 1.189674e-04 -0.0189321828 #> te0 1.365383e-05 1.343098e-05 -9.855499e-06 1.252947e-05 -0.0004450840 #> tec50 tkout te0 #> tktr 0.0001333848 9.641362e-05 1.365383e-05 #> tka 0.0001362464 1.069037e-04 1.343098e-05 #> tcl -0.0003585788 -9.755546e-05 -9.855499e-06 #> tv 0.0001232516 1.189674e-04 1.252947e-05 #> temax 0.0485635015 -1.893218e-02 -4.450840e-04 #> tec50 0.0018384895 1.539214e-04 -1.360918e-04 #> tkout 0.0001539214 6.316775e-04 5.255583e-05 #> te0 -0.0001360918 5.255583e-05 8.870276e-05 fit #> ── nlmixr² nonmem2rx reading NONMEM ver 7.4.3 ── #> #> OBJF AIC BIC Log-likelihood #> nonmem2rx 439.2156 1364.91 1444.331 -663.4551 #> #> ── Time (sec fit$time): ── #> #> setup table compress NONMEM as.nlmixr2 covariance #> elapsed 0.033591 0.078 0.01 320.27 3.673 13.826 #> #> ── Population Parameters (fit$parFixed or fit$parFixedDf): ── #> #> Parameter Est. SE %RSE Back-transformed(95%CI) #> tktr 1 - tktr 6.24e-07 0.135 2.17e+07 1 (0.767, 1.3) #> tka 2 - tka -3.01e-06 0.135 4.5e+06 1 (0.767, 1.3) #> tcl 3 - tcl -2 0.0157 0.786 0.135 (0.131, 0.139) #> tv 4 - tv 2.05 0.0178 0.87 7.78 (7.52, 8.06) #> prop.err 5 - prop.err 0.0986 0.0986 #> pkadd.err 6 - pkadd.err 0.512 0.512 #> temax 7 - temax 6.42 2.76 42.9 0.998 (0.734, 1) #> tec50 8 - tec50 0.141 0.0429 30.5 1.15 (1.06, 1.25) #> tkout 9 - tkout -2.95 0.0251 0.851 0.0522 (0.0497, 0.0548) #> te0 10 - te0 4.57 0.00942 0.206 96.6 (94.8, 98.4) #> pdadd.err 11 - pdadd.err 3.72 3.72 #> BSV(CV% or SD) Shrink(SD)% #> tktr 86.5 59.8% #> tka 86.5 59.8% #> tcl 28.6 1.34% #> tv 22.8 6.44% #> prop.err #> pkadd.err #> temax 0.00707 100.% #> tec50 45.0 6.06% #> tkout 9.16 32.4% #> te0 5.24 18.1% #> pdadd.err #> #> Covariance Type (fit$covMethod): r #> No correlations in between subject variability (BSV) matrix #> Full BSV covariance (fit$omega) or correlation (fit$omegaR; diagonals=SDs) #> Distribution stats (mean/skewness/kurtosis/p-value) available in fit$shrink #> Censoring (fit$censInformation): No censoring #> Minimization message (fit$message): #> #> #> WARNINGS AND ERRORS (IF ANY) FOR PROBLEM 1 #> #> (WARNING 2) NM-TRAN INFERS THAT THE DATA ARE POPULATION. #> #> #> 0MINIMIZATION TERMINATED #> DUE TO ROUNDING ERRORS (ERROR=134) #> NO. OF FUNCTION EVALUATIONS USED: 1088 #> NO. OF SIG. DIGITS UNREPORTABLE #> 0PARAMETER ESTIMATE IS NEAR ITS BOUNDARY #> #> IPRED relative difference compared to Nonmem IPRED: 0%; 95% percentile: (0%,0%); rtol=5.09e-06 #> PRED relative difference compared to Nonmem PRED: 0%; 95% percentile: (0%,0%); rtol=5.29e-06 #> IPRED absolute difference compared to Nonmem IPRED: 95% percentile: (2.2e-06, 0.000454); atol=3.03e-05 #> PRED absolute difference compared to Nonmem PRED: 95% percentile: (4.72e-07,0.00361); atol=5.29e-06 #> there are solving errors during optimization (see '$prderr') #> nonmem2rx model file: 'pk.turnover.emax3-nonmem/pk.turnover.emax3.nmctl' #> #> ── Fit Data (object fit is a modified tibble): ── #> # A tibble: 483 × 35 #> ID TIME CMT DV PRED RES IPRED IRES IWRES eta.ktr eta.ka eta.cl #> #> 1 1 0.5 dcp 0 1.16 -1.16 0.444 -0.444 -0.864 -0.506 -0.506 0.699 #> 2 1 1 dcp 1.9 3.37 -1.47 1.45 0.446 0.840 -0.506 -0.506 0.699 #> 3 1 2 dcp 3.3 7.51 -4.21 3.96 -0.660 -1.03 -0.506 -0.506 0.699 #> # ℹ 480 more rows #> # ℹ 23 more variables: eta.v , eta.emax , eta.ec50 , #> # eta.kout , eta.e0 , dcp , eff , DEPOT , GUT , #> # CENTER , EFFECT , ktr , ka , cl , v , #> # emax , ec50 , kout , e0 , pd , kin , #> # tad , dosenum "},{"path":"/articles/rxode2-validate.html","id":"comparing-differences-between-nonmem-and-rxode2","dir":"Articles","previous_headings":"","what":"Comparing differences between NONMEM and rxode2","title":"Qualify rxode2 model against NONMEM","text":"may wish see differences predictions NONMEM rxode2. rxode2 generated outputs compared NONMEM generated outputs following items: Population Predictions: shows model translation adequate simulate general trends; validate structural model’s population parameters coupled model structure. Individual Predictions: shows model translation able replicate values subjects within modeling data-set. validates model can reproduce subject variability observed study. Individual Weighted Residuals: one step individual parameter validation, couples individual predictions, observations residual specification generate individual weighted residuals. Since can modify residual specification create nlmixr2-compatible model, step important make sure residual specification . Note: part validated three metrics subject covariance matrix, omega. assume correct long read correctly.","code":""},{"path":"/articles/rxode2-validate.html","id":"comparing-numerically","dir":"Articles","previous_headings":"","what":"Comparing numerically","title":"Qualify rxode2 model against NONMEM","text":"want numerical differences, can also get modified returned ui object. rtol, atol follows : can see exactly match close (say validate). However can explore difference wish looking ipredCompare predCompare datasets: cases can see NONMEM seems round values output (rounding rules based FORMAT option), rxode2 seems keep entire number. Note observation data compared. Dosing predictions excluded comparisons. can also explore NONMEM input dataset used make validation predictions (dosing observations) $nonmemData item:","code":"mod$iwresAtol #> 50% #> 3.64871e-06 mod$iwresRtol #> 50% #> 8.987887e-06 mod$ipredAtol #> 50% #> 0.00166826 mod$ipredRtol #> 50% #> 6.430677e-06 mod$predAtol #> 50% #> 6.406839e-06 mod$predAtol #> 50% #> 6.406839e-06 head(mod$iwresCompare) #> ID TIME nonmemIWRES IWRES #> 1 1 0.25 -0.73154 -0.7315464 #> 2 1 0.50 1.86670 1.8666563 #> 3 1 0.75 -1.26860 -1.2685789 #> 4 1 1.00 0.44442 0.4444172 #> 5 1 1.50 0.55470 0.5546978 #> 6 1 2.00 0.35351 0.3535035 head(mod$ipredCompare) #> ID TIME nonmemIPRED IPRED #> 1 1 0.25 1215.4 1215.358 #> 2 1 0.50 1191.9 1191.924 #> 3 1 0.75 1169.2 1169.164 #> 4 1 1.00 1147.1 1147.057 #> 5 1 1.50 1104.7 1104.721 #> 6 1 2.00 1064.8 1064.759 head(mod$predCompare) #> ID TIME nonmemPRED PRED #> 1 1 0.25 1750.3 1750.290 #> 2 1 0.50 1699.8 1699.834 #> 3 1 0.75 1651.3 1651.349 #> 4 1 1.00 1604.8 1604.752 #> 5 1 1.50 1516.9 1516.913 #> 6 1 2.00 1435.7 1435.723 head(mod$nonmemData) # with nlme loaded you can also use getData(mod) #> ID TIME DV LNDV MDV AMT EVID DOSE V1I CLI QI V2I SSX IIX SD #> 1 1 0.00 0.0 0.0000 1 120000 1 120000 101.5 3.57 6.99 59.19 99 0 1 #> 2 1 0.25 1040.7 6.9476 0 0 0 120000 101.5 3.57 6.99 59.19 99 0 1 #> 3 1 0.50 1629.0 7.3957 0 0 0 120000 101.5 3.57 6.99 59.19 99 0 1 #> 4 1 0.75 877.8 6.7774 0 0 0 120000 101.5 3.57 6.99 59.19 99 0 1 #> 5 1 1.00 1247.2 7.1286 0 0 0 120000 101.5 3.57 6.99 59.19 99 0 1 #> 6 1 1.50 1225.1 7.1107 0 0 0 120000 101.5 3.57 6.99 59.19 99 0 1 #> CMT #> 1 1 #> 2 1 #> 3 1 #> 4 1 #> 5 1 #> 6 1"},{"path":"/articles/rxode2-validate.html","id":"comparing-visually","dir":"Articles","previous_headings":"","what":"Comparing visually","title":"Qualify rxode2 model against NONMEM","text":"easiest way visually compare differences plot method:","code":"plot(mod) # for general plot # you can also see individual comparisons plot(mod, log=\"y\", ncol=2, nrow=2, xlab=\"Time (hr)\", ylab=\"Concentrations\", page=1) # If you want all pages you could use: # plot(mod, log=\"y\", ncol=2, nrow=2, xlab=\"Time (hr)\", ylab=\"Concentrations\", page=TRUE)"},{"path":"/articles/rxode2-validate.html","id":"notes-on-validation","dir":"Articles","previous_headings":"","what":"Notes on validation","title":"Qualify rxode2 model against NONMEM","text":"validation model uses best data available NONMEM estimates. : theta population parameters eta individual parameters omega sigma matrices captured. nlmixr2 model fully qualified, IWRES validation ensures residual errors specified correctly. Otherwise omega sigma values contribute validation. Also overall covariance captured, used validation.","code":""},{"path":"/articles/simulate-extra-items.html","id":"step-1-import-the-model","dir":"Articles","previous_headings":"","what":"Step 1: Import the model","title":"Simulate Derived Variables from imported NONMEM model","text":"","code":"library(nonmem2rx) library(rxode2) # First we need the location of the nonmem control stream Since we are running an example, we will use one of the built-in examples in `nonmem2rx` ctlFile <- system.file(\"mods/cpt/runODE032.ctl\", package=\"nonmem2rx\") # You can use a control stream or other file. With the development # version of `babelmixr2`, you can simply point to the listing file mod <- nonmem2rx(ctlFile, lst=\".res\", save=FALSE, determineError=FALSE) #> ℹ getting information from '/home/runner/work/_temp/Library/nonmem2rx/mods/cpt/runODE032.ctl' #> ℹ reading in xml file #> ℹ done #> ℹ reading in ext file #> ℹ done #> ℹ reading in phi file #> ℹ done #> ℹ reading in lst file #> ℹ abbreviated list parsing #> ℹ done #> ℹ done #> ℹ splitting control stream by records #> ℹ done #> ℹ Processing record $INPUT #> ℹ Processing record $MODEL #> ℹ Processing record $gTHETA #> ℹ Processing record $OMEGA #> ℹ Processing record $SIGMA #> ℹ Processing record $PROBLEM #> ℹ Processing record $DATA #> ℹ Processing record $SUBROUTINES #> ℹ Processing record $PK #> ℹ Processing record $DES #> ℹ Processing record $ERROR #> ℹ Processing record $ESTIMATION #> ℹ Ignore record $ESTIMATION #> ℹ Processing record $COVARIANCE #> ℹ Ignore record $COVARIANCE #> ℹ Processing record $TABLE #> ℹ change initial estimate of `theta1` to `1.37034036528946` #> ℹ change initial estimate of `theta2` to `4.19814911033061` #> ℹ change initial estimate of `theta3` to `1.38003493562413` #> ℹ change initial estimate of `theta4` to `3.87657341967489` #> ℹ change initial estimate of `theta5` to `0.196446108190896` #> ℹ change initial estimate of `eta1` to `0.101251418415006` #> ℹ change initial estimate of `eta2` to `0.0993872449483344` #> ℹ change initial estimate of `eta3` to `0.101302674763154` #> ℹ change initial estimate of `eta4` to `0.0730497519364148` #> ℹ read in nonmem input data (for model validation): /home/runner/work/_temp/Library/nonmem2rx/mods/cpt/Bolus_2CPT.csv #> ℹ ignoring lines that begin with a letter (IGNORE=@)' #> ℹ applying names specified by $INPUT #> ℹ subsetting accept/ignore filters code: .data[-which((.data$SD == 0)),] #> ℹ done #> ℹ read in nonmem IPRED data (for model validation): /home/runner/work/_temp/Library/nonmem2rx/mods/cpt/runODE032.csv #> ℹ done #> ℹ changing most variables to lower case #> ℹ done #> ℹ replace theta names #> ℹ done #> ℹ replace eta names #> ℹ done (no labels) #> ℹ renaming compartments #> ℹ done #> ℹ solving ipred problem #> ℹ done #> ℹ solving pred problem #> ℹ done"},{"path":"/articles/simulate-extra-items.html","id":"step-2-add-auc-calculation","dir":"Articles","previous_headings":"","what":"Step 2: Add AUC calculation","title":"Simulate Derived Variables from imported NONMEM model","text":"concentration case f model, trick get AUC additional ODE d/dt(AUC) <- f use reset get per dosing period. However, additional parameter part original model. calculation AUC depend number observations model, sparse data wouldn’t terribly accurate. One thing can use model piping append d/dt(AUC) <- f imported model: can also use append=NA pre-pend append=f put ODE right f line model.","code":"modAuc <- mod %>% model(d/dt(AUC) <- f, append=TRUE) #> → significant model change detected #> → kept in model: '$atol', '$nonmemData', '$rtol', '$ssAtol', '$ssRtol' #> → removed from model: '$digest', '$etaData', '$file', '$ipredAtol', '$ipredCompare', '$ipredData', '$ipredRtol', '$iwresAtol', '$iwresCompare', '$iwresRtol', '$notes', '$outputExtension', '$predAtol', '$predCompare', '$predData', '$predRtol', '$sigmaNames' modAuc #> ── rxode2-based free-form 3-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> theta1 theta2 theta3 theta4 RSV #> 1.3703404 4.1981491 1.3800349 3.8765734 0.1964461 #> #> Omega ($omega): #> eta1 eta2 eta3 eta4 #> eta1 0.1012514 0.00000000 0.0000000 0.00000000 #> eta2 0.0000000 0.09938724 0.0000000 0.00000000 #> eta3 0.0000000 0.00000000 0.1013027 0.00000000 #> eta4 0.0000000 0.00000000 0.0000000 0.07304975 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 CENTRAL #> 2 2 PERI #> 3 3 AUC #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 theta1 eta1 id #> 2 theta2 eta2 id #> 3 theta3 eta3 id #> 4 theta4 eta4 id #> #> ── Model (Normalized Syntax): ── #> function() { #> description <- \"BOLUS_2CPT_CLV1QV2 SINGLE DOSE FOCEI (120 Ind/2280 Obs) runODE032\" #> dfObs <- 2280 #> dfSub <- 120 #> sigma <- lotri({ #> eps1 ~ 1 #> }) #> thetaMat <- lotri({ #> theta1 ~ c(theta1 = 0.000887681) #> theta2 ~ c(theta1 = -0.00010551, theta2 = 0.000871409) #> theta3 ~ c(theta1 = 0.000184416, theta2 = -0.000106195, #> theta3 = 0.00299336) #> theta4 ~ c(theta1 = -0.000120234, theta2 = -5.06663e-05, #> theta3 = 0.000165252, theta4 = 0.00121347) #> RSV ~ c(theta1 = 5.2783e-08, theta2 = -1.56562e-05, theta3 = 5.99331e-06, #> theta4 = -2.53991e-05, RSV = 9.94218e-06) #> eps1 ~ c(theta1 = 0, theta2 = 0, theta3 = 0, theta4 = 0, #> RSV = 0, eps1 = 0) #> eta1 ~ c(theta1 = -4.71273e-05, theta2 = 4.69667e-05, #> theta3 = -3.64271e-05, theta4 = 2.54796e-05, RSV = -8.16885e-06, #> eps1 = 0, eta1 = 0.000169296) #> omega.2.1 ~ c(theta1 = 0, theta2 = 0, theta3 = 0, theta4 = 0, #> RSV = 0, eps1 = 0, eta1 = 0, omega.2.1 = 0) #> eta2 ~ c(theta1 = -7.37156e-05, theta2 = 2.56634e-05, #> theta3 = -8.08349e-05, theta4 = 1.37e-05, RSV = -4.36564e-06, #> eps1 = 0, eta1 = 8.75181e-06, omega.2.1 = 0, eta2 = 0.00015125) #> omega.3.1 ~ c(theta1 = 0, theta2 = 0, theta3 = 0, theta4 = 0, #> RSV = 0, eps1 = 0, eta1 = 0, omega.2.1 = 0, eta2 = 0, #> omega.3.1 = 0) #> omega.3.2 ~ c(theta1 = 0, theta2 = 0, theta3 = 0, theta4 = 0, #> RSV = 0, eps1 = 0, eta1 = 0, omega.2.1 = 0, eta2 = 0, #> omega.3.1 = 0, omega.3.2 = 0) #> eta3 ~ c(theta1 = 6.63383e-05, theta2 = -8.19002e-05, #> theta3 = 0.000548985, theta4 = 0.000168356, RSV = 1.59122e-06, #> eps1 = 0, eta1 = 3.48714e-05, omega.2.1 = 0, eta2 = 4.31593e-07, #> omega.3.1 = 0, omega.3.2 = 0, eta3 = 0.000959029) #> omega.4.1 ~ c(theta1 = 0, theta2 = 0, theta3 = 0, theta4 = 0, #> RSV = 0, eps1 = 0, eta1 = 0, omega.2.1 = 0, eta2 = 0, #> omega.3.1 = 0, omega.3.2 = 0, eta3 = 0, omega.4.1 = 0) #> omega.4.2 ~ c(theta1 = 0, theta2 = 0, theta3 = 0, theta4 = 0, #> RSV = 0, eps1 = 0, eta1 = 0, omega.2.1 = 0, eta2 = 0, #> omega.3.1 = 0, omega.3.2 = 0, eta3 = 0, omega.4.1 = 0, #> omega.4.2 = 0) #> omega.4.3 ~ c(theta1 = 0, theta2 = 0, theta3 = 0, theta4 = 0, #> RSV = 0, eps1 = 0, eta1 = 0, omega.2.1 = 0, eta2 = 0, #> omega.3.1 = 0, omega.3.2 = 0, eta3 = 0, omega.4.1 = 0, #> omega.4.2 = 0, omega.4.3 = 0) #> eta4 ~ c(theta1 = -9.49661e-06, theta2 = 0.000110108, #> theta3 = -0.000306537, theta4 = -9.12897e-05, RSV = 3.1877e-06, #> eps1 = 0, eta1 = 1.36628e-05, omega.2.1 = 0, eta2 = -1.95096e-05, #> omega.3.1 = 0, omega.3.2 = 0, eta3 = -0.00012977, #> omega.4.1 = 0, omega.4.2 = 0, omega.4.3 = 0, eta4 = 0.00051019) #> }) #> validation <- c(\"IPRED relative difference compared to Nonmem IPRED: 0%; 95% percentile: (0%,0%); rtol=6.43e-06\", #> \"IPRED absolute difference compared to Nonmem IPRED: 95% percentile: (2.19e-05, 0.0418); atol=0.00167\", #> \"IWRES relative difference compared to Nonmem IWRES: 0%; 95% percentile: (0%,0.01%); rtol=8.99e-06\", #> \"IWRES absolute difference compared to Nonmem IWRES: 95% percentile: (1.82e-07, 4.63e-05); atol=3.65e-06\", #> \"PRED relative difference compared to Nonmem PRED: 0%; 95% percentile: (0%,0%); rtol=6.41e-06\", #> \"PRED absolute difference compared to Nonmem PRED: 95% percentile: (1.41e-07,0.00382) atol=6.41e-06\") #> ini({ #> theta1 <- 1.37034036528946 #> label(\"log Cl\") #> theta2 <- 4.19814911033061 #> label(\"log Vc\") #> theta3 <- 1.38003493562413 #> label(\"log Q\") #> theta4 <- 3.87657341967489 #> label(\"log Vp\") #> RSV <- c(0, 0.196446108190896, 1) #> label(\"RSV\") #> eta1 ~ 0.101251418415006 #> eta2 ~ 0.0993872449483344 #> eta3 ~ 0.101302674763154 #> eta4 ~ 0.0730497519364148 #> }) #> model({ #> cmt(CENTRAL) #> cmt(PERI) #> cl <- exp(theta1 + eta1) #> v <- exp(theta2 + eta2) #> q <- exp(theta3 + eta3) #> v2 <- exp(theta4 + eta4) #> v1 <- v #> scale1 <- v #> k21 <- q/v2 #> k12 <- q/v #> d/dt(CENTRAL) <- k21 * PERI - k12 * CENTRAL - cl * CENTRAL/v1 #> d/dt(PERI) <- -k21 * PERI + k12 * CENTRAL #> f <- CENTRAL/scale1 #> ipred <- f #> rescv <- RSV #> w <- ipred * rescv #> ires <- DV - ipred #> iwres <- ires/w #> y <- ipred + w * eps1 #> d/dt(AUC) <- f #> }) #> } #> ── nonmem2rx extra properties: ── #> #> Sigma ($sigma): #> eps1 #> eps1 1 #> #> other properties include: $nonmemData #> captured NONMEM table outputs: #> NONMEM/rxode2 comparison data: $iwresCompare, $predCompare, $ipredCompare #> NONMEM/rxode2 composite comparison: $predAtol, $predRtol, $ipredAtol, $ipredRtol, $iwresAtol, $iwresRtol"},{"path":"/articles/simulate-extra-items.html","id":"step-3-setup-event-table-to-calculate-the-auc-for-a-different-dosing-paradigm","dir":"Articles","previous_headings":"","what":"Step 3: Setup event table to calculate the AUC for a different dosing paradigm:","title":"Simulate Derived Variables from imported NONMEM model","text":"Lets say case instead single dose, want see concentration profile single day BID dosing. case done creating quick event table. case since also wanting AUC per dosing period, can add reset dose AUC compartment every time dose given (track AUC current dose):","code":"ev <- et(amt=120000, ii=12, until=24) %>% et(amt=0, ii=12, until=24, cmt=\"AUC\", evid=5) %>% # replace AUC with zero at dosing et(c(0, 4, 8, 11.999, 12, 12.01, 14, 20, 23.999, 24, 24.001, 28, 32, 36)) %>% et(id=1:10)"},{"path":"/articles/simulate-extra-items.html","id":"step-4-solve-using-rxode2","dir":"Articles","previous_headings":"","what":"Step 4: Solve using rxode2","title":"Simulate Derived Variables from imported NONMEM model","text":"step, solve model new event table 10 subjects: Note since derived nonmem2rx model, default solving match tolerances methods specified NONMEM model.","code":"s <- rxSolve(modAuc, ev) #> ℹ using nocb interpolation like NONMEM, specify directly to change #> ℹ using addlKeepsCov=TRUE like NONMEM, specify directly to change #> ℹ using addlDropSs=TRUE like NONMEM, specify directly to change #> ℹ using ssAtDoseTime=TRUE like NONMEM, specify directly to change #> ℹ using safeZero=FALSE since NONMEM does not use protection by default #> ℹ using safePow=FALSE since NONMEM does not use protection by default #> ℹ using safeLog=FALSE since NONMEM does not use protection by default #> ℹ using ss2cancelAllPending=FALSE since NONMEM does not cancel pending doses with SS=2 #> ℹ using sigma from NONMEM #> ℹ using NONMEM specified atol=1e-12 #> ℹ using NONMEM specified rtol=1e-06 #> ℹ using NONMEM specified ssAtol=1e-12 #> using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’"},{"path":"/articles/simulate-extra-items.html","id":"step-5-exploring-the-simulation-by-plotting-and-summarizing-dplyr","dir":"Articles","previous_headings":"","what":"Step 5: Exploring the simulation (by plotting), and summarizing (dplyr)","title":"Simulate Derived Variables from imported NONMEM model","text":"solved object acts rxode2 solved object, can use plot() function see individual running AUC profiles simulated: can also select points near dosing get AUC interval:","code":"library(ggplot2) plot(s, AUC) + ylab(\"Running AUC\") library(dplyr) #> #> Attaching package: 'dplyr' #> The following objects are masked from 'package:data.table': #> #> between, first, last #> The following objects are masked from 'package:stats': #> #> filter, lag #> The following objects are masked from 'package:base': #> #> intersect, setdiff, setequal, union s %>% filter(time %in% c(11.999, 23.999)) %>% mutate(time=round(time)) %>% select(id, time, AUC) #> id time AUC #> 1 1 12 14933.285 #> 2 1 24 20692.082 #> 3 2 12 11099.596 #> 4 2 24 16694.837 #> 5 3 12 10303.763 #> 6 3 24 14196.023 #> 7 4 12 13015.708 #> 8 4 24 21400.784 #> 9 5 12 11612.369 #> 10 5 24 17944.491 #> 11 6 12 10137.247 #> 12 6 24 15223.973 #> 13 7 12 16532.019 #> 14 7 24 22787.019 #> 15 8 12 10612.266 #> 16 8 24 16781.396 #> 17 9 12 11593.421 #> 18 9 24 17713.529 #> 19 10 12 7972.637 #> 20 10 24 13225.795"},{"path":"/articles/simulate-new-dosing.html","id":"step-1-import-the-model","dir":"Articles","previous_headings":"","what":"Step 1: Import the model","title":"Simulate New dosing from NONMEM model","text":"","code":"library(nonmem2rx) library(rxode2) library(nonmem2rx) # First we need the location of the nonmem control stream Since we are running an example, we will use one of the built-in examples in `nonmem2rx` ctlFile <- system.file(\"mods/cpt/runODE032.ctl\", package=\"nonmem2rx\") # You can use a control stream or other file. With the development # version of `babelmixr2`, you can simply point to the listing file mod <- nonmem2rx(ctlFile, lst=\".res\", save=FALSE, determineError=FALSE) #> ℹ getting information from '/home/runner/work/_temp/Library/nonmem2rx/mods/cpt/runODE032.ctl' #> ℹ reading in xml file #> ℹ done #> ℹ reading in ext file #> ℹ done #> ℹ reading in phi file #> ℹ done #> ℹ reading in lst file #> ℹ abbreviated list parsing #> ℹ done #> ℹ done #> ℹ splitting control stream by records #> ℹ done #> ℹ Processing record $INPUT #> ℹ Processing record $MODEL #> ℹ Processing record $gTHETA #> ℹ Processing record $OMEGA #> ℹ Processing record $SIGMA #> ℹ Processing record $PROBLEM #> ℹ Processing record $DATA #> ℹ Processing record $SUBROUTINES #> ℹ Processing record $PK #> ℹ Processing record $DES #> ℹ Processing record $ERROR #> ℹ Processing record $ESTIMATION #> ℹ Ignore record $ESTIMATION #> ℹ Processing record $COVARIANCE #> ℹ Ignore record $COVARIANCE #> ℹ Processing record $TABLE #> ℹ change initial estimate of `theta1` to `1.37034036528946` #> ℹ change initial estimate of `theta2` to `4.19814911033061` #> ℹ change initial estimate of `theta3` to `1.38003493562413` #> ℹ change initial estimate of `theta4` to `3.87657341967489` #> ℹ change initial estimate of `theta5` to `0.196446108190896` #> ℹ change initial estimate of `eta1` to `0.101251418415006` #> ℹ change initial estimate of `eta2` to `0.0993872449483344` #> ℹ change initial estimate of `eta3` to `0.101302674763154` #> ℹ change initial estimate of `eta4` to `0.0730497519364148` #> ℹ read in nonmem input data (for model validation): /home/runner/work/_temp/Library/nonmem2rx/mods/cpt/Bolus_2CPT.csv #> ℹ ignoring lines that begin with a letter (IGNORE=@)' #> ℹ applying names specified by $INPUT #> ℹ subsetting accept/ignore filters code: .data[-which((.data$SD == 0)),] #> ℹ done #> ℹ read in nonmem IPRED data (for model validation): /home/runner/work/_temp/Library/nonmem2rx/mods/cpt/runODE032.csv #> ℹ done #> ℹ changing most variables to lower case #> ℹ done #> ℹ replace theta names #> ℹ done #> ℹ replace eta names #> ℹ done (no labels) #> ℹ renaming compartments #> ℹ done #> ℹ solving ipred problem #> ℹ done #> ℹ solving pred problem #> ℹ done"},{"path":"/articles/simulate-new-dosing.html","id":"step-2-look-at-a-different-dosing-paradigm","dir":"Articles","previous_headings":"","what":"Step 2: Look at a different dosing paradigm","title":"Simulate New dosing from NONMEM model","text":"Lets say case instead single dose, want see concentration profile single day BID dosing. case done creating quick event table:","code":"ev <- et(amt=120000, ii=12, until=24) %>% et(list(c(0, 2), # add observations in windows c(4, 6), c(8, 12), c(14, 18), c(20, 26), c(28, 32), c(32, 36), c(36, 44))) %>% et(id=1:10)"},{"path":"/articles/simulate-new-dosing.html","id":"step-3-solve-using-rxode2","dir":"Articles","previous_headings":"","what":"Step 3: solve using rxode2","title":"Simulate New dosing from NONMEM model","text":"step, solve model new event table 10 subjects: Note since nonmem2rx model, default solving match tolerances methods specified NONMEM model.","code":"s <- rxSolve(mod, ev) #> ℹ using nocb interpolation like NONMEM, specify directly to change #> ℹ using addlKeepsCov=TRUE like NONMEM, specify directly to change #> ℹ using addlDropSs=TRUE like NONMEM, specify directly to change #> ℹ using ssAtDoseTime=TRUE like NONMEM, specify directly to change #> ℹ using safeZero=FALSE since NONMEM does not use protection by default #> ℹ using safePow=FALSE since NONMEM does not use protection by default #> ℹ using safeLog=FALSE since NONMEM does not use protection by default #> ℹ using ss2cancelAllPending=FALSE since NONMEM does not cancel pending doses with SS=2 #> ℹ using sigma from NONMEM #> ℹ using NONMEM specified atol=1e-12 #> ℹ using NONMEM specified rtol=1e-06 #> ℹ using NONMEM specified ssAtol=1e-12"},{"path":"/articles/simulate-new-dosing.html","id":"step-4-exploring-the-simulation-by-plotting","dir":"Articles","previous_headings":"","what":"Step 4: exploring the simulation (by plotting)","title":"Simulate New dosing from NONMEM model","text":"solved object acts rxode2 solved object, can use plot() function see individual profiles simulated:","code":"library(ggplot2) plot(s, ipred) + ylab(\"Concentrations\")"},{"path":"/articles/simulate-uncertainty.html","id":"step-1-import-the-model","dir":"Articles","previous_headings":"","what":"Step 1: Import the model","title":"Simulate using Parameter Uncertainty","text":"","code":"library(nonmem2rx) library(rxode2) # its best practice to set the seed for the simulations set.seed(42) rxSetSeed(42) # First we need the location of the nonmem control stream Since we are # running an example, we will use one of the built-in examples in # `nonmem2rx` ctlFile <- system.file(\"mods/cpt/runODE032.ctl\", package=\"nonmem2rx\") # You can use a control stream or other file. With the development # version of `babelmixr2`, you can simply point to the listing file mod <- nonmem2rx(ctlFile, lst=\".res\", save=FALSE, determineError=FALSE) #> ℹ getting information from '/home/runner/work/_temp/Library/nonmem2rx/mods/cpt/runODE032.ctl' #> ℹ reading in xml file #> ℹ done #> ℹ reading in ext file #> ℹ done #> ℹ reading in phi file #> ℹ done #> ℹ reading in lst file #> ℹ abbreviated list parsing #> ℹ done #> ℹ done #> ℹ splitting control stream by records #> ℹ done #> ℹ Processing record $INPUT #> ℹ Processing record $MODEL #> ℹ Processing record $gTHETA #> ℹ Processing record $OMEGA #> ℹ Processing record $SIGMA #> ℹ Processing record $PROBLEM #> ℹ Processing record $DATA #> ℹ Processing record $SUBROUTINES #> ℹ Processing record $PK #> ℹ Processing record $DES #> ℹ Processing record $ERROR #> ℹ Processing record $ESTIMATION #> ℹ Ignore record $ESTIMATION #> ℹ Processing record $COVARIANCE #> ℹ Ignore record $COVARIANCE #> ℹ Processing record $TABLE #> ℹ change initial estimate of `theta1` to `1.37034036528946` #> ℹ change initial estimate of `theta2` to `4.19814911033061` #> ℹ change initial estimate of `theta3` to `1.38003493562413` #> ℹ change initial estimate of `theta4` to `3.87657341967489` #> ℹ change initial estimate of `theta5` to `0.196446108190896` #> ℹ change initial estimate of `eta1` to `0.101251418415006` #> ℹ change initial estimate of `eta2` to `0.0993872449483344` #> ℹ change initial estimate of `eta3` to `0.101302674763154` #> ℹ change initial estimate of `eta4` to `0.0730497519364148` #> ℹ read in nonmem input data (for model validation): /home/runner/work/_temp/Library/nonmem2rx/mods/cpt/Bolus_2CPT.csv #> ℹ ignoring lines that begin with a letter (IGNORE=@)' #> ℹ applying names specified by $INPUT #> ℹ subsetting accept/ignore filters code: .data[-which((.data$SD == 0)),] #> ℹ done #> ℹ read in nonmem IPRED data (for model validation): /home/runner/work/_temp/Library/nonmem2rx/mods/cpt/runODE032.csv #> ℹ done #> ℹ changing most variables to lower case #> ℹ done #> ℹ replace theta names #> ℹ done #> ℹ replace eta names #> ℹ done (no labels) #> ℹ renaming compartments #> ℹ done #> ℹ solving ipred problem #> ℹ done #> ℹ solving pred problem #> ℹ done"},{"path":"/articles/simulate-uncertainty.html","id":"step-2-look-at-a-different-dosing-paradigm","dir":"Articles","previous_headings":"","what":"Step 2: Look at a different dosing paradigm","title":"Simulate using Parameter Uncertainty","text":"Lets say case instead single dose, want see concentration profile single day BID dosing. case done creating quick event table.","code":"ev <- et(amt=120000, ii=12, until=24) %>% et(c(1:6, seq(8, 24, by=2))) %>% et(id=1:100)"},{"path":"/articles/simulate-uncertainty.html","id":"step-3-solve-using-the-uncertainty-in-the-nonmem-model","dir":"Articles","previous_headings":"","what":"Step 3: Solve using the uncertainty in the NONMEM model","title":"Simulate using Parameter Uncertainty","text":"use uncertainty model, simple matter telling many times rxode2() sample nStud=X. case use 100.","code":"s <- rxSolve(mod, ev, nStud=100) #> ℹ using nocb interpolation like NONMEM, specify directly to change #> ℹ using addlKeepsCov=TRUE like NONMEM, specify directly to change #> ℹ using addlDropSs=TRUE like NONMEM, specify directly to change #> ℹ using ssAtDoseTime=TRUE like NONMEM, specify directly to change #> ℹ using safeZero=FALSE since NONMEM does not use protection by default #> ℹ using safePow=FALSE since NONMEM does not use protection by default #> ℹ using safeLog=FALSE since NONMEM does not use protection by default #> ℹ using ss2cancelAllPending=FALSE since NONMEM does not cancel pending doses with SS=2 #> ℹ using dfSub=120 from NONMEM #> ℹ using dfObs=2280 from NONMEM #> ℹ using thetaMat from NONMEM #> ℹ using sigma from NONMEM #> ℹ using NONMEM specified atol=1e-12 #> ℹ using NONMEM specified rtol=1e-06 #> ℹ using NONMEM specified ssAtol=1e-12 #> ℹ thetaMat has too many items, ignored: 'omega.2.1', 'omega.3.1', 'omega.3.2', 'omega.4.1', 'omega.4.2', 'omega.4.3' #> ℹ thetaMat has zero diagonal items, ignored: 'eps1' #> [====|====|====|====|====|====|====|====|====|====] 0:00:01 s #> ── Solved rxode2 object ── #> ── Parameters (x$params): ── #> # A tibble: 10,000 × 11 #> sim.id id theta1 theta2 theta3 theta4 RSV eta1 eta2 eta3 #> #> 1 1 1 1.34 4.14 1.34 3.88 0.197 -0.177 -0.0490 0.354 #> 2 1 2 1.34 4.14 1.34 3.88 0.197 0.300 -0.175 -0.000835 #> 3 1 3 1.34 4.14 1.34 3.88 0.197 0.512 0.543 0.0679 #> 4 1 4 1.34 4.14 1.34 3.88 0.197 -0.0557 -0.225 0.464 #> 5 1 5 1.34 4.14 1.34 3.88 0.197 0.0727 0.717 -0.0169 #> 6 1 6 1.34 4.14 1.34 3.88 0.197 -0.0835 -0.221 0.510 #> 7 1 7 1.34 4.14 1.34 3.88 0.197 0.721 -0.147 0.306 #> 8 1 8 1.34 4.14 1.34 3.88 0.197 0.336 0.00156 0.287 #> 9 1 9 1.34 4.14 1.34 3.88 0.197 0.240 -0.00161 -0.246 #> 10 1 10 1.34 4.14 1.34 3.88 0.197 0.368 -0.178 0.171 #> # ℹ 9,990 more rows #> # ℹ 1 more variable: eta4 #> ── Initial Conditions (x$inits): ── #> CENTRAL PERI #> 0 0 #> #> Simulation with uncertainty in: #> • parameters (x$thetaMat for changes) #> • omega matrix (x$omegaList) #> • sigma matrix (x$sigmaList) #> #> ── First part of data (object): ── #> # A tibble: 150,000 × 21 #> sim.id id time cl v q v2 v1 scale1 k21 k12 f #> #> 1 1 1 1 3.21 59.9 5.41 31.1 59.9 59.9 0.174 0.0904 1749. #> 2 1 1 2 3.21 59.9 5.41 31.1 59.9 59.9 0.174 0.0904 1549. #> 3 1 1 3 3.21 59.9 5.41 31.1 59.9 59.9 0.174 0.0904 1391. #> 4 1 1 4 3.21 59.9 5.41 31.1 59.9 59.9 0.174 0.0904 1265. #> 5 1 1 5 3.21 59.9 5.41 31.1 59.9 59.9 0.174 0.0904 1164. #> 6 1 1 6 3.21 59.9 5.41 31.1 59.9 59.9 0.174 0.0904 1081. #> # ℹ 149,994 more rows #> # ℹ 9 more variables: ipred , rescv , w , ires , #> # iwres , y , CENTRAL , PERI , DV "},{"path":"/articles/simulate-uncertainty.html","id":"step-4-summarize-and-plot","dir":"Articles","previous_headings":"","what":"Step 4: Summarize and plot","title":"Simulate using Parameter Uncertainty","text":"Since bunch data, confidence band simulation uncertainty helpful. One way select interesting components, create confidence interval plot confidence bands:","code":"sci <- confint(s, parm=c(\"CENTRAL\", \"PERI\", \"sim\")) #> summarizing data...done sci #> # A tibble: 90 × 7 #> p1 time trt p2.5 p50 p97.5 Percentile #>