Changing rxode2 compartment numbers
-2024-01-23
+2024-01-30
Source:vignettes/rxode2-cmt.Rmd
rxode2-cmt.Rmd
How rxode2 assigns compartment n
#> using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’
summary(pbpk)
-#> rxode2 2.1.1.9000 model named rx_45cececb1f44bc6825377e86555bf32a model (ready).
-#> DLL: /tmp/RtmpQvsiAp/rxode2/rx_45cececb1f44bc6825377e86555bf32a__.rxd/rx_45cececb1f44bc6825377e86555bf32a_.so
+#> rxode2 2.1.1.9000 model named rx_888e3ca6bf91062251a0666640a91082 model (ready).
+#> DLL: /tmp/RtmpVdj7Cq/rxode2/rx_888e3ca6bf91062251a0666640a91082__.rxd/rx_888e3ca6bf91062251a0666640a91082_.so
#> NULL
#>
#> Calculated Variables:
@@ -732,7 +732,7 @@ Appending compartments to the model
ode.1c.ka$simulationModel
#> using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’
-#> rxode2 2.1.1.9000 model named rx_3c2c707bde58bb58ac7dd2fb5996f24e model (ready).
+#> rxode2 2.1.1.9000 model named rx_155ca4092dddb690ae2ee099e46ed405 model (ready).
#> x$state: depot, center
#> x$stateExtra: eff
#> x$params: V, KA, CL
diff --git a/articles/rxode2-covariates.html b/articles/rxode2-covariates.html
index 97d129071..efd67a70e 100644
--- a/articles/rxode2-covariates.html
+++ b/articles/rxode2-covariates.html
@@ -158,7 +158,7 @@ Advanced Features, Model Types, Techni
rxode2 Covariates
- 2024-01-23
+ 2024-01-30
Source: vignettes/rxode2-covariates.Rmd
rxode2-covariates.Rmd
diff --git a/articles/rxode2-data-frame.html b/articles/rxode2-data-frame.html
index 4da1dcdf8..cec9e4b81 100644
--- a/articles/rxode2-data-frame.html
+++ b/articles/rxode2-data-frame.html
@@ -158,7 +158,7 @@ Advanced Features, Model Types, Techni
rxode2 Data Frames
- 2024-01-23
+ 2024-01-30
Source: vignettes/rxode2-data-frame.Rmd
rxode2-data-frame.Rmd
diff --git a/articles/rxode2-datasets.html b/articles/rxode2-datasets.html
index 443f4dc2c..d21dd8b4e 100644
--- a/articles/rxode2-datasets.html
+++ b/articles/rxode2-datasets.html
@@ -158,7 +158,7 @@ Advanced Features, Model Types, Techni
rxode2 Event Types
- 2024-01-23
+ 2024-01-30
Source: vignettes/rxode2-datasets.Rmd
rxode2-datasets.Rmd
diff --git a/articles/rxode2-event-table.html b/articles/rxode2-event-table.html
index 0ed76ab13..4411f4d04 100644
--- a/articles/rxode2-event-table.html
+++ b/articles/rxode2-event-table.html
@@ -158,7 +158,7 @@ Advanced Features, Model Types, Techni
Easy rxode2 Event Tables
- 2024-01-23
+ 2024-01-30
Source: vignettes/rxode2-event-table.Rmd
rxode2-event-table.Rmd
diff --git a/articles/rxode2-event-types.html b/articles/rxode2-event-types.html
index fed1a2e76..48e10dc65 100644
--- a/articles/rxode2-event-types.html
+++ b/articles/rxode2-event-types.html
@@ -158,7 +158,7 @@ Advanced Features, Model Types, Techni
rxode2 Event Types
- 2024-01-23
+ 2024-01-30
Source: vignettes/rxode2-event-types.Rmd
rxode2-event-types.Rmd
diff --git a/articles/rxode2-events-classic.html b/articles/rxode2-events-classic.html
index d605a6f18..a9c20453f 100644
--- a/articles/rxode2-events-classic.html
+++ b/articles/rxode2-events-classic.html
@@ -158,7 +158,7 @@ Advanced Features, Model Types, Techni
Classic rxode2 Events
- 2024-01-23
+ 2024-01-30
Source: vignettes/rxode2-events-classic.Rmd
rxode2-events-classic.Rmd
diff --git a/articles/rxode2-intro.html b/articles/rxode2-intro.html
index 2cd49edb8..b91a3649e 100644
--- a/articles/rxode2-intro.html
+++ b/articles/rxode2-intro.html
@@ -158,7 +158,7 @@ Advanced Features, Model Types, Techni
Introduction to rxode2
- 2024-01-23
+ 2024-01-30
Source: vignettes/rxode2-intro.Rmd
rxode2-intro.Rmd
diff --git a/articles/rxode2-model-types.html b/articles/rxode2-model-types.html
index 4d1ff19d0..5bf5d26de 100644
--- a/articles/rxode2-model-types.html
+++ b/articles/rxode2-model-types.html
@@ -163,7 +163,7 @@ Advanced Features, Model Types, Techni
rxode2 additional model types
- 2024-01-23
+ 2024-01-30
Source: vignettes/rxode2-model-types.Rmd
rxode2-model-types.Rmd
@@ -238,18 +238,18 @@ Solved compartment modelsVC or V
),
Peripheral/Tissue (VP
, VT
). While more
translations are available, some example translations are below:
-
-Another popular parameterization is in terms of micro-constants.
+
+Another popular parameterization is in terms of micro-constants.
rxode2 assumes compartment 1
is the central compartment.
The elimination constant would be specified by K
,
Ke
or Kel
. Some example translations are
below:
-
-The last parameterization possible is using alpha
and
+
+The last parameterization possible is using alpha
and
V
and/or A
/B
/C
. Some
example translations are below:
-
-Once the linCmt()
sleuthing is complete, the
+
+Once the linCmt()
sleuthing is complete, the
1
, 2
or 3
compartment model
solution is used as the value of linCmt()
.
The compartments where you can dose in a linear solved system are
diff --git a/articles/rxode2-nesting.html b/articles/rxode2-nesting.html
index 8baf1307b..6b027bb80 100644
--- a/articles/rxode2-nesting.html
+++ b/articles/rxode2-nesting.html
@@ -158,7 +158,7 @@
Advanced Features, Model Types, Techni
Nesting levels in rxode2
- 2024-01-23
+ 2024-01-30
Source: vignettes/rxode2-nesting.Rmd
rxode2-nesting.Rmd
@@ -313,24 +313,24 @@ Uncertainty in Model parametersdimnames(tMat) <- list(names(theta), names(theta))
tMat
-#> TKA TCl V2 Q V3 Kin
-#> TKA 0.097505124 -0.062632381 0.002185946 -0.05914820 -0.03199291 0.05191104
-#> TCl -0.062632381 0.143171198 -0.008142099 0.05343880 -0.05722191 0.02899693
-#> V2 0.002185946 -0.008142099 0.154042336 -0.02971687 0.05260648 -0.01051195
-#> Q -0.059148203 0.053438800 -0.029716875 0.22633127 -0.03319782 -0.02766129
-#> V3 -0.031992913 -0.057221913 0.052606476 -0.03319782 0.13971052 -0.05199069
-#> Kin 0.051911038 0.028996932 -0.010511954 -0.02766129 -0.05199069 0.07440267
-#> Kout 0.002767053 -0.029273941 0.027177995 0.05301177 -0.01928564 -0.01900449
-#> EC50 0.042999966 0.029589661 0.025228785 -0.02581527 -0.06561574 0.05785742
-#> Kout EC50
-#> TKA 0.002767053 0.04299997
-#> TCl -0.029273941 0.02958966
-#> V2 0.027177995 0.02522879
-#> Q 0.053011769 -0.02581527
-#> V3 -0.019285641 -0.06561574
-#> Kin -0.019004494 0.05785742
-#> Kout 0.084064882 0.01531464
-#> EC50 0.015314645 0.07068059
+#> TKA TCl V2 Q V3
+#> TKA 0.126848583 -0.032826578 -0.01782012 0.073985411 0.059556312
+#> TCl -0.032826578 0.151271663 0.03931559 -0.051646177 -0.007039095
+#> V2 -0.017820116 0.039315589 0.12984576 -0.020526430 -0.020795502
+#> Q 0.073985411 -0.051646177 -0.02052643 0.117838807 0.038811836
+#> V3 0.059556312 -0.007039095 -0.02079550 0.038811836 0.143854965
+#> Kin 0.045394641 -0.081603448 -0.09260154 0.041152976 0.040346612
+#> Kout 0.000167824 0.003345854 0.05728777 0.001139339 0.049801997
+#> EC50 -0.027327195 -0.038015655 -0.07461475 -0.001034485 -0.001467119
+#> Kin Kout EC50
+#> TKA 0.045394641 0.000167824 -0.027327195
+#> TCl -0.081603448 0.003345854 -0.038015655
+#> V2 -0.092601542 0.057287774 -0.074614754
+#> Q 0.041152976 0.001139339 -0.001034485
+#> V3 0.040346612 0.049801997 -0.001467119
+#> Kin 0.164699412 0.005776729 0.058097097
+#> Kout 0.005776729 0.093264071 -0.020050191
+#> EC50 0.058097097 -0.020050191 0.066070112
Nesting Variability
@@ -408,16 +408,16 @@ Solving the problem#> # A tibble: 8,000 x 24
#> sim.id id `inv.Cl(inv==1)` `inv.Cl(inv==2)` `inv.Ka(inv==1)`
#> <int> <fct> <dbl> <dbl> <dbl>
-#> 1 1 1 0.0561 0.00268 0.0989
-#> 2 1 2 0.0561 0.00268 0.0989
-#> 3 1 3 0.0561 0.00268 0.0989
-#> 4 1 4 0.0561 0.00268 0.0989
-#> 5 1 5 0.0561 0.00268 0.0989
-#> 6 1 6 0.0561 0.00268 0.0989
-#> 7 1 7 0.0561 0.00268 0.0989
-#> 8 1 8 0.0561 0.00268 0.0989
-#> 9 1 9 0.0561 0.00268 0.0989
-#> 10 1 10 0.0561 0.00268 0.0989
+#> 1 1 1 -0.122 0.155 -0.132
+#> 2 1 2 -0.122 0.155 -0.132
+#> 3 1 3 -0.122 0.155 -0.132
+#> 4 1 4 -0.122 0.155 -0.132
+#> 5 1 5 -0.122 0.155 -0.132
+#> 6 1 6 -0.122 0.155 -0.132
+#> 7 1 7 -0.122 0.155 -0.132
+#> 8 1 8 -0.122 0.155 -0.132
+#> 9 1 9 -0.122 0.155 -0.132
+#> 10 1 10 -0.122 0.155 -0.132
#> # i 7,990 more rows
#> # i 19 more variables: `inv.Ka(inv==2)` <dbl>, `eye.Cl(eye==1)` <dbl>,
#> # `eye.Cl(eye==2)` <dbl>, `eye.Ka(eye==1)` <dbl>, `eye.Ka(eye==2)` <dbl>,
@@ -434,14 +434,14 @@ Solving the problem#>
#> -- First part of data (object): --
#> # A tibble: 976,000 x 21
-#> sim.id id time inv.Cl inv.Ka eye.Cl eye.Ka iov.Cl iov.Ka C2 C3
-#> <int> <int> [h] <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
-#> 1 1 1 0 0.0561 0.0989 -0.369 0.216 0.0635 -0.0104 0 0
-#> 2 1 1 0.1 0.0561 0.0989 0.339 0.195 0.0635 -0.0104 -0.671 -0.00418
-#> 3 1 1 4 0.0561 0.0989 -0.369 0.216 0.0635 -0.0104 -11.2 -2.33
-#> 4 1 1 4.1 0.0561 0.0989 0.339 0.195 0.0635 -0.0104 -27.5 -2.41
-#> 5 1 1 8 0.0561 0.0989 -0.369 0.216 0.0635 -0.0104 -44.1 -6.06
-#> 6 1 1 8.1 0.0561 0.0989 0.339 0.195 0.0635 -0.0104 -16.4 -6.17
+#> sim.id id time inv.Cl inv.Ka eye.Cl eye.Ka iov.Cl iov.Ka C2 C3
+#> <int> <int> [h] <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
+#> 1 1 1 0 -0.122 -0.132 0.178 0.202 0.140 -0.114 0 0
+#> 2 1 1 0.1 -0.122 -0.132 0.0179 0.590 0.140 -0.114 21.4 0.0308
+#> 3 1 1 4 -0.122 -0.132 0.178 0.202 0.140 -0.114 27.4 8.06
+#> 4 1 1 4.1 -0.122 -0.132 0.0179 0.590 0.140 -0.114 16.5 8.11
+#> 5 1 1 8 -0.122 -0.132 0.178 0.202 0.140 -0.114 5.53 8.05
+#> 6 1 1 8.1 -0.122 -0.132 0.0179 0.590 0.140 -0.114 2.26 8.03
#> # i 975,994 more rows
#> # i 10 more variables: CL <dbl>, KA <dbl>, ef0 <dbl>, depot <dbl>, centr <dbl>,
#> # peri <dbl>, eff <dbl>, occ <fct>, eye <fct>, inv <fct>
@@ -463,63 +463,63 @@ Solving the problem
print(head(s$params))
#> sim.id id inv.Cl(inv==1) inv.Cl(inv==2) inv.Ka(inv==1) inv.Ka(inv==2)
-#> 1 1 1 0.05613725 0.002676121 0.09886939 -0.1145422
-#> 2 1 2 0.05613725 0.002676121 0.09886939 -0.1145422
-#> 3 1 3 0.05613725 0.002676121 0.09886939 -0.1145422
-#> 4 1 4 0.05613725 0.002676121 0.09886939 -0.1145422
-#> 5 1 5 0.05613725 0.002676121 0.09886939 -0.1145422
-#> 6 1 6 0.05613725 0.002676121 0.09886939 -0.1145422
+#> 1 1 1 -0.1215069 0.1545973 -0.1315419 0.04715879
+#> 2 1 2 -0.1215069 0.1545973 -0.1315419 0.04715879
+#> 3 1 3 -0.1215069 0.1545973 -0.1315419 0.04715879
+#> 4 1 4 -0.1215069 0.1545973 -0.1315419 0.04715879
+#> 5 1 5 -0.1215069 0.1545973 -0.1315419 0.04715879
+#> 6 1 6 -0.1215069 0.1545973 -0.1315419 0.04715879
#> eye.Cl(eye==1) eye.Cl(eye==2) eye.Ka(eye==1) eye.Ka(eye==2) iov.Cl(occ==1)
-#> 1 -0.36889783 0.33918164 0.2162948 0.19535253 0.06345274
-#> 2 -0.14895018 0.07424926 0.1097794 0.15293130 0.05229912
-#> 3 -0.15606853 0.11696081 -0.1158629 0.07757864 0.02750855
-#> 4 0.01562668 -0.19437159 0.3422191 -0.19985282 0.07953385
-#> 5 0.06257184 -0.37364710 -0.3959396 -0.01406317 0.03389101
-#> 6 0.07229385 0.43743875 -0.3090004 0.24403413 0.04431553
+#> 1 0.17768102 0.01792468 0.20248907 0.59034041 0.14004312
+#> 2 0.06489535 0.29199480 0.29632489 0.21877654 0.11411853
+#> 3 0.26209113 0.24908804 0.02238583 0.19128359 -0.03635801
+#> 4 -0.05790927 0.11175879 0.29045175 0.10784750 -0.11147278
+#> 5 0.11253973 -0.54106107 0.12217645 -0.06972935 0.11371664
+#> 6 -0.12160938 0.21721757 0.16076583 0.19466692 0.14876658
#> iov.Cl(occ==2) iov.Ka(occ==1) iov.Ka(occ==2) V2 V3 TCl
-#> 1 0.079961183 -0.01035850 0.05980327 40.18099 296.9346 19.00838
-#> 2 0.144455837 -0.02503950 -0.05779184 40.18099 296.9346 19.00838
-#> 3 0.009428645 0.21422583 0.04698294 40.18099 296.9346 19.00838
-#> 4 -0.064550794 -0.11564902 -0.05483477 40.18099 296.9346 19.00838
-#> 5 -0.006710996 -0.15198013 0.04304332 40.18099 296.9346 19.00838
-#> 6 0.014598965 -0.06497242 -0.02679635 40.18099 296.9346 19.00838
-#> eta.Cl TKA eta.Ka Q Kin Kout EC50
-#> 1 0.325220393 -0.1308913 -0.70691415 10.82697 0.8761277 1.110527 199.9781
-#> 2 -0.239072540 -0.1308913 0.09798957 10.82697 0.8761277 1.110527 199.9781
-#> 3 -0.365966014 -0.1308913 -0.22095613 10.82697 0.8761277 1.110527 199.9781
-#> 4 -0.385975216 -0.1308913 0.43595833 10.82697 0.8761277 1.110527 199.9781
-#> 5 -0.494204338 -0.1308913 -0.43747789 10.82697 0.8761277 1.110527 199.9781
-#> 6 -0.005687513 -0.1308913 0.18786647 10.82697 0.8761277 1.110527 199.9781
+#> 1 0.006036892 -0.114443871 0.12691051 39.87968 297.0515 18.18964
+#> 2 -0.045177500 0.088364808 -0.05786029 39.87968 297.0515 18.18964
+#> 3 -0.071183712 0.055763391 0.05496106 39.87968 297.0515 18.18964
+#> 4 -0.008961117 -0.001915763 -0.12189986 39.87968 297.0515 18.18964
+#> 5 -0.044598387 -0.015648688 0.03349536 39.87968 297.0515 18.18964
+#> 6 0.082074695 0.088764338 -0.04455202 39.87968 297.0515 18.18964
+#> eta.Cl TKA eta.Ka Q Kin Kout EC50
+#> 1 0.346512208 0.5115992 0.15779437 10.4914 1.230806 0.550272 200.0012
+#> 2 -0.429153012 0.5115992 -0.06162353 10.4914 1.230806 0.550272 200.0012
+#> 3 -0.594006469 0.5115992 0.41790229 10.4914 1.230806 0.550272 200.0012
+#> 4 -0.017669131 0.5115992 -0.21379448 10.4914 1.230806 0.550272 200.0012
+#> 5 0.005789727 0.5115992 0.02455379 10.4914 1.230806 0.550272 200.0012
+#> 6 -0.244988767 0.5115992 -0.34299309 10.4914 1.230806 0.550272 200.0012
#> sim.id id inv.Cl(inv==1) inv.Cl(inv==2) inv.Ka(inv==1) inv.Ka(inv==2)
-#> 1 2 1 0.3716316 0.1462637 0.2201585 -0.1795746
-#> 2 2 2 0.3716316 0.1462637 0.2201585 -0.1795746
-#> 3 2 3 0.3716316 0.1462637 0.2201585 -0.1795746
-#> 4 2 4 0.3716316 0.1462637 0.2201585 -0.1795746
-#> 5 2 5 0.3716316 0.1462637 0.2201585 -0.1795746
-#> 6 2 6 0.3716316 0.1462637 0.2201585 -0.1795746
+#> 1 2 1 -0.01057313 -0.2681566 0.1124571 -0.1934464
+#> 2 2 2 -0.01057313 -0.2681566 0.1124571 -0.1934464
+#> 3 2 3 -0.01057313 -0.2681566 0.1124571 -0.1934464
+#> 4 2 4 -0.01057313 -0.2681566 0.1124571 -0.1934464
+#> 5 2 5 -0.01057313 -0.2681566 0.1124571 -0.1934464
+#> 6 2 6 -0.01057313 -0.2681566 0.1124571 -0.1934464
#> eye.Cl(eye==1) eye.Cl(eye==2) eye.Ka(eye==1) eye.Ka(eye==2) iov.Cl(occ==1)
-#> 1 0.16696543 0.070457235 0.04083151 0.2307054 0.05856952
-#> 2 0.11722824 -0.017176892 -0.04952944 -0.2212587 0.08642440
-#> 3 0.02993742 -0.042805106 0.01951154 -0.3526755 0.22378102
-#> 4 -0.04845361 -0.071353576 -0.19917086 -0.7232118 0.08176182
-#> 5 -0.47189049 -0.009489383 0.07986463 0.2155951 -0.11265072
-#> 6 -0.30771112 -0.270450225 0.14291960 -0.1234880 -0.13191721
-#> iov.Cl(occ==2) iov.Ka(occ==1) iov.Ka(occ==2) V2 V3 TCl
-#> 1 0.11407708 -0.025806967 0.096592475 39.76595 296.7083 18.6806
-#> 2 0.03995586 -0.030545407 -0.064031061 39.76595 296.7083 18.6806
-#> 3 -0.05760596 0.040064339 -0.132986456 39.76595 296.7083 18.6806
-#> 4 0.10317142 -0.023111088 0.073936889 39.76595 296.7083 18.6806
-#> 5 0.03014249 -0.009342765 0.078688405 39.76595 296.7083 18.6806
-#> 6 0.03136129 0.038632834 0.007001786 39.76595 296.7083 18.6806
-#> eta.Cl TKA eta.Ka Q Kin Kout EC50
-#> 1 -0.1793494 -0.145803 0.2898582 10.44525 0.5898876 1.22986 199.855
-#> 2 0.5037215 -0.145803 -0.4326681 10.44525 0.5898876 1.22986 199.855
-#> 3 0.2406049 -0.145803 -0.1300759 10.44525 0.5898876 1.22986 199.855
-#> 4 -0.2885122 -0.145803 -0.8424224 10.44525 0.5898876 1.22986 199.855
-#> 5 -0.4313984 -0.145803 0.1490218 10.44525 0.5898876 1.22986 199.855
-#> 6 0.3886682 -0.145803 0.2832276 10.44525 0.5898876 1.22986 199.855
+#> 1 0.188192979 0.15446999 0.06496711 -0.0363898042 0.12166973
+#> 2 0.238059374 -0.15031874 -0.05673069 -0.0380056984 0.03976102
+#> 3 -0.009181288 0.27973679 -0.09273052 0.0008831785 -0.06182943
+#> 4 0.127782122 -0.25292487 -0.28648116 -0.2964420340 0.04841083
+#> 5 0.069248352 0.01308512 0.27893736 0.0179776517 -0.05728655
+#> 6 0.185834266 -0.34968461 -0.21868525 0.1113316292 0.30223133
+#> iov.Cl(occ==2) iov.Ka(occ==1) iov.Ka(occ==2) V2 V3 TCl
+#> 1 0.03663079 -0.11113535 0.03930488 40.30603 297.3599 18.67602
+#> 2 -0.06971917 0.04701878 -0.10809105 40.30603 297.3599 18.67602
+#> 3 -0.05006046 0.02070942 0.05511813 40.30603 297.3599 18.67602
+#> 4 -0.14295695 -0.13590835 -0.11438424 40.30603 297.3599 18.67602
+#> 5 0.01508066 0.04698955 -0.09478923 40.30603 297.3599 18.67602
+#> 6 0.14507034 0.12851272 0.06502513 40.30603 297.3599 18.67602
+#> eta.Cl TKA eta.Ka Q Kin Kout EC50
+#> 1 -0.43592595 0.4782224 0.09977002 10.54849 1.471684 1.390875 199.8732
+#> 2 -0.30435078 0.4782224 -0.16682736 10.54849 1.471684 1.390875 199.8732
+#> 3 0.09160909 0.4782224 0.05367372 10.54849 1.471684 1.390875 199.8732
+#> 4 0.36520870 0.4782224 0.10092741 10.54849 1.471684 1.390875 199.8732
+#> 5 0.42367115 0.4782224 -0.01304600 10.54849 1.471684 1.390875 199.8732
+#> 6 -0.49519424 0.4782224 0.03113892 10.54849 1.471684 1.390875 199.8732
For between eye variability and between occasion variability each
individual simulates a number of variables that become the between eye
and between occasion variability; In the case of the eye:
diff --git a/articles/rxode2-pipeline.html b/articles/rxode2-pipeline.html
index 1f288c049..3c7ffc3c7 100644
--- a/articles/rxode2-pipeline.html
+++ b/articles/rxode2-pipeline.html
@@ -158,7 +158,7 @@ Advanced Features, Model Types, Techni
rxode2 in a pipeline
- 2024-01-23
+ 2024-01-30
Source: vignettes/rxode2-pipeline.Rmd
rxode2-pipeline.Rmd
diff --git a/articles/rxode2-plot.html b/articles/rxode2-plot.html
index 05411e976..ccbafa63f 100644
--- a/articles/rxode2-plot.html
+++ b/articles/rxode2-plot.html
@@ -160,7 +160,7 @@ Advanced Features, Model Types, Techni
Matthew
Fidler
- 2024-01-23
+ 2024-01-30
Source: vignettes/rxode2-plot.Rmd
rxode2-plot.Rmd
diff --git a/articles/rxode2-plot_files/figure-html/unnamed-chunk-10-1.png b/articles/rxode2-plot_files/figure-html/unnamed-chunk-10-1.png
index 39dbb8a9a..3e6b366c8 100644
Binary files a/articles/rxode2-plot_files/figure-html/unnamed-chunk-10-1.png and b/articles/rxode2-plot_files/figure-html/unnamed-chunk-10-1.png differ
diff --git a/articles/rxode2-plot_files/figure-html/unnamed-chunk-6-1.png b/articles/rxode2-plot_files/figure-html/unnamed-chunk-6-1.png
index b18bb4ee0..5c11f93e4 100644
Binary files a/articles/rxode2-plot_files/figure-html/unnamed-chunk-6-1.png and b/articles/rxode2-plot_files/figure-html/unnamed-chunk-6-1.png differ
diff --git a/articles/rxode2-plot_files/figure-html/unnamed-chunk-7-1.png b/articles/rxode2-plot_files/figure-html/unnamed-chunk-7-1.png
index 09ceec962..b35b93d21 100644
Binary files a/articles/rxode2-plot_files/figure-html/unnamed-chunk-7-1.png and b/articles/rxode2-plot_files/figure-html/unnamed-chunk-7-1.png differ
diff --git a/articles/rxode2-plot_files/figure-html/unnamed-chunk-8-1.png b/articles/rxode2-plot_files/figure-html/unnamed-chunk-8-1.png
index 510b6544c..6136ebc84 100644
Binary files a/articles/rxode2-plot_files/figure-html/unnamed-chunk-8-1.png and b/articles/rxode2-plot_files/figure-html/unnamed-chunk-8-1.png differ
diff --git a/articles/rxode2-prior-data.html b/articles/rxode2-prior-data.html
index 1ea74691b..c463d1bb3 100644
--- a/articles/rxode2-prior-data.html
+++ b/articles/rxode2-prior-data.html
@@ -158,7 +158,7 @@ Advanced Features, Model Types, Techni
Using Prior Data for ODE solving
- 2024-01-23
+ 2024-01-30
Source: vignettes/rxode2-prior-data.Rmd
rxode2-prior-data.Rmd
diff --git a/articles/rxode2-rxUse.html b/articles/rxode2-rxUse.html
index c052658ad..9756d748c 100644
--- a/articles/rxode2-rxUse.html
+++ b/articles/rxode2-rxUse.html
@@ -160,7 +160,7 @@ Advanced Features, Model Types, Techni
Matthew
Fidler
- 2024-01-23
+ 2024-01-30
Source: vignettes/rxode2-rxUse.Rmd
rxode2-rxUse.Rmd
diff --git a/articles/rxode2-shiny.html b/articles/rxode2-shiny.html
index edc4b38f3..a8ad791c2 100644
--- a/articles/rxode2-shiny.html
+++ b/articles/rxode2-shiny.html
@@ -158,7 +158,7 @@ Advanced Features, Model Types, Techni
rxode2 and Shiny
- 2024-01-23
+ 2024-01-30
Source: vignettes/rxode2-shiny.Rmd
rxode2-shiny.Rmd
diff --git a/articles/rxode2-sim-var.html b/articles/rxode2-sim-var.html
index 5103d89f3..0cea68fbe 100644
--- a/articles/rxode2-sim-var.html
+++ b/articles/rxode2-sim-var.html
@@ -158,7 +158,7 @@ Advanced Features, Model Types, Techni
rxode2 Simulation
- 2024-01-23
+ 2024-01-30
Source: vignettes/rxode2-sim-var.Rmd
rxode2-sim-var.Rmd
diff --git a/articles/rxode2-single-subject.html b/articles/rxode2-single-subject.html
index 073042231..1d9eb6b93 100644
--- a/articles/rxode2-single-subject.html
+++ b/articles/rxode2-single-subject.html
@@ -158,7 +158,7 @@ Advanced Features, Model Types, Techni
Single Subject ODE solving -- differences from multiple subject
- 2024-01-23
+ 2024-01-30
Source: vignettes/rxode2-single-subject.Rmd
rxode2-single-subject.Rmd
diff --git a/articles/rxode2-speed.html b/articles/rxode2-speed.html
index 77d61d96a..ee26fc8ff 100644
--- a/articles/rxode2-speed.html
+++ b/articles/rxode2-speed.html
@@ -160,7 +160,7 @@ Advanced Features, Model Types, Techni
Matthew
Fidler
- 2024-01-23
+ 2024-01-30
Source: vignettes/rxode2-speed.Rmd
rxode2-speed.Rmd
@@ -263,8 +263,8 @@ A note about t
output. You can see the differences below:
summary(mod1$simulationModel)
-#> rxode2 2.1.1.9000 model named rx_dde7adafaa5c6f5a2e1f34b01767a0af model (✔ ready).
-#> DLL: /tmp/RtmpQvsiAp/rxode2/rx_dde7adafaa5c6f5a2e1f34b01767a0af__.rxd/rx_dde7adafaa5c6f5a2e1f34b01767a0af_.so
+#> rxode2 2.1.1.9000 model named rx_ec464bc9eace073a4527d87acadfddb4 model (✔ ready).
+#> DLL: /tmp/RtmpVdj7Cq/rxode2/rx_ec464bc9eace073a4527d87acadfddb4__.rxd/rx_ec464bc9eace073a4527d87acadfddb4_.so
#> NULL
#>
#> Calculated Variables:
@@ -282,8 +282,8 @@ A note about t
#> })
summary(mod1$simulationIniModel)
#> using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’
-#> rxode2 2.1.1.9000 model named rx_e44e9ee38545b57dae62d04510ccab81 model (✔ ready).
-#> DLL: /tmp/RtmpQvsiAp/rxode2/rx_e44e9ee38545b57dae62d04510ccab81__.rxd/rx_e44e9ee38545b57dae62d04510ccab81_.so
+#> rxode2 2.1.1.9000 model named rx_5a172c6836cda6d471133865d1613f08 model (✔ ready).
+#> DLL: /tmp/RtmpVdj7Cq/rxode2/rx_5a172c6836cda6d471133865d1613f08__.rxd/rx_5a172c6836cda6d471133865d1613f08_.so
#> NULL
#>
#> Calculated Variables:
@@ -309,8 +309,8 @@ A note about t
#> })
summary(mod2f$simulationModel)
#> using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’
-#> rxode2 2.1.1.9000 model named rx_525381b0d2a180cfde7f4fecb32b3a45 model (✔ ready).
-#> DLL: /tmp/RtmpQvsiAp/rxode2/rx_525381b0d2a180cfde7f4fecb32b3a45__.rxd/rx_525381b0d2a180cfde7f4fecb32b3a45_.so
+#> rxode2 2.1.1.9000 model named rx_d175dc97754e25b6601589d6579909e4 model (✔ ready).
+#> DLL: /tmp/RtmpVdj7Cq/rxode2/rx_d175dc97754e25b6601589d6579909e4__.rxd/rx_d175dc97754e25b6601589d6579909e4_.so
#> NULL
#>
#> Calculated Variables:
@@ -366,8 +366,8 @@ A note about t
#> })
summary(mod2f$simulationIniModel)
#> using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’
-#> rxode2 2.1.1.9000 model named rx_1e1e825cbc5725fe5238d9a808269d13 model (✔ ready).
-#> DLL: /tmp/RtmpQvsiAp/rxode2/rx_1e1e825cbc5725fe5238d9a808269d13__.rxd/rx_1e1e825cbc5725fe5238d9a808269d13_.so
+#> rxode2 2.1.1.9000 model named rx_1fa541ac46daeb5fc30a38552ebd1a28 model (✔ ready).
+#> DLL: /tmp/RtmpVdj7Cq/rxode2/rx_1fa541ac46daeb5fc30a38552ebd1a28__.rxd/rx_1fa541ac46daeb5fc30a38552ebd1a28_.so
#> NULL
#>
#> Calculated Variables:
@@ -553,10 +553,10 @@ Compare the times between all
print(bench)
#> Unit: milliseconds
#> expr min lq mean median uq max
-#> runFor() 272.68192 279.27422 293.81865 283.77730 296.50623 431.60477
-#> runSapply() 271.76756 279.56641 289.78392 281.80045 290.21712 399.43239
-#> runSingleThread() 27.14962 27.43392 28.53953 27.65254 28.09581 46.61663
-#> run2Thread() 16.18853 16.43165 17.36998 16.73554 17.11031 27.44037
+#> runFor() 275.27445 282.72659 296.32924 285.36428 296.59053 421.94861
+#> runSapply() 275.42242 282.27560 289.41330 284.19744 288.66425 340.32593
+#> runSingleThread() 27.80331 28.08948 28.58767 28.33210 28.62940 34.20171
+#> run2Thread() 16.46957 16.92515 18.70476 17.21281 17.81127 30.40426
#> neval
#> 100
#> 100
@@ -583,10 +583,10 @@ Compare the times between all
print(bench)
#> Unit: milliseconds
#> expr min lq mean median uq max neval
-#> runThread(1) 27.13695 27.62539 28.89258 28.21513 28.89024 50.12725 100
-#> runThread(2) 16.32435 16.75297 18.91421 17.30626 18.75373 29.18771 100
-#> runThread(3) 17.49259 18.48256 19.99102 20.16053 20.75537 25.10859 100
-#> runThread(4) 16.21415 16.76762 18.08898 17.12330 17.54657 37.09393 100
+#> runThread(1) 27.88072 28.08433 29.26498 28.41125 29.54402 48.86065 100
+#> runThread(2) 16.53631 16.85069 18.65513 17.31703 17.76293 32.22483 100
+#> runThread(3) 17.98543 19.65418 20.38128 20.00796 20.52825 26.88089 100
+#> runThread(4) 16.21520 16.54979 18.03119 17.11132 17.37072 36.57811 100
autoplot(bench)
@@ -675,8 +675,8 @@ Increasing speed with compiler o
print(bench)
#> Unit: milliseconds
#> expr min lq mean median uq max neval
-#> standardCompile 191.3855 300.3776 305.9900 301.8742 306.8112 354.7742 100
-#> fastCompile 193.4735 301.5670 307.5617 303.9288 309.4961 355.8324 100
+#> standardCompile 189.9879 310.2717 315.7530 312.1834 316.6587 372.8248 100
+#> fastCompile 194.8383 309.7847 316.1023 313.0658 319.1076 386.9029 100
autoplot(bench)
@@ -770,7 +770,7 @@ A real life exampleStoplapply <- Sys.time()
print(Stoplapply - Startlapply)
-#> Time difference of 11.60301 secs
+#> Time difference of 13.49471 secs
By applying some of the new parallel solving concepts you can simply
run the same simulation both with less code and faster:
@@ -811,7 +811,7 @@ A real life exampleres <- rxSolve(rx, ev, omega=omega, returnType="data.table")
endParallel <- Sys.time()
print(endParallel - startParallel)
-#> Time difference of 0.104939 secs
+#> Time difference of 0.1269417 secs
You can see a striking time difference between the two methods; A few
things to keep in mind:
+#> [1] gtable_0.3.4 xfun_0.41 bslib_0.6.1
+#> [4] RApiSerialize_0.1.2 lattice_0.21-9 vctrs_0.6.5
+#> [7] tools_4.3.2 generics_0.1.3 tibble_3.2.1
+#> [10] symengine_0.2.4 fansi_1.0.6 highr_0.10
+#> [13] pkgconfig_2.0.3 checkmate_2.3.1 desc_1.4.3
+#> [16] RcppParallel_5.1.7 lifecycle_1.0.4 compiler_4.3.2
+#> [19] farver_2.1.1 stringr_1.5.1 textshaping_0.3.7
+#> [22] munsell_0.5.0 qs_0.25.7 htmltools_0.5.7
+#> [25] sys_3.4.2 sass_0.4.8 yaml_2.3.8
+#> [28] lazyeval_0.2.2 pillar_1.9.0 pkgdown_2.0.7
+#> [31] crayon_1.5.2 jquerylib_0.1.4 cachem_1.0.8
+#> [34] nlme_3.1-163 tidyselect_1.2.0 digest_0.6.34
+#> [37] lotri_0.4.4 stringi_1.8.3 dplyr_1.1.4
+#> [40] purrr_1.0.2 rxode2ll_2.0.11.9000 fastmap_1.1.1
+#> [43] grid_4.3.2 colorspace_2.1-0 rxode2parse_2.0.18
+#> [46] cli_3.6.2 dparser_1.3.1-11 magrittr_2.0.3
+#> [49] utf8_1.2.4 withr_3.0.0 scales_1.3.0
+#> [52] backports_1.4.1 rmarkdown_2.25 ragg_1.2.7
+#> [55] stringfish_0.16.0 memoise_2.0.1 evaluate_0.23
+#> [58] knitr_1.45 rex_1.2.1 rxode2et_2.0.12
+#> [61] rxode2random_2.0.13 PreciseSums_0.6 rlang_1.1.3
+#> [64] Rcpp_1.0.12 glue_1.7.0 jsonlite_1.8.8
+#> [67] R6_2.5.1 systemfonts_1.0.5 fs_1.6.3
+#> [70] units_0.8-5
diff --git a/articles/rxode2-transit-compartments.html b/articles/rxode2-transit-compartments.html
index 46738f2b6..ddc71fe4d 100644
--- a/articles/rxode2-transit-compartments.html
+++ b/articles/rxode2-transit-compartments.html
@@ -158,7 +158,7 @@ Advanced Features, Model Types, Techni
rxode2 Transit Compartment Models
- 2024-01-23
+ 2024-01-30
Source: vignettes/rxode2-transit-compartments.Rmd
rxode2-transit-compartments.Rmd
diff --git a/articles/rxode2-wt.html b/articles/rxode2-wt.html
index 5b49fd487..838c79e7c 100644
--- a/articles/rxode2-wt.html
+++ b/articles/rxode2-wt.html
@@ -158,7 +158,7 @@ Advanced Features, Model Types, Techni
Weight Based Dosing in rxode2
- 2024-01-23
+ 2024-01-30
Source: vignettes/rxode2-wt.Rmd
rxode2-wt.Rmd
diff --git a/pkgdown.yml b/pkgdown.yml
index fd061d836..288b8d413 100644
--- a/pkgdown.yml
+++ b/pkgdown.yml
@@ -27,7 +27,7 @@ articles:
rxode2-transit-compartments: rxode2-transit-compartments.html
rxode2-tutorials: rxode2-tutorials.html
rxode2-wt: rxode2-wt.html
-last_built: 2024-01-23T05:35Z
+last_built: 2024-01-30T05:37Z
urls:
reference: https://nlmixr2.github.io/rxode2/reference
article: https://nlmixr2.github.io/rxode2/articles
diff --git a/reference/dot-rxWithWd.html b/reference/dot-rxWithWd.html
index 960340e85..98e1e0002 100644
--- a/reference/dot-rxWithWd.html
+++ b/reference/dot-rxWithWd.html
@@ -162,7 +162,7 @@ Examples.rxWithWd(tempdir(), {
getwd()
})
-#> [1] "/tmp/RtmpQvsiAp"
+#> [1] "/tmp/RtmpVdj7Cq"
getwd()
#> [1] "/home/runner/work/rxode2/rxode2/docs/reference"
diff --git a/reference/myapp/mod1.d/mod1_.c b/reference/myapp/mod1.d/mod1_.c
index 4cc8bf41c..0ce9dd16f 100644
--- a/reference/myapp/mod1.d/mod1_.c
+++ b/reference/myapp/mod1.d/mod1_.c
@@ -1,119 +1,119 @@
-#define _getRxSolve_ _rxmod1_90e78de85eae102082dac9d0e66faf820
-#define _evalUdf _rxmod1_90e78de85eae102082dac9d0e66faf821
-#define _solveData _rxmod1_90e78de85eae102082dac9d0e66faf822
-#define _assign_ptr _rxmod1_90e78de85eae102082dac9d0e66faf823
-#define _rxRmModelLib _rxmod1_90e78de85eae102082dac9d0e66faf824
-#define _rxGetModelLib _rxmod1_90e78de85eae102082dac9d0e66faf825
-#define _old_c _rxmod1_90e78de85eae102082dac9d0e66faf826
-#define _ptrid _rxmod1_90e78de85eae102082dac9d0e66faf827
-#define _rxIsCurrentC _rxmod1_90e78de85eae102082dac9d0e66faf828
-#define _sumPS _rxmod1_90e78de85eae102082dac9d0e66faf829
-#define _prodPS _rxmod1_90e78de85eae102082dac9d0e66faf8210
-#define _prodType _rxmod1_90e78de85eae102082dac9d0e66faf8211
-#define _sumType _rxmod1_90e78de85eae102082dac9d0e66faf8212
-#define _update_par_ptr _rxmod1_90e78de85eae102082dac9d0e66faf8213
-#define _getParCov _rxmod1_90e78de85eae102082dac9d0e66faf8214
-#define _rxode2_rxAssignPtr _rxmod1_90e78de85eae102082dac9d0e66faf8215
-#define _rxQr _rxmod1_90e78de85eae102082dac9d0e66faf8216
-#define _compareFactorVal _rxmod1_90e78de85eae102082dac9d0e66faf8217
-#define _sum _rxmod1_90e78de85eae102082dac9d0e66faf8218
-#define _udf _rxmod1_90e78de85eae102082dac9d0e66faf8219
-#define _sign _rxmod1_90e78de85eae102082dac9d0e66faf8220
-#define _prod _rxmod1_90e78de85eae102082dac9d0e66faf8221
-#define _max _rxmod1_90e78de85eae102082dac9d0e66faf8222
-#define _min _rxmod1_90e78de85eae102082dac9d0e66faf8223
-#define _transit4P _rxmod1_90e78de85eae102082dac9d0e66faf8224
-#define _transit3P _rxmod1_90e78de85eae102082dac9d0e66faf8225
-#define _assignFuns0 _rxmod1_90e78de85eae102082dac9d0e66faf8226
-#define _assignFuns _rxmod1_90e78de85eae102082dac9d0e66faf8227
-#define _rxord _rxmod1_90e78de85eae102082dac9d0e66faf8228
-#define __assignFuns2 _rxmod1_90e78de85eae102082dac9d0e66faf8229
-#define _llikCauchyDscale _rxmod1_90e78de85eae102082dac9d0e66faf8230
-#define _llikCauchyDlocation _rxmod1_90e78de85eae102082dac9d0e66faf8231
-#define _llikCauchy _rxmod1_90e78de85eae102082dac9d0e66faf8232
-#define _llikGammaDrate _rxmod1_90e78de85eae102082dac9d0e66faf8233
-#define _llikGammaDshape _rxmod1_90e78de85eae102082dac9d0e66faf8234
-#define _llikGamma _rxmod1_90e78de85eae102082dac9d0e66faf8235
-#define _llikWeibullDscale _rxmod1_90e78de85eae102082dac9d0e66faf8236
-#define _llikWeibullDshape _rxmod1_90e78de85eae102082dac9d0e66faf8237
-#define _llikWeibull _rxmod1_90e78de85eae102082dac9d0e66faf8238
-#define _llikUnifDbeta _rxmod1_90e78de85eae102082dac9d0e66faf8239
-#define _llikUnifDalpha _rxmod1_90e78de85eae102082dac9d0e66faf8240
-#define _llikUnif _rxmod1_90e78de85eae102082dac9d0e66faf8241
-#define _llikGeomDp _rxmod1_90e78de85eae102082dac9d0e66faf8242
-#define _llikGeom _rxmod1_90e78de85eae102082dac9d0e66faf8243
-#define _llikFDdf2 _rxmod1_90e78de85eae102082dac9d0e66faf8244
-#define _llikFDdf1 _rxmod1_90e78de85eae102082dac9d0e66faf8245
-#define _llikF _rxmod1_90e78de85eae102082dac9d0e66faf8246
-#define _llikExpDrate _rxmod1_90e78de85eae102082dac9d0e66faf8247
-#define _llikExp _rxmod1_90e78de85eae102082dac9d0e66faf8248
-#define _llikChisqDdf _rxmod1_90e78de85eae102082dac9d0e66faf8249
-#define _llikChisq _rxmod1_90e78de85eae102082dac9d0e66faf8250
-#define _llikTDsd _rxmod1_90e78de85eae102082dac9d0e66faf8251
-#define _llikTDmean _rxmod1_90e78de85eae102082dac9d0e66faf8252
-#define _llikTDdf _rxmod1_90e78de85eae102082dac9d0e66faf8253
-#define _llikT _rxmod1_90e78de85eae102082dac9d0e66faf8254
-#define _llikBetaDshape2 _rxmod1_90e78de85eae102082dac9d0e66faf8255
-#define _llikBetaDshape1 _rxmod1_90e78de85eae102082dac9d0e66faf8256
-#define _llikBeta _rxmod1_90e78de85eae102082dac9d0e66faf8257
-#define _llikNbinomMuDmu _rxmod1_90e78de85eae102082dac9d0e66faf8258
-#define _llikNbinomMu _rxmod1_90e78de85eae102082dac9d0e66faf8259
-#define _llikNbinomDprob _rxmod1_90e78de85eae102082dac9d0e66faf8260
-#define _llikNbinom _rxmod1_90e78de85eae102082dac9d0e66faf8261
-#define _llikBinomDprob _rxmod1_90e78de85eae102082dac9d0e66faf8262
-#define _llikBinom _rxmod1_90e78de85eae102082dac9d0e66faf8263
-#define _llikPoisDlambda _rxmod1_90e78de85eae102082dac9d0e66faf8264
-#define _llikPois _rxmod1_90e78de85eae102082dac9d0e66faf8265
-#define _llikNormDsd _rxmod1_90e78de85eae102082dac9d0e66faf8266
-#define _llikNormDmean _rxmod1_90e78de85eae102082dac9d0e66faf8267
-#define _llikNorm _rxmod1_90e78de85eae102082dac9d0e66faf8268
-#define simeps _rxmod1_90e78de85eae102082dac9d0e66faf8269
-#define simeta _rxmod1_90e78de85eae102082dac9d0e66faf8270
-#define expit _rxmod1_90e78de85eae102082dac9d0e66faf8271
-#define logit _rxmod1_90e78de85eae102082dac9d0e66faf8272
-#define gammapDer _rxmod1_90e78de85eae102082dac9d0e66faf8273
-#define lowergamma _rxmod1_90e78de85eae102082dac9d0e66faf8274
-#define uppergamma _rxmod1_90e78de85eae102082dac9d0e66faf8275
-#define gammaqInva _rxmod1_90e78de85eae102082dac9d0e66faf8276
-#define gammaqInv _rxmod1_90e78de85eae102082dac9d0e66faf8277
-#define gammapInva _rxmod1_90e78de85eae102082dac9d0e66faf8278
-#define gammapInv _rxmod1_90e78de85eae102082dac9d0e66faf8279
-#define gammaq _rxmod1_90e78de85eae102082dac9d0e66faf8280
-#define gammap _rxmod1_90e78de85eae102082dac9d0e66faf8281
-#define phi _rxmod1_90e78de85eae102082dac9d0e66faf8282
-#define riweibull _rxmod1_90e78de85eae102082dac9d0e66faf8283
-#define riunif _rxmod1_90e78de85eae102082dac9d0e66faf8284
-#define rit_ _rxmod1_90e78de85eae102082dac9d0e66faf8285
-#define ripois _rxmod1_90e78de85eae102082dac9d0e66faf8286
-#define ribeta _rxmod1_90e78de85eae102082dac9d0e66faf8287
-#define rigamma _rxmod1_90e78de85eae102082dac9d0e66faf8288
-#define rigeom _rxmod1_90e78de85eae102082dac9d0e66faf8289
-#define rif _rxmod1_90e78de85eae102082dac9d0e66faf8290
-#define riexp _rxmod1_90e78de85eae102082dac9d0e66faf8291
-#define richisq _rxmod1_90e78de85eae102082dac9d0e66faf8292
-#define ricauchy _rxmod1_90e78de85eae102082dac9d0e66faf8293
-#define rinbinomMu _rxmod1_90e78de85eae102082dac9d0e66faf8294
-#define rinbinom _rxmod1_90e78de85eae102082dac9d0e66faf8295
-#define ribinom _rxmod1_90e78de85eae102082dac9d0e66faf8296
-#define rinorm _rxmod1_90e78de85eae102082dac9d0e66faf8297
-#define rxweibull _rxmod1_90e78de85eae102082dac9d0e66faf8298
-#define rxunif _rxmod1_90e78de85eae102082dac9d0e66faf8299
-#define rxt_ _rxmod1_90e78de85eae102082dac9d0e66faf82100
-#define rxpois _rxmod1_90e78de85eae102082dac9d0e66faf82101
-#define rxbeta _rxmod1_90e78de85eae102082dac9d0e66faf82102
-#define rxgamma _rxmod1_90e78de85eae102082dac9d0e66faf82103
-#define rxgeom _rxmod1_90e78de85eae102082dac9d0e66faf82104
-#define rxf _rxmod1_90e78de85eae102082dac9d0e66faf82105
-#define rxexp _rxmod1_90e78de85eae102082dac9d0e66faf82106
-#define rxchisq _rxmod1_90e78de85eae102082dac9d0e66faf82107
-#define rxcauchy _rxmod1_90e78de85eae102082dac9d0e66faf82108
-#define rxnbinomMu _rxmod1_90e78de85eae102082dac9d0e66faf82109
-#define rxnbinom _rxmod1_90e78de85eae102082dac9d0e66faf82110
-#define rxbinom _rxmod1_90e78de85eae102082dac9d0e66faf82111
-#define rxnorm _rxmod1_90e78de85eae102082dac9d0e66faf82112
-#define linCmtC _rxmod1_90e78de85eae102082dac9d0e66faf82113
-#define linCmtB _rxmod1_90e78de85eae102082dac9d0e66faf82114
-#define linCmtA _rxmod1_90e78de85eae102082dac9d0e66faf82115
+#define _getRxSolve_ _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f10
+#define _evalUdf _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f11
+#define _solveData _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f12
+#define _assign_ptr _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f13
+#define _rxRmModelLib _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f14
+#define _rxGetModelLib _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f15
+#define _old_c _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f16
+#define _ptrid _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f17
+#define _rxIsCurrentC _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f18
+#define _sumPS _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f19
+#define _prodPS _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f110
+#define _prodType _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f111
+#define _sumType _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f112
+#define _update_par_ptr _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f113
+#define _getParCov _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f114
+#define _rxode2_rxAssignPtr _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f115
+#define _rxQr _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f116
+#define _compareFactorVal _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f117
+#define _sum _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f118
+#define _udf _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f119
+#define _sign _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f120
+#define _prod _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f121
+#define _max _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f122
+#define _min _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f123
+#define _transit4P _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f124
+#define _transit3P _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f125
+#define _assignFuns0 _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f126
+#define _assignFuns _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f127
+#define _rxord _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f128
+#define __assignFuns2 _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f129
+#define _llikCauchyDscale _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f130
+#define _llikCauchyDlocation _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f131
+#define _llikCauchy _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f132
+#define _llikGammaDrate _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f133
+#define _llikGammaDshape _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f134
+#define _llikGamma _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f135
+#define _llikWeibullDscale _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f136
+#define _llikWeibullDshape _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f137
+#define _llikWeibull _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f138
+#define _llikUnifDbeta _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f139
+#define _llikUnifDalpha _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f140
+#define _llikUnif _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f141
+#define _llikGeomDp _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f142
+#define _llikGeom _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f143
+#define _llikFDdf2 _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f144
+#define _llikFDdf1 _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f145
+#define _llikF _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f146
+#define _llikExpDrate _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f147
+#define _llikExp _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f148
+#define _llikChisqDdf _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f149
+#define _llikChisq _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f150
+#define _llikTDsd _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f151
+#define _llikTDmean _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f152
+#define _llikTDdf _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f153
+#define _llikT _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f154
+#define _llikBetaDshape2 _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f155
+#define _llikBetaDshape1 _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f156
+#define _llikBeta _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f157
+#define _llikNbinomMuDmu _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f158
+#define _llikNbinomMu _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f159
+#define _llikNbinomDprob _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f160
+#define _llikNbinom _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f161
+#define _llikBinomDprob _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f162
+#define _llikBinom _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f163
+#define _llikPoisDlambda _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f164
+#define _llikPois _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f165
+#define _llikNormDsd _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f166
+#define _llikNormDmean _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f167
+#define _llikNorm _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f168
+#define simeps _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f169
+#define simeta _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f170
+#define expit _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f171
+#define logit _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f172
+#define gammapDer _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f173
+#define lowergamma _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f174
+#define uppergamma _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f175
+#define gammaqInva _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f176
+#define gammaqInv _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f177
+#define gammapInva _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f178
+#define gammapInv _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f179
+#define gammaq _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f180
+#define gammap _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f181
+#define phi _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f182
+#define riweibull _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f183
+#define riunif _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f184
+#define rit_ _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f185
+#define ripois _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f186
+#define ribeta _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f187
+#define rigamma _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f188
+#define rigeom _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f189
+#define rif _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f190
+#define riexp _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f191
+#define richisq _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f192
+#define ricauchy _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f193
+#define rinbinomMu _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f194
+#define rinbinom _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f195
+#define ribinom _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f196
+#define rinorm _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f197
+#define rxweibull _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f198
+#define rxunif _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f199
+#define rxt_ _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f1100
+#define rxpois _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f1101
+#define rxbeta _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f1102
+#define rxgamma _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f1103
+#define rxgeom _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f1104
+#define rxf _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f1105
+#define rxexp _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f1106
+#define rxchisq _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f1107
+#define rxcauchy _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f1108
+#define rxnbinomMu _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f1109
+#define rxnbinom _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f1110
+#define rxbinom _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f1111
+#define rxnorm _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f1112
+#define linCmtC _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f1113
+#define linCmtB _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f1114
+#define linCmtA _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f1115
#include
#define __MAX_PROD__ 0
#define _CMT CMT
@@ -684,9 +684,9 @@ extern SEXP mod1__model_vars(void){
SEXP _mv = PROTECT(_rxGetModelLib("mod1__model_vars"));pro++;
if (!_rxIsCurrentC(_mv)){
SEXP hash = PROTECT(allocVector(STRSXP, 1));pro++;
-#define __doBuf__ snprintf(buf, __doBufN__, "un]\"BAAA@QRtHACAAAAAAAY4zAAAv7#aT)CYk)MA==)a=W6xYB~1\"d|dB8o!;OnqKS@vXmkM/z7;*5%%*xp\"jec/578;vzk;OKH>XwJvmY\?a$`6:BS%%}aIXu!3tJt.A{CQ$jQwahw7dv;Ix)T_nf}I289xCIs\?N|;Uf{T+2k@+TT33s,I;LT[`4xdcs$XG=LaczKj/wZM2Nk3#f3a+Un!3z&Qq*|pVMO<^!Nl_+lj%%#W5*F}VoWc[^uBPlf)ocbDBmOU\"NmgT*1gp{q~o8Ff9|3d9~I99/Pt^EB)0P[9Mj9EO:MbIJ\"V1^kV*o]\?y1QJ4;9^V7v_52`mLpgeiO(is$p|(kQ=Cc(o{fflFPA6>jeFDMjH(@R73umRXk|,EkRTf!LBeGFR<7zV\"C95/bcLX2zd;*Rv&tbyK2IE]):w+VrF@oK5`sQt{r(@O1[$[CGU(*ZUJ4ZHAf7a!:u]qcUzFz%%%%Q_PE!vjci.>WWzQ>9b|wT\?*7FNA\?68.n2sG)YwMaOwzr6(!MHtl=Ja~jL");
- char buf[1056];
-#define __doBufN__ 1056
+#define __doBuf__ snprintf(buf, __doBufN__, "un]\"BAAA@QRtHACAAAAAAA6yzAAAv7#aT)^X\"&MAI<)agtVwYBaiiq@C2k[@I!7tc/r+VBI5mtRsmxuUu_%%x^gWz,0^AqZCeX/%%.hJt,A_CD,iw!LwDYJCje~*#TZ!$0>FFig!^t_uR&PgqW=\"s:>JW5>BTr;wk4A$r4:k2qg1}$^8[s$/*yk*JbCP60t^//j#VHiU:@ke\?Sp^KC}rlhn2@*}):>$FcNHjp7i<[BztU;aO3Z1/$aM`Ap1NzhggmRY\"1rH44itnvA2AF}gSX.Iq&f>LPMO@!!!xl;Vy65K!DiugR^$T5g.*_Kx^J@WALopypF!Qw\?K*PlFTr5@E6cZ7ez8bFjK+wxibE]^U,.,QQ$dpf~GM]Aw`I>O#U\"X^jn7xp#(x*+zKOMi/R[CLbRK%%+E\"NOhj5NXJ\?#TpE]Kn,ZMB]1wl=gt~J+%%$td$&y2jnQ96*>VzE9W:&\?DVlplF)26ZS}gY#0$$eNeiN(BG@>#},nG+{i[D&z$ptq^oc[@1!},fB)o$}JkZ42hXo=Z/6qgh<@*o&G~ZnPae#A{pk%%6NvHm)q,qdaUbeM*+7x_*/Y0Y,+&tEN\?ZVt\"J*+*YxJ$k$c$+26%%ob2\?I\?qXh]>R73umRXk|,EkRTf!LBeGFR<7zV\"C95/bcLX2zd;*Hv&tbyK27D]):w8^;zn.s(w=3lsBu#uZ{;5o@>ZP86_$/K79<9zscZVoDA%%u~P2ON4]KTa2l0[#m9]O7L[6i9qp~9\"CtLNgrVA#C,NMu[j51lt.M>rF@oK5`sQt{r(@O1[$[CGU(*ZUJ4ZHAf7a!:u]qcUzFz%%%%Q_PE!vjci.>WWzQ>9b|wT\?*7FNA\?68.n2sG)YwMaOwzr6(!MHu]}g4Hf");
+ char buf[1059];
+#define __doBufN__ 1059
__doBuf__
#undef __doBuf__
#undef __doBufN__
diff --git a/reference/myapp/mod1.d/mod1_.o b/reference/myapp/mod1.d/mod1_.o
index d9ba81804..2b2b9dfad 100644
Binary files a/reference/myapp/mod1.d/mod1_.o and b/reference/myapp/mod1.d/mod1_.o differ
diff --git a/reference/myapp/mod1.d/mod1_.so b/reference/myapp/mod1.d/mod1_.so
index ea6416b85..94758fc39 100755
Binary files a/reference/myapp/mod1.d/mod1_.so and b/reference/myapp/mod1.d/mod1_.so differ
diff --git a/reference/myapp/rx_shiny_data.rda b/reference/myapp/rx_shiny_data.rda
index 5214e22ee..a378af35e 100644
Binary files a/reference/myapp/rx_shiny_data.rda and b/reference/myapp/rx_shiny_data.rda differ
diff --git a/reference/rxCombineErrorLines.html b/reference/rxCombineErrorLines.html
index ccedcf0a4..5c6471685 100644
--- a/reference/rxCombineErrorLines.html
+++ b/reference/rxCombineErrorLines.html
@@ -383,7 +383,7 @@ Examples#>
#>
#> using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’
-#> rxode2 2.1.1.9000 model named rx_ffb5b3afd66c33175c304e3aaae51091 model (✔ ready).
+#> rxode2 2.1.1.9000 model named rx_50de6acd63214183c70f26383fc904b0 model (✔ ready).
#> $state: depot, gut, center, effect
#> $stateExtra: cp
#> $params: tktr, tka, tcl, tv, prop.err, pkadd.err, temax, tec50, tkout, te0, pdadd.err, eta.ktr, eta.ka, eta.cl, eta.v, eta.emax, eta.ec50, eta.kout, eta.e0, CMT, rxerr.cp, rxerr.effect
diff --git a/reference/rxExpandGrid.html b/reference/rxExpandGrid.html
index f12157c74..f726192b1 100644
--- a/reference/rxExpandGrid.html
+++ b/reference/rxExpandGrid.html
@@ -859,12 +859,12 @@ Examples# \donttest{
microbenchmark::microbenchmark(rxExpandGrid(letters, letters), expand.grid.jc(letters, letters))
#> Unit: microseconds
-#> expr min lq mean median uq
-#> rxExpandGrid(letters, letters) 11.511 12.6785 26.31728 13.5700 14.682
-#> expand.grid.jc(letters, letters) 15.269 17.2970 125.37047 18.4345 20.318
+#> expr min lq mean median uq
+#> rxExpandGrid(letters, letters) 12.533 14.7425 38.56275 17.4275 23.0235
+#> expand.grid.jc(letters, letters) 16.050 19.4310 171.23374 22.9025 31.9695
#> max neval
-#> 1267.291 100
-#> 5441.729 100
+#> 2010.680 100
+#> 6944.552 100
# }
diff --git a/reference/rxbeta.html b/reference/rxbeta.html
index 3dc37738f..87d9b4c18 100644
--- a/reference/rxbeta.html
+++ b/reference/rxbeta.html
@@ -202,8 +202,8 @@ Examples#> [1] 0.7852473 0.4552276 0.9643407 0.7309750 0.9217035 0.4459162 0.9446204
#> [8] 0.7547216 0.6014439 0.9971971
rxbeta(5, 1, n = 10, ncores = 2) # You can parallelize the simulation using openMP
-#> [1] 0.9863230 0.9691479 0.9796321 0.9713815 0.9617760 0.6733853 0.6034338
-#> [8] 0.7713400 0.6270114 0.7109119
+#> [1] 0.9863230 0.6787542 0.9691479 0.9634618 0.9796321 0.6733853 0.9617760
+#> [8] 0.7713400 0.6034338 0.7109119
rxbeta(1, 3)
#> [1] 0.2516317
diff --git a/search.json b/search.json
index 6d2253963..1f2b7f334 100644
--- a/search.json
+++ b/search.json
@@ -1 +1 @@
-[{"path":"https://nlmixr2.github.io/rxode2/articles/Integrating-User-Defined-Functions-into-rxode2.html","id":"user-defined-functions","dir":"Articles","previous_headings":"","what":"User Defined Functions","title":"Integrating User Defined Functions into rxode2","text":"defining models may wished write small R function make function integrate rxode2 somehow. article discusses 2 ways : R-based user function can loaded simple function certain circumstances translated C run efficiently C function define integrate code","code":"library(rxode2) #> rxode2 2.1.1.9000 using 2 threads (see ?getRxThreads) #> no cache: create with `rxCreateCache()`"},{"path":"https://nlmixr2.github.io/rxode2/articles/Integrating-User-Defined-Functions-into-rxode2.html","id":"r-based-user-functions","dir":"Articles","previous_headings":"","what":"R based user functions","title":"Integrating User Defined Functions into rxode2","text":"R-based user function convenient include ODE, slower done written C , C++ compiled language. requested github appropriate example; However, use simple example simply illustrate concepts. Now ODE compiled R functions called solving ODE. Since calling R, forces parallization turned since R single-threaded. also takes time solve since shuttling back forth R C. Lets see simple function performs: terribly bad, even though shuffling R C. can make better converting functions C: C version almost twice fast R version. may noticed conversion also created C versions first derivative. done automatically gives just C versions function, C versions derivatives registers rxode2. allows C versions work rxode2 nlmixr2 models. function setup advance allow type conversion. general derivatives calculated return() statement user defined function. means simply let R return last value instead explictly calling return(). Many people prefer method coding. Even return function, function converted C. github issue, used function convert derivatives: still helpful functions early returns, nlmixr2 models requiring derivatives calculated non-optimized finite differences occurs. gets internals rxode2 nlmixr2 can see easily calculating derivatives: Whereas originally defined function newAbs() use new derivatives calculated well: circumstances, conversion C possible, though can still use R function. requirements R functions integrated rxode2 system: function must set number arguments, variable arguments like f(…) currently allowed. function given argument single number, function return single number requirements met can use R function rxode2. Additional requirements conversion C include: functions use within R function must understood available rxode2. Practically speaking fun2() refers fun1(), fun1() must changed C code available rxode2 changing function fun2() C. functions can include /else assignments simple return statements (either returning value value line ). Special R control structures functions (like lapply) present. function refer package functions mentioned, return() statement present, derivative C functions rxode2’s derivative table updated.","code":"newAbs <- function(x) { if (x < 0) { -x } else { x } } f <- rxode2({ a <- newAbs(time) }) #> using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’ e <- et(-10, 10, length.out=40) mb1 <- microbenchmark::microbenchmark(withoutC=suppressWarnings(rxSolve(f,e))) library(ggplot2) autoplot(mb1) + rxTheme() # Create C functions automatically with `rxFun()` rxFun(newAbs) #> → finding duplicate expressions in d(newAbs)/d(x)... #> [====|====|====|====|====|====|====|====|====|====] 0:00:00 #> → optimizing duplicate expressions in d(newAbs)/d(x)... #> [====|====|====|====|====|====|====|====|====|====] 0:00:00 #> converted R function 'newAbs' to C (will now use in rxode2) #> converted R function 'rx_newAbs_d_x' to C (will now use in rxode2) #> Added derivative table for 'newAbs' # Recompile to use the C functions # Note it would recompile anyway if you didn't do this step, # it just makes sure that it doesn't recompile every step in # the benchmark f <- rxode2({ a <- newAbs(time) }) #> using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’ mb2 <- microbenchmark::microbenchmark(withC=rxSolve(f,e, cores=1)) mb <- rbind(mb1, mb2) autoplot(mb) + rxTheme() + xgxr::xgx_scale_y_log10() #> Scale for y is already present. #> Adding another scale for y, which will replace the existing scale. print(mb) #> Unit: milliseconds #> expr min lq mean median uq max neval #> withoutC 7.754378 8.111007 8.768889 8.302625 8.536936 14.293111 100 #> withC 2.065438 2.156628 2.514262 2.288734 2.795845 6.822972 100 # Light f_R <- function(actRad, k_0, a_k) { photfac <- a_k * actRad + k_0 if (photfac > 1) { photfac = 1 } return(photfac) } rxFun(f_R) #> function contains return statement; derivatives not calculated #> converted R function 'f_R' to C (will now use in rxode2) rxFromSE(\"Derivative(f_R(actRad, k_0, a_k),k_0)\") #> [1] \"(f_R(actRad,(k_0)+6.05545445239334e-06,a_k)-f_R(actRad,k_0,a_k))/6.05545445239334e-06\" rxFromSE(\"Derivative(newAbs(x),x)\") #> [1] \"rx_newAbs_d_x(x)\""},{"path":"https://nlmixr2.github.io/rxode2/articles/Integrating-User-Defined-Functions-into-rxode2.html","id":"c-based-functions","dir":"Articles","previous_headings":"","what":"C based functions","title":"Integrating User Defined Functions into rxode2","text":"can add C functions directly rxode2 well using rxFun(): wanted also use C functions expressions derivatives using rxD() function: Removing function rxRmFun() also remove derivative table:","code":"fun <- \" double fun(double a, double b, double c) { return a*a+b*a+c; } \" ## C-code for function rxFun(\"fun\", c(\"a\", \"b\", \"c\"), fun) rxD(\"fun\", list( function(a, b, c) { # derivative of arg1: a paste0(\"2*\", a, \"+\", b) }, function(a, b, c) { # derivative of arg2: b return(a) }, function(a, b, c) { # derivative of arg3: c return(\"0.0\") } )) rxRmFun(\"fun\")"},{"path":"https://nlmixr2.github.io/rxode2/articles/Modifying-Models.html","id":"modifying-model","dir":"Articles","previous_headings":"","what":"Modifying model","title":"Modifying Models","text":"tasks might want overall model: Change line model Add line model Rename parameters model Combine different models Create functions add certain model features model go model piping functions can use modify models even add functions modify models. cover model modification functions nlmixr2lib","code":""},{"path":"https://nlmixr2.github.io/rxode2/articles/Modifying-Models.html","id":"modifying-a-model-line","dir":"Articles","previous_headings":"Modifying model","what":"Modifying a model line","title":"Modifying Models","text":"opinion, modifying lines model likely common task modifying model. may wish modify model subject variability add covariate effects. begin course need base model modify. Let’s start simple PK example, using single-dose theophylline dataset generously provided Dr. Robert . Upton University California, San Francisco: believed enough absorption support subject variability can change line drop subject modifying single line. simply type line want model piping expression: expected, line modified. Also can notice initial estimate subject variability dropped since longer part model. reason wanted add back model can modify model add back: modification, eta.ka automatically assumed subject variability parameter. Also since eta.ka mu-referenced rxode2 points . automatic detection eta.ka name follows convention. Parameters starting ending following names assumed subject variability parameters: eta (NONMEM convention) ppv (per patient variability) psv (per subject variability) iiv (inter-individual variability) bsv (subject variability) bpv (patient variability) functioning correctly can change covariate can add type initial estimate later: seen , eta.ka model assumed data-input parameter covariate instead estimated parameter. can also note WT automatically recognized covariate covWt automatically recognized covariate parameter. general covariates typical/population parameters automatically converted estimated parameters based parameter name starting (ending ): tv (typical value) t (also typical value) pop (population parameter) err (error parameter) eff (effect parameter) cov (covariate parameters) notable exceptions parameters like (wt, sex crcl) assumed covariates. don’t want automatic variable conversion, can also use auto=FALSE: case additional parameters (eta.ka, WT, covWt) assumed parameters dataset.","code":"one.compartment <- function() { ini({ tka <- 0.45; label(\"Ka\") tcl <- 1; label(\"Cl\") tv <- 3.45; label(\"V\") eta.ka ~ 0.6 eta.cl ~ 0.3 eta.v ~ 0.1 add.sd <- 0.7 }) model({ ka <- exp(tka + eta.ka) cl <- exp(tcl + eta.cl) v <- exp(tv + eta.v) d/dt(depot) = -ka * depot d/dt(center) = ka * depot - cl / v * center cp = center / v cp ~ add(add.sd) }) } mod <- one.compartment |> model(ka <- exp(tka)) #> ! remove between subject variability `eta.ka` print(mod) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd #> 0.45 1.00 3.45 0.70 #> #> Omega ($omega): #> eta.cl eta.v #> eta.cl 0.3 0.0 #> eta.v 0.0 0.1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 tcl eta.cl id #> 2 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- 0.45 #> label(\"Ka\") #> tcl <- 1 #> label(\"Cl\") #> tv <- 3.45 #> label(\"V\") #> add.sd <- c(0, 0.7) #> eta.cl ~ 0.3 #> eta.v ~ 0.1 #> }) #> model({ #> ka <- exp(tka) #> cl <- exp(tcl + eta.cl) #> v <- exp(tv + eta.v) #> d/dt(depot) = -ka * depot #> d/dt(center) = ka * depot - cl/v * center #> cp = center/v #> cp ~ add(add.sd) #> }) #> } mod2 <- mod |> model(ka <- tka * exp(eta.ka)) #> ℹ add between subject variability `eta.ka` and set estimate to 1 print(mod2) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd #> 0.45 1.00 3.45 0.70 #> #> Omega ($omega): #> eta.cl eta.v eta.ka #> eta.cl 0.3 0.0 0 #> eta.v 0.0 0.1 0 #> eta.ka 0.0 0.0 1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 tcl eta.cl id #> 2 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- 0.45 #> label(\"Ka\") #> tcl <- 1 #> label(\"Cl\") #> tv <- 3.45 #> label(\"V\") #> add.sd <- c(0, 0.7) #> eta.cl ~ 0.3 #> eta.v ~ 0.1 #> eta.ka ~ 1 #> }) #> model({ #> ka <- tka * exp(eta.ka) #> cl <- exp(tcl + eta.cl) #> v <- exp(tv + eta.v) #> d/dt(depot) = -ka * depot #> d/dt(center) = ka * depot - cl/v * center #> cp = center/v #> cp ~ add(add.sd) #> }) #> } mod2 <- mod |> model(ka <- tka * exp(eta.ka) + WT * covWt, cov=\"eta.ka\") #> ℹ add covariate `eta.ka` (as requested by cov option) #> ℹ add covariate `WT` #> ℹ add population parameter `covWt` and set estimate to 1 print(mod2) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd covWt #> 0.45 1.00 3.45 0.70 1.00 #> #> Omega ($omega): #> eta.cl eta.v #> eta.cl 0.3 0.0 #> eta.v 0.0 0.1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level covariates #> 1 tcl eta.cl id #> 2 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- 0.45 #> label(\"Ka\") #> tcl <- 1 #> label(\"Cl\") #> tv <- 3.45 #> label(\"V\") #> add.sd <- c(0, 0.7) #> covWt <- 1 #> eta.cl ~ 0.3 #> eta.v ~ 0.1 #> }) #> model({ #> ka <- tka * exp(eta.ka) + WT * covWt #> cl <- exp(tcl + eta.cl) #> v <- exp(tv + eta.v) #> d/dt(depot) = -ka * depot #> d/dt(center) = ka * depot - cl/v * center #> cp = center/v #> cp ~ add(add.sd) #> }) #> } mod3 <- mod |> model(ka <- tka * exp(eta.ka) + WT * covWt, auto=FALSE) #> ℹ add covariate `eta.ka` #> ℹ add covariate `WT` #> ℹ add covariate `covWt` print(mod3) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd #> 0.45 1.00 3.45 0.70 #> #> Omega ($omega): #> eta.cl eta.v #> eta.cl 0.3 0.0 #> eta.v 0.0 0.1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level covariates #> 1 tcl eta.cl id #> 2 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- 0.45 #> label(\"Ka\") #> tcl <- 1 #> label(\"Cl\") #> tv <- 3.45 #> label(\"V\") #> add.sd <- c(0, 0.7) #> eta.cl ~ 0.3 #> eta.v ~ 0.1 #> }) #> model({ #> ka <- tka * exp(eta.ka) + WT * covWt #> cl <- exp(tcl + eta.cl) #> v <- exp(tv + eta.v) #> d/dt(depot) = -ka * depot #> d/dt(center) = ka * depot - cl/v * center #> cp = center/v #> cp ~ add(add.sd) #> }) #> }"},{"path":"https://nlmixr2.github.io/rxode2/articles/Modifying-Models.html","id":"note-on-automatic-detection-of-variables","dir":"Articles","previous_headings":"Modifying model","what":"Note on automatic detection of variables","title":"Modifying Models","text":"automatic detection variables convenient many models may suit style; like can always change using options(): option disabled, variables assumed covariates promote population parameters ini block last example option enabled none variables starting t added model course use turn back : can use withr::with_options(list(rxode2.autoVarPiping=FALSE), ...) turn option temporarily. don’t like defaults changing variables change well rxSetPipingAuto() example wanted variables starting ending te can change : requested population parameters starting te added ini block. want reset defaults simply call rxSetPipingAuto() without arguments:","code":"options(rxode2.autoVarPiping=FALSE) mod7 <- mod3 |> model({ emax <- exp(temax) e0 <- exp(te0 + eta.e0) ec50 <- exp(tec50) kin <- exp(tkin) kout <- exp(tkout) }, append=FALSE) print(mod7) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd #> 0.45 1.00 3.45 0.70 #> #> Omega ($omega): #> eta.cl eta.v #> eta.cl 0.3 0.0 #> eta.v 0.0 0.1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level covariates #> 1 tcl eta.cl id #> 2 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- 0.45 #> label(\"Ka\") #> tcl <- 1 #> label(\"Cl\") #> tv <- 3.45 #> label(\"V\") #> add.sd <- c(0, 0.7) #> eta.cl ~ 0.3 #> eta.v ~ 0.1 #> }) #> model({ #> emax <- exp(temax) #> e0 <- exp(te0 + eta.e0) #> ec50 <- exp(tec50) #> kin <- exp(tkin) #> kout <- exp(tkout) #> ka <- tka * exp(eta.ka) + WT * covWt #> cl <- exp(tcl + eta.cl) #> v <- exp(tv + eta.v) #> d/dt(depot) = -ka * depot #> d/dt(center) = ka * depot - cl/v * center #> cp = center/v #> cp ~ add(add.sd) #> }) #> } options(rxode2.autoVarPiping=TRUE) mod8 <- mod |> model({ emax <- exp(temax) e0 <- exp(te0 + eta.e0) ec50 <- exp(tec50) kin <- exp(tkin) kout <- exp(tkout) }, append=FALSE) #> ℹ promote `temax` to population parameter with initial estimate 1 #> ℹ promote `te0` to population parameter with initial estimate 1 #> ℹ promote `eta.e0` to between subject variability with initial estimate 1 #> ℹ promote `tec50` to population parameter with initial estimate 1 #> ℹ promote `tkin` to population parameter with initial estimate 1 #> ℹ promote `tkout` to population parameter with initial estimate 1 print(mod8) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd temax te0 tec50 tkin tkout #> 0.45 1.00 3.45 0.70 1.00 1.00 1.00 1.00 1.00 #> #> Omega ($omega): #> eta.cl eta.v eta.e0 #> eta.cl 0.3 0.0 0 #> eta.v 0.0 0.1 0 #> eta.e0 0.0 0.0 1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 te0 eta.e0 id #> 2 tcl eta.cl id #> 3 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- 0.45 #> label(\"Ka\") #> tcl <- 1 #> label(\"Cl\") #> tv <- 3.45 #> label(\"V\") #> add.sd <- c(0, 0.7) #> temax <- 1 #> te0 <- 1 #> tec50 <- 1 #> tkin <- 1 #> tkout <- 1 #> eta.cl ~ 0.3 #> eta.v ~ 0.1 #> eta.e0 ~ 1 #> }) #> model({ #> emax <- exp(temax) #> e0 <- exp(te0 + eta.e0) #> ec50 <- exp(tec50) #> kin <- exp(tkin) #> kout <- exp(tkout) #> ka <- exp(tka) #> cl <- exp(tcl + eta.cl) #> v <- exp(tv + eta.v) #> d/dt(depot) = -ka * depot #> d/dt(center) = ka * depot - cl/v * center #> cp = center/v #> cp ~ add(add.sd) #> }) #> } rxSetPipingAuto(thetamodelVars = rex::rex(\"te\")) mod9 <- mod |> model({ emax <- exp(temax) e0 <- exp(te0 + eta.e0) ec50 <- exp(tec50) kin <- exp(tkin) kout <- exp(tkout) }, append=FALSE) #> ℹ promote `temax` to population parameter with initial estimate 1 #> ℹ promote `te0` to population parameter with initial estimate 1 #> ℹ promote `eta.e0` to between subject variability with initial estimate 1 #> ℹ promote `tec50` to population parameter with initial estimate 1 print(mod9) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd temax te0 tec50 #> 0.45 1.00 3.45 0.70 1.00 1.00 1.00 #> #> Omega ($omega): #> eta.cl eta.v eta.e0 #> eta.cl 0.3 0.0 0 #> eta.v 0.0 0.1 0 #> eta.e0 0.0 0.0 1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 te0 eta.e0 id #> 2 tcl eta.cl id #> 3 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- 0.45 #> label(\"Ka\") #> tcl <- 1 #> label(\"Cl\") #> tv <- 3.45 #> label(\"V\") #> add.sd <- c(0, 0.7) #> temax <- 1 #> te0 <- 1 #> tec50 <- 1 #> eta.cl ~ 0.3 #> eta.v ~ 0.1 #> eta.e0 ~ 1 #> }) #> model({ #> emax <- exp(temax) #> e0 <- exp(te0 + eta.e0) #> ec50 <- exp(tec50) #> kin <- exp(tkin) #> kout <- exp(tkout) #> ka <- exp(tka) #> cl <- exp(tcl + eta.cl) #> v <- exp(tv + eta.v) #> d/dt(depot) = -ka * depot #> d/dt(center) = ka * depot - cl/v * center #> cp = center/v #> cp ~ add(add.sd) #> }) #> } rxSetPipingAuto() mod10 <- mod |> model({ emax <- exp(temax) e0 <- exp(te0 + eta.e0) ec50 <- exp(tec50) kin <- exp(tkin) kout <- exp(tkout) }, append=FALSE) #> ℹ promote `temax` to population parameter with initial estimate 1 #> ℹ promote `te0` to population parameter with initial estimate 1 #> ℹ promote `eta.e0` to between subject variability with initial estimate 1 #> ℹ promote `tec50` to population parameter with initial estimate 1 #> ℹ promote `tkin` to population parameter with initial estimate 1 #> ℹ promote `tkout` to population parameter with initial estimate 1"},{"path":"https://nlmixr2.github.io/rxode2/articles/Modifying-Models.html","id":"adding-model-lines","dir":"Articles","previous_headings":"Modifying model","what":"Adding model lines","title":"Modifying Models","text":"three ways insert lines rxode2/nlmixr2 model. can add lines end model, expression beginning model controlled append option. Let’s assume two different assays run compound noticed different variability. can modify model adding lines end model using append=TRUE: Perhaps instead may want add indirect response model addition concentrations, can choose add : append=lhsVar lhsVar left handed variable want insert new lines: last type insertion may wish add lines beginning model using append=FALSE:","code":"mod4 <- mod |> model({ cp2 <- cp cp2 ~ lnorm(lnorm.sd) }, append=TRUE) #> ℹ add residual parameter `lnorm.sd` and set estimate to 1 print(mod4) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd lnorm.sd #> 0.45 1.00 3.45 0.70 1.00 #> #> Omega ($omega): #> eta.cl eta.v #> eta.cl 0.3 0.0 #> eta.v 0.0 0.1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── Multiple Endpoint Model ($multipleEndpoint): ── #> variable cmt dvid* #> 1 cp ~ … cmt='cp' or cmt=3 dvid='cp' or dvid=1 #> 2 cp2 ~ … cmt='cp2' or cmt=4 dvid='cp2' 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 #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- 0.45 #> label(\"Ka\") #> tcl <- 1 #> label(\"Cl\") #> tv <- 3.45 #> label(\"V\") #> add.sd <- c(0, 0.7) #> lnorm.sd <- c(0, 1) #> eta.cl ~ 0.3 #> eta.v ~ 0.1 #> }) #> model({ #> ka <- exp(tka) #> cl <- exp(tcl + eta.cl) #> v <- exp(tv + eta.v) #> d/dt(depot) = -ka * depot #> d/dt(center) = ka * depot - cl/v * center #> cp = center/v #> cp ~ add(add.sd) #> cp2 <- cp #> cp2 ~ lnorm(lnorm.sd) #> }) #> } mod5 <- mod |> model({ PD <- 1-emax*cp/(ec50+cp) ## effect(0) <- e0 kin <- e0*kout d/dt(effect) <- kin*PD -kout*effect }, append=d/dt(center)) mod6 <- mod5 |> model({ emax <- exp(temax) e0 <- exp(te0 + eta.e0) ec50 <- exp(tec50) kin <- exp(tkin) kout <- exp(tkout) }, append=FALSE) #> ℹ promote `temax` to population parameter with initial estimate 1 #> ℹ promote `te0` to population parameter with initial estimate 1 #> ℹ promote `eta.e0` to between subject variability with initial estimate 1 #> ℹ promote `tec50` to population parameter with initial estimate 1 #> ℹ promote `tkin` to population parameter with initial estimate 1 #> ℹ promote `tkout` to population parameter with initial estimate 1 print(mod6) #> ── rxode2-based free-form 3-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd temax te0 tec50 tkin tkout #> 0.45 1.00 3.45 0.70 1.00 1.00 1.00 1.00 1.00 #> #> Omega ($omega): #> eta.cl eta.v eta.e0 #> eta.cl 0.3 0.0 0 #> eta.v 0.0 0.1 0 #> eta.e0 0.0 0.0 1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> 3 3 effect #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 te0 eta.e0 id #> 2 tcl eta.cl id #> 3 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- 0.45 #> label(\"Ka\") #> tcl <- 1 #> label(\"Cl\") #> tv <- 3.45 #> label(\"V\") #> add.sd <- c(0, 0.7) #> temax <- 1 #> te0 <- 1 #> tec50 <- 1 #> tkin <- 1 #> tkout <- 1 #> eta.cl ~ 0.3 #> eta.v ~ 0.1 #> eta.e0 ~ 1 #> }) #> model({ #> emax <- exp(temax) #> e0 <- exp(te0 + eta.e0) #> ec50 <- exp(tec50) #> kin <- exp(tkin) #> kout <- exp(tkout) #> ka <- exp(tka) #> cl <- exp(tcl + eta.cl) #> v <- exp(tv + eta.v) #> d/dt(depot) = -ka * depot #> d/dt(center) = ka * depot - cl/v * center #> PD <- 1 - emax * cp/(ec50 + cp) #> effect(0) <- e0 #> kin <- e0 * kout #> d/dt(effect) <- kin * PD - kout * effect #> cp = center/v #> cp ~ add(add.sd) #> }) #> }"},{"path":"https://nlmixr2.github.io/rxode2/articles/Modifying-Models.html","id":"remove-lines-in-the-model","dir":"Articles","previous_headings":"Modifying model","what":"Remove lines in the model","title":"Modifying Models","text":"lines model can removed one 2 ways either use -param param <- NULL model piping:","code":"mod7 <- mod6 |> model(-emax) #> ! remove population parameter `temax` print(mod7) #> ── rxode2-based free-form 3-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd te0 tec50 tkin tkout #> 0.45 1.00 3.45 0.70 1.00 1.00 1.00 1.00 #> #> Omega ($omega): #> eta.cl eta.v eta.e0 #> eta.cl 0.3 0.0 0 #> eta.v 0.0 0.1 0 #> eta.e0 0.0 0.0 1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> 3 3 effect #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 te0 eta.e0 id #> 2 tcl eta.cl id #> 3 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- 0.45 #> label(\"Ka\") #> tcl <- 1 #> label(\"Cl\") #> tv <- 3.45 #> label(\"V\") #> add.sd <- c(0, 0.7) #> te0 <- 1 #> tec50 <- 1 #> tkin <- 1 #> tkout <- 1 #> eta.cl ~ 0.3 #> eta.v ~ 0.1 #> eta.e0 ~ 1 #> }) #> model({ #> e0 <- exp(te0 + eta.e0) #> ec50 <- exp(tec50) #> kin <- exp(tkin) #> kout <- exp(tkout) #> ka <- exp(tka) #> cl <- exp(tcl + eta.cl) #> v <- exp(tv + eta.v) #> d/dt(depot) = -ka * depot #> d/dt(center) = ka * depot - cl/v * center #> PD <- 1 - emax * cp/(ec50 + cp) #> effect(0) <- e0 #> kin <- e0 * kout #> d/dt(effect) <- kin * PD - kout * effect #> cp = center/v #> cp ~ add(add.sd) #> }) #> } # Equivalently mod8 <- mod6 |> model(emax <- NULL) #> ! remove population parameter `temax` print(mod8) #> ── rxode2-based free-form 3-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd te0 tec50 tkin tkout #> 0.45 1.00 3.45 0.70 1.00 1.00 1.00 1.00 #> #> Omega ($omega): #> eta.cl eta.v eta.e0 #> eta.cl 0.3 0.0 0 #> eta.v 0.0 0.1 0 #> eta.e0 0.0 0.0 1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> 3 3 effect #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 te0 eta.e0 id #> 2 tcl eta.cl id #> 3 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- 0.45 #> label(\"Ka\") #> tcl <- 1 #> label(\"Cl\") #> tv <- 3.45 #> label(\"V\") #> add.sd <- c(0, 0.7) #> te0 <- 1 #> tec50 <- 1 #> tkin <- 1 #> tkout <- 1 #> eta.cl ~ 0.3 #> eta.v ~ 0.1 #> eta.e0 ~ 1 #> }) #> model({ #> e0 <- exp(te0 + eta.e0) #> ec50 <- exp(tec50) #> kin <- exp(tkin) #> kout <- exp(tkout) #> ka <- exp(tka) #> cl <- exp(tcl + eta.cl) #> v <- exp(tv + eta.v) #> d/dt(depot) = -ka * depot #> d/dt(center) = ka * depot - cl/v * center #> PD <- 1 - emax * cp/(ec50 + cp) #> effect(0) <- e0 #> kin <- e0 * kout #> d/dt(effect) <- kin * PD - kout * effect #> cp = center/v #> cp ~ add(add.sd) #> }) #> }"},{"path":"https://nlmixr2.github.io/rxode2/articles/Modifying-Models.html","id":"rename-parameters-in-a-model","dir":"Articles","previous_headings":"Modifying model","what":"Rename parameters in a model","title":"Modifying Models","text":"may want rename parameters model, easy rxRename(). dplyr loaded can even replace rename(). semantics similar two functions, assigning newVar=oldVar. example: can see every instance variable named model renamed inside model ini block. completeness can see dplyr verb (since S3 method):","code":"mod11 <- mod10 |> rxRename(drug1kout=kout, tv.drug1kout=tkout) print(mod11) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd temax te0 #> 0.45 1.00 3.45 0.70 1.00 1.00 #> tec50 tkin tv.drug1kout #> 1.00 1.00 1.00 #> #> Omega ($omega): #> eta.cl eta.v eta.e0 #> eta.cl 0.3 0.0 0 #> eta.v 0.0 0.1 0 #> eta.e0 0.0 0.0 1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 te0 eta.e0 id #> 2 tcl eta.cl id #> 3 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- 0.45 #> label(\"Ka\") #> tcl <- 1 #> label(\"Cl\") #> tv <- 3.45 #> label(\"V\") #> add.sd <- c(0, 0.7) #> temax <- 1 #> te0 <- 1 #> tec50 <- 1 #> tkin <- 1 #> tv.drug1kout <- 1 #> eta.cl ~ 0.3 #> eta.v ~ 0.1 #> eta.e0 ~ 1 #> }) #> model({ #> emax <- exp(temax) #> e0 <- exp(te0 + eta.e0) #> ec50 <- exp(tec50) #> kin <- exp(tkin) #> drug1kout <- exp(tv.drug1kout) #> ka <- exp(tka) #> cl <- exp(tcl + eta.cl) #> v <- exp(tv + eta.v) #> d/dt(depot) = -ka * depot #> d/dt(center) = ka * depot - cl/v * center #> cp = center/v #> cp ~ add(add.sd) #> }) #> } library(dplyr) #> #> Attaching package: 'dplyr' #> The following objects are masked from 'package:stats': #> #> filter, lag #> The following objects are masked from 'package:base': #> #> intersect, setdiff, setequal, union mod12 <- mod10 |> rename(drug1kout=kout, tv.drug1kout=tkout) print(mod12) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd temax te0 #> 0.45 1.00 3.45 0.70 1.00 1.00 #> tec50 tkin tv.drug1kout #> 1.00 1.00 1.00 #> #> Omega ($omega): #> eta.cl eta.v eta.e0 #> eta.cl 0.3 0.0 0 #> eta.v 0.0 0.1 0 #> eta.e0 0.0 0.0 1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 te0 eta.e0 id #> 2 tcl eta.cl id #> 3 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- 0.45 #> label(\"Ka\") #> tcl <- 1 #> label(\"Cl\") #> tv <- 3.45 #> label(\"V\") #> add.sd <- c(0, 0.7) #> temax <- 1 #> te0 <- 1 #> tec50 <- 1 #> tkin <- 1 #> tv.drug1kout <- 1 #> eta.cl ~ 0.3 #> eta.v ~ 0.1 #> eta.e0 ~ 1 #> }) #> model({ #> emax <- exp(temax) #> e0 <- exp(te0 + eta.e0) #> ec50 <- exp(tec50) #> kin <- exp(tkin) #> drug1kout <- exp(tv.drug1kout) #> ka <- exp(tka) #> cl <- exp(tcl + eta.cl) #> v <- exp(tv + eta.v) #> d/dt(depot) = -ka * depot #> d/dt(center) = ka * depot - cl/v * center #> cp = center/v #> cp ~ add(add.sd) #> }) #> }"},{"path":"https://nlmixr2.github.io/rxode2/articles/Modifying-Models.html","id":"combine-different-models","dir":"Articles","previous_headings":"Modifying model","what":"Combine different models","title":"Modifying Models","text":"can also combine different models rxAppendModel(). general need variables common combine. generally want models link . example pk pd model done renaming cp first model ceff second model: get error try combine models without variables common: want combine models without respecting variables common, can use common=FALSE:","code":"ocmt <- function() { ini({ tka <- exp(0.45) # Ka tcl <- exp(1) # Cl tv <- exp(3.45); # log V ## the label(\"Label name\") works with all models add.sd <- 0.7 }) model({ ka <- tka cl <- tcl v <- tv d/dt(depot) <- -ka * depot d/dt(center) <- ka * depot - cl / v * center cp <- center / v cp ~ add(add.sd) }) } idr <- function() { ini({ tkin <- log(1) tkout <- log(1) tic50 <- log(10) gamma <- fix(1) idr.sd <- 1 }) model({ kin <- exp(tkin) kout <- exp(tkout) ic50 <- exp(tic50) d/dt(eff) <- kin - kout*(1-ceff^gamma/(ic50^gamma+ceff^gamma)) eff ~ add(idr.sd) }) } rxAppendModel(ocmt %>% rxRename(ceff=cp), idr) #> ℹ parameter labels from comments will be replaced by 'label()' #> ── rxode2-based free-form 3-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd tkin tkout tic50 gamma #> 1.568312 2.718282 31.500392 0.700000 0.000000 0.000000 2.302585 1.000000 #> idr.sd #> 1.000000 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> 3 3 eff #> ── Multiple Endpoint Model ($multipleEndpoint): ── #> variable cmt dvid* #> 1 ceff ~ … cmt='ceff' or cmt=4 dvid='ceff' or dvid=1 #> 2 eff ~ … cmt='eff' or cmt=3 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 #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- 1.56831218549017 #> label(\"Ka\") #> tcl <- 2.71828182845905 #> label(\"Cl\") #> tv <- 31.5003923087479 #> label(\"log V\") #> add.sd <- c(0, 0.7) #> tkin <- 0 #> tkout <- 0 #> tic50 <- 2.30258509299405 #> gamma <- fix(1) #> idr.sd <- c(0, 1) #> }) #> model({ #> ka <- tka #> cl <- tcl #> v <- tv #> d/dt(depot) <- -ka * depot #> d/dt(center) <- ka * depot - cl/v * center #> ceff <- center/v #> ceff ~ add(add.sd) #> kin <- exp(tkin) #> kout <- exp(tkout) #> ic50 <- exp(tic50) #> d/dt(eff) <- kin - kout * (1 - ceff^gamma/(ic50^gamma + #> ceff^gamma)) #> eff ~ add(idr.sd) #> }) #> } try(rxAppendModel(ocmt, idr)) #> ℹ parameter labels from comments will be replaced by 'label()' #> Error : not all the models have variables in common (use `common=FALSE` to allow this) mod2 <- rxAppendModel(ocmt, idr, common=FALSE) |> model(ceff=cp, append=ic50) # here we add the translation after the #> ℹ parameter labels from comments will be replaced by 'label()' # ic50 line to make it reasonable print(mod2) #> ── rxode2-based free-form 3-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd tkin tkout tic50 gamma #> 1.568312 2.718282 31.500392 0.700000 0.000000 0.000000 2.302585 1.000000 #> idr.sd #> 1.000000 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> 3 3 eff #> ── Multiple Endpoint Model ($multipleEndpoint): ── #> variable cmt dvid* #> 1 cp ~ … cmt='cp' or cmt=4 dvid='cp' or dvid=1 #> 2 eff ~ … cmt='eff' or cmt=3 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 #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- 1.56831218549017 #> label(\"Ka\") #> tcl <- 2.71828182845905 #> label(\"Cl\") #> tv <- 31.5003923087479 #> label(\"log V\") #> add.sd <- c(0, 0.7) #> tkin <- 0 #> tkout <- 0 #> tic50 <- 2.30258509299405 #> gamma <- fix(1) #> idr.sd <- c(0, 1) #> }) #> model({ #> ka <- tka #> cl <- tcl #> v <- tv #> d/dt(depot) <- -ka * depot #> d/dt(center) <- ka * depot - cl/v * center #> cp <- center/v #> cp ~ add(add.sd) #> kin <- exp(tkin) #> kout <- exp(tkout) #> ic50 <- exp(tic50) #> ceff <- cp #> d/dt(eff) <- kin - kout * (1 - ceff^gamma/(ic50^gamma + #> ceff^gamma)) #> eff ~ add(idr.sd) #> }) #> }"},{"path":"https://nlmixr2.github.io/rxode2/articles/Modifying-Models.html","id":"creating-more-complex-model-modification-functions","dir":"Articles","previous_headings":"Modifying model","what":"Creating more complex model modification functions","title":"Modifying Models","text":"pretty flexible, may want even , helper functions help create functions . discuss extract model function update . Lets start model: Lets assume moment want remove eta cl. First probably want get model lines. can modelExtract(): Now want worry cl line, can subset : Now wish change line “cl <- exp(tcl+eta.cl)” Note functions modify ini({}) block. may modify ini block first make valid rxode2/nlmixr2 model. particular case, using model piping easier, simply demonstrates two different way extract model information way add information final model. methods can tricky using model parsed correctly. means make sure parameters endpoints follow correct rules","code":"f <- function() { ini({ tka <- 0.45 tcl <- 1 tv <- 3.45 eta.ka ~ 0.6 eta.v ~ 0.1 }) model({ ka <- exp(tka + eta.ka) cl <- exp(tcl) v <- exp(tv + eta.v) d/dt(depot) <- -ka * depot d/dt(center) <- ka * depot - cl/v * center cp <- center/v }) } totLines <- modelExtract(f, endpoint=NA) # endpoints should be included print(totLines) #> [1] \"ka <- exp(tka + eta.ka)\" #> [2] \"cl <- exp(tcl)\" #> [3] \"v <- exp(tv + eta.v)\" #> [4] \"d/dt(depot) <- -ka * depot\" #> [5] \"d/dt(center) <- ka * depot - cl/v * center\" #> [6] \"cp <- center/v\" clLine <- modelExtract(f, cl, lines=TRUE) line <- attr(clLine, \"lines\") totLines[line] <- \"cl <- exp(tcl+eta.cl)\" # For now lets remove the entire `ini` block (so you don't have to # worry about syncing parameters). # ini(f) <- NULL model(f) <- totLines #> ℹ parameter labels from comments are typically ignored in non-interactive mode #> ℹ Need to run with the source intact to parse comments print(f) #> function () #> { #> ini({ #> }) #> model({ #> ka <- exp(tka + eta.ka) #> cl <- exp(tcl + eta.cl) #> v <- exp(tv + eta.v) #> d/dt(depot) <- -ka * depot #> d/dt(center) <- ka * depot - cl/v * center #> cp <- center/v #> }) #> } #> "},{"path":"https://nlmixr2.github.io/rxode2/articles/Modifying-Models.html","id":"modifying-initial-estimates","dir":"Articles","previous_headings":"","what":"Modifying initial estimates","title":"Modifying Models","text":"common items want initial estimates : Fix/Unfix parameter Change initial condition values bounds Change initial condition type Change labels transformations Reorder parameters may wish create functions; discuss .","code":""},{"path":"https://nlmixr2.github.io/rxode2/articles/Modifying-Models.html","id":"fixing-or-unfixing-a-parameter","dir":"Articles","previous_headings":"Modifying initial estimates","what":"Fixing or unfixing a parameter","title":"Modifying Models","text":"can fix model estimates two ways. first fix value whatever model function, done piping model parameter name (like tka) setting equal fix (%>% ini(tka=fix)). full example: can also fix parameter different value wish; similar can specify value fix inside fix pseudo-function follows: %>% ini(tka=fix(0.1)). fully worked example :","code":"f <- function() { ini({ tka <- 0.45 tcl <- 1 tv <- 3.45 add.sd <- c(0, 0.7) eta.ka ~ 0.6 eta.v ~ 0.1 }) model({ ka <- exp(tka + eta.ka) cl <- exp(tcl) v <- exp(tv + eta.v) d/dt(depot) <- -ka * depot d/dt(center) <- ka * depot - cl/v * center cp <- center/v cp ~ add(add.sd) }) } f2 <- f |> ini(tka=fix) #> ℹ fix `tka` to `0.45` print(f2) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd #> 0.45 1.00 3.45 0.70 #> #> Omega ($omega): #> eta.ka eta.v #> eta.ka 0.6 0.0 #> eta.v 0.0 0.1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 tka eta.ka id #> 2 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- fix(0.45) #> tcl <- 1 #> tv <- 3.45 #> add.sd <- c(0, 0.7) #> eta.ka ~ 0.6 #> eta.v ~ 0.1 #> }) #> model({ #> ka <- exp(tka + eta.ka) #> cl <- exp(tcl) #> v <- exp(tv + eta.v) #> d/dt(depot) <- -ka * depot #> d/dt(center) <- ka * depot - cl/v * center #> cp <- center/v #> cp ~ add(add.sd) #> }) #> } f <- function() { ini({ tka <- 0.45 tcl <- 1 tv <- 3.45 add.sd <- c(0, 0.7) eta.ka ~ 0.6 eta.v ~ 0.1 }) model({ ka <- exp(tka + eta.ka) cl <- exp(tcl) v <- exp(tv + eta.v) d/dt(depot) <- -ka * depot d/dt(center) <- ka * depot - cl/v * center cp <- center/v cp ~ add(add.sd) }) } f2 <- f |> ini(tka=fix(0.1)) #> ℹ fix `tka` to `0.45` #> ℹ change initial estimate of `tka` to `0.1` print(f2) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd #> 0.10 1.00 3.45 0.70 #> #> Omega ($omega): #> eta.ka eta.v #> eta.ka 0.6 0.0 #> eta.v 0.0 0.1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 tka eta.ka id #> 2 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- fix(0.1) #> tcl <- 1 #> tv <- 3.45 #> add.sd <- c(0, 0.7) #> eta.ka ~ 0.6 #> eta.v ~ 0.1 #> }) #> model({ #> ka <- exp(tka + eta.ka) #> cl <- exp(tcl) #> v <- exp(tv + eta.v) #> d/dt(depot) <- -ka * depot #> d/dt(center) <- ka * depot - cl/v * center #> cp <- center/v #> cp ~ add(add.sd) #> }) #> }"},{"path":"https://nlmixr2.github.io/rxode2/articles/Modifying-Models.html","id":"unfixing-parameters","dir":"Articles","previous_headings":"Modifying initial estimates","what":"Unfixing parameters","title":"Modifying Models","text":"unfix parameters similarly fixing. Instead using fix keyword, use unfix keyword. unfix parameter (keeping value) pipe model using (|> ini(tka=unfix)). Starting fixed model fully worked example : can also unfix change initial estimate ini(parameter=unfix(newEst)):","code":"print(f2) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd #> 0.10 1.00 3.45 0.70 #> #> Omega ($omega): #> eta.ka eta.v #> eta.ka 0.6 0.0 #> eta.v 0.0 0.1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 tka eta.ka id #> 2 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- fix(0.1) #> tcl <- 1 #> tv <- 3.45 #> add.sd <- c(0, 0.7) #> eta.ka ~ 0.6 #> eta.v ~ 0.1 #> }) #> model({ #> ka <- exp(tka + eta.ka) #> cl <- exp(tcl) #> v <- exp(tv + eta.v) #> d/dt(depot) <- -ka * depot #> d/dt(center) <- ka * depot - cl/v * center #> cp <- center/v #> cp ~ add(add.sd) #> }) #> } f3 <- f2 |> ini(tka=unfix) #> ℹ unfix `tka` keeping initial estimate `0.1` print(f3) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd #> 0.10 1.00 3.45 0.70 #> #> Omega ($omega): #> eta.ka eta.v #> eta.ka 0.6 0.0 #> eta.v 0.0 0.1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 tka eta.ka id #> 2 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- 0.1 #> tcl <- 1 #> tv <- 3.45 #> add.sd <- c(0, 0.7) #> eta.ka ~ 0.6 #> eta.v ~ 0.1 #> }) #> model({ #> ka <- exp(tka + eta.ka) #> cl <- exp(tcl) #> v <- exp(tv + eta.v) #> d/dt(depot) <- -ka * depot #> d/dt(center) <- ka * depot - cl/v * center #> cp <- center/v #> cp ~ add(add.sd) #> }) #> } print(f2) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd #> 0.10 1.00 3.45 0.70 #> #> Omega ($omega): #> eta.ka eta.v #> eta.ka 0.6 0.0 #> eta.v 0.0 0.1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 tka eta.ka id #> 2 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- fix(0.1) #> tcl <- 1 #> tv <- 3.45 #> add.sd <- c(0, 0.7) #> eta.ka ~ 0.6 #> eta.v ~ 0.1 #> }) #> model({ #> ka <- exp(tka + eta.ka) #> cl <- exp(tcl) #> v <- exp(tv + eta.v) #> d/dt(depot) <- -ka * depot #> d/dt(center) <- ka * depot - cl/v * center #> cp <- center/v #> cp ~ add(add.sd) #> }) #> } f3 <- f2 |> ini(tka=unfix(10)) #> ℹ unfix `tka` keeping initial estimate `0.1` #> ℹ change initial estimate of `tka` to `10` print(f3) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd #> 10.00 1.00 3.45 0.70 #> #> Omega ($omega): #> eta.ka eta.v #> eta.ka 0.6 0.0 #> eta.v 0.0 0.1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 tka eta.ka id #> 2 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- 10 #> tcl <- 1 #> tv <- 3.45 #> add.sd <- c(0, 0.7) #> eta.ka ~ 0.6 #> eta.v ~ 0.1 #> }) #> model({ #> ka <- exp(tka + eta.ka) #> cl <- exp(tcl) #> v <- exp(tv + eta.v) #> d/dt(depot) <- -ka * depot #> d/dt(center) <- ka * depot - cl/v * center #> cp <- center/v #> cp ~ add(add.sd) #> }) #> }"},{"path":[]},{"path":"https://nlmixr2.github.io/rxode2/articles/Modifying-Models.html","id":"multiple-parameter-assignment","dir":"Articles","previous_headings":"Modifying initial estimates > Changing the parameter values and possibly bounds","what":"Multiple parameter assignment","title":"Modifying Models","text":"can also assign multiple parameters providing : vector/list multiple lines piped ini() block Using covariance matrix case vector can specify pipe model. example: can also added multiple lines commas separating estimates: also use matrix specify covariance:","code":"ini1 <- c(tka=0.1, tcl=1, tv=3) f4 <- f |> ini(ini1) #> ℹ change initial estimate of `tka` to `0.1` #> ℹ change initial estimate of `tcl` to `1` #> ℹ change initial estimate of `tv` to `3` print(f4) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd #> 0.1 1.0 3.0 0.7 #> #> Omega ($omega): #> eta.ka eta.v #> eta.ka 0.6 0.0 #> eta.v 0.0 0.1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 tka eta.ka id #> 2 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- 0.1 #> tcl <- 1 #> tv <- 3 #> add.sd <- c(0, 0.7) #> eta.ka ~ 0.6 #> eta.v ~ 0.1 #> }) #> model({ #> ka <- exp(tka + eta.ka) #> cl <- exp(tcl) #> v <- exp(tv + eta.v) #> d/dt(depot) <- -ka * depot #> d/dt(center) <- ka * depot - cl/v * center #> cp <- center/v #> cp ~ add(add.sd) #> }) #> } # or equivalently ini1 <- list(tka=0.1, tcl=1, tv=3) f4a <- f |> ini(ini1) #> ℹ change initial estimate of `tka` to `0.1` #> ℹ change initial estimate of `tcl` to `1` #> ℹ change initial estimate of `tv` to `3` print(f4) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd #> 0.1 1.0 3.0 0.7 #> #> Omega ($omega): #> eta.ka eta.v #> eta.ka 0.6 0.0 #> eta.v 0.0 0.1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 tka eta.ka id #> 2 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- 0.1 #> tcl <- 1 #> tv <- 3 #> add.sd <- c(0, 0.7) #> eta.ka ~ 0.6 #> eta.v ~ 0.1 #> }) #> model({ #> ka <- exp(tka + eta.ka) #> cl <- exp(tcl) #> v <- exp(tv + eta.v) #> d/dt(depot) <- -ka * depot #> d/dt(center) <- ka * depot - cl/v * center #> cp <- center/v #> cp ~ add(add.sd) #> }) #> } # commas separating values: f4 <- f |> ini(tka=0.1, tcl=1, tv=3) #> ℹ change initial estimate of `tka` to `0.1` #> ℹ change initial estimate of `tcl` to `1` #> ℹ change initial estimate of `tv` to `3` print(f4) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd #> 0.1 1.0 3.0 0.7 #> #> Omega ($omega): #> eta.ka eta.v #> eta.ka 0.6 0.0 #> eta.v 0.0 0.1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 tka eta.ka id #> 2 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- 0.1 #> tcl <- 1 #> tv <- 3 #> add.sd <- c(0, 0.7) #> eta.ka ~ 0.6 #> eta.v ~ 0.1 #> }) #> model({ #> ka <- exp(tka + eta.ka) #> cl <- exp(tcl) #> v <- exp(tv + eta.v) #> d/dt(depot) <- -ka * depot #> d/dt(center) <- ka * depot - cl/v * center #> cp <- center/v #> cp ~ add(add.sd) #> }) #> } # multiple lines in {} f4 <- f |> ini({ tka <- 0.2 tcl <- 2 tv <- 6 }) #> ℹ change initial estimate of `tka` to `0.2` #> ℹ change initial estimate of `tcl` to `2` #> ℹ change initial estimate of `tv` to `6` print(f4) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd #> 0.2 2.0 6.0 0.7 #> #> Omega ($omega): #> eta.ka eta.v #> eta.ka 0.6 0.0 #> eta.v 0.0 0.1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 tka eta.ka id #> 2 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- 0.2 #> tcl <- 2 #> tv <- 6 #> add.sd <- c(0, 0.7) #> eta.ka ~ 0.6 #> eta.v ~ 0.1 #> }) #> model({ #> ka <- exp(tka + eta.ka) #> cl <- exp(tcl) #> v <- exp(tv + eta.v) #> d/dt(depot) <- -ka * depot #> d/dt(center) <- ka * depot - cl/v * center #> cp <- center/v #> cp ~ add(add.sd) #> }) #> } ome <- lotri(eta.ka + eta.v ~ c(0.6, 0.01, 10.1)) f4 <- f |> ini(ome) #> ℹ change initial estimate of `eta.ka` to `0.6` #> ℹ add covariance between `eta.v` and `eta.ka` with initial estimate `0.01` #> ℹ change initial estimate of `eta.v` to `10.1` print(f4) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd #> 0.45 1.00 3.45 0.70 #> #> Omega ($omega): #> eta.ka eta.v #> eta.ka 0.60 0.01 #> eta.v 0.01 10.10 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 tka eta.ka id #> 2 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- 0.45 #> tcl <- 1 #> tv <- 3.45 #> add.sd <- c(0, 0.7) #> eta.ka + eta.v ~ c(0.6, 0.01, 10.1) #> }) #> model({ #> ka <- exp(tka + eta.ka) #> cl <- exp(tcl) #> v <- exp(tv + eta.v) #> d/dt(depot) <- -ka * depot #> d/dt(center) <- ka * depot - cl/v * center #> cp <- center/v #> cp ~ add(add.sd) #> }) #> } # or equavialtly use the lotri-type syntax for the omega: f4 <- f |> ini(eta.ka + eta.v ~ c(0.6, 0.01, 0.2)) #> ℹ change initial estimate of `eta.ka` to `0.6` #> ℹ add covariance between `eta.v` and `eta.ka` with initial estimate `0.01` #> ℹ change initial estimate of `eta.v` to `0.2` print(f4) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd #> 0.45 1.00 3.45 0.70 #> #> Omega ($omega): #> eta.ka eta.v #> eta.ka 0.60 0.01 #> eta.v 0.01 0.20 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 tka eta.ka id #> 2 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- 0.45 #> tcl <- 1 #> tv <- 3.45 #> add.sd <- c(0, 0.7) #> eta.ka + eta.v ~ c(0.6, 0.01, 0.2) #> }) #> model({ #> ka <- exp(tka + eta.ka) #> cl <- exp(tcl) #> v <- exp(tv + eta.v) #> d/dt(depot) <- -ka * depot #> d/dt(center) <- ka * depot - cl/v * center #> cp <- center/v #> cp ~ add(add.sd) #> }) #> }"},{"path":"https://nlmixr2.github.io/rxode2/articles/Modifying-Models.html","id":"single-parameter-assignment","dir":"Articles","previous_headings":"Modifying initial estimates > Changing the parameter values and possibly bounds","what":"Single parameter assignment","title":"Modifying Models","text":"simplest way change initial parameter estimates simply use ini(parameter=newValue). can also use <- ~ change value: fully worked example showing three types initial value modification : can change bounds like model specification using numeric vector c(low, estimate) c(low, estimate, hi). worked example: Note changing parameters default values might show parameter printout:","code":"f3 <- f |> ini(tka <- 0.1) #> ℹ change initial estimate of `tka` to `0.1` f4 <- f |> ini(tka=0.1) #> ℹ change initial estimate of `tka` to `0.1` f5 <- f |> ini(tka ~ 0.1) #> ℹ change initial estimate of `tka` to `0.1` print(f5) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd #> 0.10 1.00 3.45 0.70 #> #> Omega ($omega): #> eta.ka eta.v #> eta.ka 0.6 0.0 #> eta.v 0.0 0.1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 tka eta.ka id #> 2 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- 0.1 #> tcl <- 1 #> tv <- 3.45 #> add.sd <- c(0, 0.7) #> eta.ka ~ 0.6 #> eta.v ~ 0.1 #> }) #> model({ #> ka <- exp(tka + eta.ka) #> cl <- exp(tcl) #> v <- exp(tv + eta.v) #> d/dt(depot) <- -ka * depot #> d/dt(center) <- ka * depot - cl/v * center #> cp <- center/v #> cp ~ add(add.sd) #> }) #> } f3 <- f |> ini(tka <- c(0, 0.1, 0.2)) #> ℹ change initial estimate (0.1) and upper/lower bound (0 to 0.2) of `tka` print(f3) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd #> 0.10 1.00 3.45 0.70 #> #> Omega ($omega): #> eta.ka eta.v #> eta.ka 0.6 0.0 #> eta.v 0.0 0.1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 tka eta.ka id #> 2 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- c(0, 0.1, 0.2) #> tcl <- 1 #> tv <- 3.45 #> add.sd <- c(0, 0.7) #> eta.ka ~ 0.6 #> eta.v ~ 0.1 #> }) #> model({ #> ka <- exp(tka + eta.ka) #> cl <- exp(tcl) #> v <- exp(tv + eta.v) #> d/dt(depot) <- -ka * depot #> d/dt(center) <- ka * depot - cl/v * center #> cp <- center/v #> cp ~ add(add.sd) #> }) #> } f3 <- f |> ini(tka <- c(0, 0.1)) #> ℹ change initial estimate (0.1) and lower bound (0) of `tka` print(f3) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd #> 0.10 1.00 3.45 0.70 #> #> Omega ($omega): #> eta.ka eta.v #> eta.ka 0.6 0.0 #> eta.v 0.0 0.1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 tka eta.ka id #> 2 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- c(0, 0.1) #> tcl <- 1 #> tv <- 3.45 #> add.sd <- c(0, 0.7) #> eta.ka ~ 0.6 #> eta.v ~ 0.1 #> }) #> model({ #> ka <- exp(tka + eta.ka) #> cl <- exp(tcl) #> v <- exp(tv + eta.v) #> d/dt(depot) <- -ka * depot #> d/dt(center) <- ka * depot - cl/v * center #> cp <- center/v #> cp ~ add(add.sd) #> }) #> } f3 <- f |> ini(tka <- c(0, 0.1, 0.2)) #> ℹ change initial estimate (0.1) and upper/lower bound (0 to 0.2) of `tka` print(f3) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd #> 0.10 1.00 3.45 0.70 #> #> Omega ($omega): #> eta.ka eta.v #> eta.ka 0.6 0.0 #> eta.v 0.0 0.1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 tka eta.ka id #> 2 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- c(0, 0.1, 0.2) #> tcl <- 1 #> tv <- 3.45 #> add.sd <- c(0, 0.7) #> eta.ka ~ 0.6 #> eta.v ~ 0.1 #> }) #> model({ #> ka <- exp(tka + eta.ka) #> cl <- exp(tcl) #> v <- exp(tv + eta.v) #> d/dt(depot) <- -ka * depot #> d/dt(center) <- ka * depot - cl/v * center #> cp <- center/v #> cp ~ add(add.sd) #> }) #> } # Now reassign f4 <- f3 |> ini(tka <- c(-Inf, 0.1, Inf)) #> ℹ change initial estimate (0.1) and upper/lower bound (-Inf to Inf) of `tka` print(f4) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd #> 0.10 1.00 3.45 0.70 #> #> Omega ($omega): #> eta.ka eta.v #> eta.ka 0.6 0.0 #> eta.v 0.0 0.1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 tka eta.ka id #> 2 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- 0.1 #> tcl <- 1 #> tv <- 3.45 #> add.sd <- c(0, 0.7) #> eta.ka ~ 0.6 #> eta.v ~ 0.1 #> }) #> model({ #> ka <- exp(tka + eta.ka) #> cl <- exp(tcl) #> v <- exp(tv + eta.v) #> d/dt(depot) <- -ka * depot #> d/dt(center) <- ka * depot - cl/v * center #> cp <- center/v #> cp ~ add(add.sd) #> }) #> }"},{"path":"https://nlmixr2.github.io/rxode2/articles/Modifying-Models.html","id":"changing-parameter-types","dir":"Articles","previous_headings":"Modifying initial estimates > Changing the parameter values and possibly bounds","what":"Changing parameter types","title":"Modifying Models","text":"can change parameter type two operators either using -par convert parameter covariate ~par toggle population individual parameters. example 3:","code":"# Switch population parameter to between subject variability parameter: f4 <- f |> ini( ~ tcl) #> ℹ convert 'tcl' from population parameter to between subject variability print(f4) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tv add.sd #> 0.45 3.45 0.70 #> #> Omega ($omega): #> eta.ka eta.v tcl #> eta.ka 0.6 0.0 0 #> eta.v 0.0 0.1 0 #> tcl 0.0 0.0 1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 tka eta.ka id #> 2 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- 0.45 #> tv <- 3.45 #> add.sd <- c(0, 0.7) #> eta.ka ~ 0.6 #> eta.v ~ 0.1 #> tcl ~ 1 #> }) #> model({ #> ka <- exp(tka + eta.ka) #> cl <- exp(tcl) #> v <- exp(tv + eta.v) #> d/dt(depot) <- -ka * depot #> d/dt(center) <- ka * depot - cl/v * center #> cp <- center/v #> cp ~ add(add.sd) #> }) #> } # Switch back to population parameter f5 <- f4 |> ini( ~ tcl) #> ℹ convert 'tcl' from between subject variability to population parameter print(f5) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tv add.sd tcl #> 0.45 3.45 0.70 1.00 #> #> Omega ($omega): #> eta.ka eta.v #> eta.ka 0.6 0.0 #> eta.v 0.0 0.1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 tka eta.ka id #> 2 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- 0.45 #> tv <- 3.45 #> add.sd <- c(0, 0.7) #> tcl <- 1 #> eta.ka ~ 0.6 #> eta.v ~ 0.1 #> }) #> model({ #> ka <- exp(tka + eta.ka) #> cl <- exp(tcl) #> v <- exp(tv + eta.v) #> d/dt(depot) <- -ka * depot #> d/dt(center) <- ka * depot - cl/v * center #> cp <- center/v #> cp ~ add(add.sd) #> }) #> } # Change the variable to a covariate parameter (ie it doesn't have an # initial estimate so remove it with the `-` operator): f6 <- f4 |> ini(-tcl) #> ℹ changing between subject variability parameter 'tcl' to covariate parameter print(f6) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tv add.sd #> 0.45 3.45 0.70 #> #> Omega ($omega): #> eta.ka eta.v #> eta.ka 0.6 0.0 #> eta.v 0.0 0.1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 tka eta.ka id #> 2 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- 0.45 #> tv <- 3.45 #> add.sd <- c(0, 0.7) #> eta.ka ~ 0.6 #> eta.v ~ 0.1 #> }) #> model({ #> ka <- exp(tka + eta.ka) #> cl <- exp(tcl) #> v <- exp(tv + eta.v) #> d/dt(depot) <- -ka * depot #> d/dt(center) <- ka * depot - cl/v * center #> cp <- center/v #> cp ~ add(add.sd) #> }) #> } # You can change the covariate or remove the parameter estimate by # `tcl <- NULL`: f6 <- f4 |> ini(tcl <- NULL) #> ℹ changing between subject variability parameter 'tcl' to covariate parameter print(f6) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tv add.sd #> 0.45 3.45 0.70 #> #> Omega ($omega): #> eta.ka eta.v #> eta.ka 0.6 0.0 #> eta.v 0.0 0.1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 tka eta.ka id #> 2 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- 0.45 #> tv <- 3.45 #> add.sd <- c(0, 0.7) #> eta.ka ~ 0.6 #> eta.v ~ 0.1 #> }) #> model({ #> ka <- exp(tka + eta.ka) #> cl <- exp(tcl) #> v <- exp(tv + eta.v) #> d/dt(depot) <- -ka * depot #> d/dt(center) <- ka * depot - cl/v * center #> cp <- center/v #> cp ~ add(add.sd) #> }) #> } # to add it back as a between subject variability or population # parameter you can pipe it as follows: f7 <- f6 |> ini(tcl=4) #> ℹ promote `tcl` to population parameter with initial estimate 4 #> ℹ change initial estimate of `tcl` to `4` print(f7) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tv add.sd tcl #> 0.45 3.45 0.70 4.00 #> #> Omega ($omega): #> eta.ka eta.v #> eta.ka 0.6 0.0 #> eta.v 0.0 0.1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 tka eta.ka id #> 2 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- 0.45 #> tv <- 3.45 #> add.sd <- c(0, 0.7) #> tcl <- 4 #> eta.ka ~ 0.6 #> eta.v ~ 0.1 #> }) #> model({ #> ka <- exp(tka + eta.ka) #> cl <- exp(tcl) #> v <- exp(tv + eta.v) #> d/dt(depot) <- -ka * depot #> d/dt(center) <- ka * depot - cl/v * center #> cp <- center/v #> cp ~ add(add.sd) #> }) #> } f8 <- f6 |> ini(tcl ~ 0.1) #> ℹ promote `tcl` to between subject variability with initial estimate 0.1 #> ℹ change initial estimate of `tcl` to `0.1` print(f8) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tv add.sd #> 0.45 3.45 0.70 #> #> Omega ($omega): #> eta.ka eta.v tcl #> eta.ka 0.6 0.0 0.0 #> eta.v 0.0 0.1 0.0 #> tcl 0.0 0.0 0.1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 tka eta.ka id #> 2 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- 0.45 #> tv <- 3.45 #> add.sd <- c(0, 0.7) #> eta.ka ~ 0.6 #> eta.v ~ 0.1 #> tcl ~ 0.1 #> }) #> model({ #> ka <- exp(tka + eta.ka) #> cl <- exp(tcl) #> v <- exp(tv + eta.v) #> d/dt(depot) <- -ka * depot #> d/dt(center) <- ka * depot - cl/v * center #> cp <- center/v #> cp ~ add(add.sd) #> }) #> }"},{"path":"https://nlmixr2.github.io/rxode2/articles/Modifying-Models.html","id":"changing-parameter-labels","dir":"Articles","previous_headings":"Modifying initial estimates > Changing the parameter values and possibly bounds","what":"Changing parameter labels","title":"Modifying Models","text":"want change/add parameter label assign parameter label(\"label add\"). example: can also change order performing operations: want remove labels can remove ini(par=label(NULL)); example:","code":"f4 <- f |> ini(tka=label(\"Typical Ka (1/hr)\")) print(f4) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd #> 0.45 1.00 3.45 0.70 #> #> Omega ($omega): #> eta.ka eta.v #> eta.ka 0.6 0.0 #> eta.v 0.0 0.1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 tka eta.ka id #> 2 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- 0.45 #> label(\"Typical Ka (1/hr)\") #> tcl <- 1 #> tv <- 3.45 #> add.sd <- c(0, 0.7) #> eta.ka ~ 0.6 #> eta.v ~ 0.1 #> }) #> model({ #> ka <- exp(tka + eta.ka) #> cl <- exp(tcl) #> v <- exp(tv + eta.v) #> d/dt(depot) <- -ka * depot #> d/dt(center) <- ka * depot - cl/v * center #> cp <- center/v #> cp ~ add(add.sd) #> }) #> } f5 <- f |> ini(tka=label(\"Typical Ka (1/hr)\"), append=tcl) print(f5) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tcl tka tv add.sd #> 1.00 0.45 3.45 0.70 #> #> Omega ($omega): #> eta.ka eta.v #> eta.ka 0.6 0.0 #> eta.v 0.0 0.1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 tka eta.ka id #> 2 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tcl <- 1 #> tka <- 0.45 #> label(\"Typical Ka (1/hr)\") #> tv <- 3.45 #> add.sd <- c(0, 0.7) #> eta.ka ~ 0.6 #> eta.v ~ 0.1 #> }) #> model({ #> ka <- exp(tka + eta.ka) #> cl <- exp(tcl) #> v <- exp(tv + eta.v) #> d/dt(depot) <- -ka * depot #> d/dt(center) <- ka * depot - cl/v * center #> cp <- center/v #> cp ~ add(add.sd) #> }) #> } f6 <- f |> ini(tka=label(NULL)) print(f6) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd #> 0.45 1.00 3.45 0.70 #> #> Omega ($omega): #> eta.ka eta.v #> eta.ka 0.6 0.0 #> eta.v 0.0 0.1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 tka eta.ka id #> 2 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- 0.45 #> tcl <- 1 #> tv <- 3.45 #> add.sd <- c(0, 0.7) #> eta.ka ~ 0.6 #> eta.v ~ 0.1 #> }) #> model({ #> ka <- exp(tka + eta.ka) #> cl <- exp(tcl) #> v <- exp(tv + eta.v) #> d/dt(depot) <- -ka * depot #> d/dt(center) <- ka * depot - cl/v * center #> cp <- center/v #> cp ~ add(add.sd) #> }) #> }"},{"path":"https://nlmixr2.github.io/rxode2/articles/Modifying-Models.html","id":"changing-parameter-transformations","dir":"Articles","previous_headings":"Modifying initial estimates > Changing the parameter values and possibly bounds","what":"Changing parameter transformations","title":"Modifying Models","text":"Back-transformations -ride back transformations nlmixr2 models. similar modification labels. use |> ini(tka=backTransform(exp)) add exponential back-transformation data: wish remove can also |> ini(tka=backTransform(NULL)):","code":"f7 <- f |> ini(tka=backTransform(exp)) print(f7) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd #> 0.45 1.00 3.45 0.70 #> #> Omega ($omega): #> eta.ka eta.v #> eta.ka 0.6 0.0 #> eta.v 0.0 0.1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 tka eta.ka id #> 2 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- 0.45 #> backTransform(\"exp\") #> tcl <- 1 #> tv <- 3.45 #> add.sd <- c(0, 0.7) #> eta.ka ~ 0.6 #> eta.v ~ 0.1 #> }) #> model({ #> ka <- exp(tka + eta.ka) #> cl <- exp(tcl) #> v <- exp(tv + eta.v) #> d/dt(depot) <- -ka * depot #> d/dt(center) <- ka * depot - cl/v * center #> cp <- center/v #> cp ~ add(add.sd) #> }) #> } f8 <- f |> ini(tka=backTransform(NULL)) print(f8) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd #> 0.45 1.00 3.45 0.70 #> #> Omega ($omega): #> eta.ka eta.v #> eta.ka 0.6 0.0 #> eta.v 0.0 0.1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 tka eta.ka id #> 2 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- 0.45 #> tcl <- 1 #> tv <- 3.45 #> add.sd <- c(0, 0.7) #> eta.ka ~ 0.6 #> eta.v ~ 0.1 #> }) #> model({ #> ka <- exp(tka + eta.ka) #> cl <- exp(tcl) #> v <- exp(tv + eta.v) #> d/dt(depot) <- -ka * depot #> d/dt(center) <- ka * depot - cl/v * center #> cp <- center/v #> cp ~ add(add.sd) #> }) #> }"},{"path":"https://nlmixr2.github.io/rxode2/articles/Modifying-Models.html","id":"more-granular-access-of-initial-conditions","dir":"Articles","previous_headings":"Modifying initial estimates","what":"More granular access of initial conditions","title":"Modifying Models","text":"Just like model() can modify underlying data frame represents ini() block. case simply change initial estimate first parameter (tka):","code":"f <- rxode2(f) ini <- f$iniDf print(ini) #> ntheta neta1 neta2 name lower est upper fix label backTransform #> 1 1 NA NA tka -Inf 0.45 Inf FALSE #> 2 2 NA NA tcl -Inf 1.00 Inf FALSE #> 3 3 NA NA tv -Inf 3.45 Inf FALSE #> 4 4 NA NA add.sd 0 0.70 Inf FALSE #> 5 NA 1 1 eta.ka -Inf 0.60 Inf FALSE #> 6 NA 2 2 eta.v -Inf 0.10 Inf FALSE #> condition err #> 1 #> 2 #> 3 #> 4 cp add #> 5 id #> 6 id ini$est[1] <- 7 ini(f) <- ini print(f) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd #> 7.00 1.00 3.45 0.70 #> #> Omega ($omega): #> eta.ka eta.v #> eta.ka 0.6 0.0 #> eta.v 0.0 0.1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 tka eta.ka id #> 2 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- 7 #> tcl <- 1 #> tv <- 3.45 #> add.sd <- c(0, 0.7) #> eta.ka ~ 0.6 #> eta.v ~ 0.1 #> }) #> model({ #> ka <- exp(tka + eta.ka) #> cl <- exp(tcl) #> v <- exp(tv + eta.v) #> d/dt(depot) <- -ka * depot #> d/dt(center) <- ka * depot - cl/v * center #> cp <- center/v #> cp ~ add(add.sd) #> }) #> }"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-cmt.html","id":"how-rxode2-assigns-compartment-numbers","dir":"Articles","previous_headings":"","what":"How rxode2 assigns compartment numbers","title":"Changing rxode2 compartment numbers","text":"rxode2 automatically assigns compartment numbers parsing. example, Mavoglurant PBPK model following model may used: look printout, can see rxode2 assigned compartment number(s) can also see classic rxode2 model. case use summary() function: case, Venous_Blood assigned compartment 15. Figuring can inconvenient also lead re-numbering compartment simulation estimation datasets. easy probably clearer specify compartment name, tools support compartment numbers. Therefore, way number compartment easily can lead less data modification multiple tools.","code":"library(rxode2) #> rxode2 2.1.1.9000 using 2 threads (see ?getRxThreads) #> no cache: create with `rxCreateCache()` pbpk <- function() { model({ KbBR = exp(lKbBR) KbMU = exp(lKbMU) KbAD = exp(lKbAD) CLint= exp(lCLint + eta.LClint) KbBO = exp(lKbBO) KbRB = exp(lKbRB) ## Regional blood flows # Cardiac output (L/h) from White et al (1968) CO = (187.00*WT^0.81)*60/1000 QHT = 4.0 *CO/100 QBR = 12.0*CO/100 QMU = 17.0*CO/100 QAD = 5.0 *CO/100 QSK = 5.0 *CO/100 QSP = 3.0 *CO/100 QPA = 1.0 *CO/100 QLI = 25.5*CO/100 QST = 1.0 *CO/100 QGU = 14.0*CO/100 # Hepatic artery blood flow QHA = QLI - (QSP + QPA + QST + QGU) QBO = 5.0 *CO/100 QKI = 19.0*CO/100 QRB = CO - (QHT + QBR + QMU + QAD + QSK + QLI + QBO + QKI) QLU = QHT + QBR + QMU + QAD + QSK + QLI + QBO + QKI + QRB ## Organs' volumes = organs' weights / organs' density VLU = (0.76 *WT/100)/1.051 VHT = (0.47 *WT/100)/1.030 VBR = (2.00 *WT/100)/1.036 VMU = (40.00*WT/100)/1.041 VAD = (21.42*WT/100)/0.916 VSK = (3.71 *WT/100)/1.116 VSP = (0.26 *WT/100)/1.054 VPA = (0.14 *WT/100)/1.045 VLI = (2.57 *WT/100)/1.040 VST = (0.21 *WT/100)/1.050 VGU = (1.44 *WT/100)/1.043 VBO = (14.29*WT/100)/1.990 VKI = (0.44 *WT/100)/1.050 VAB = (2.81 *WT/100)/1.040 VVB = (5.62 *WT/100)/1.040 VRB = (3.86 *WT/100)/1.040 ## Fixed parameters BP = 0.61 # Blood:plasma partition coefficient fup = 0.028 # Fraction unbound in plasma fub = fup/BP # Fraction unbound in blood KbLU = exp(0.8334) KbHT = exp(1.1205) KbSK = exp(-.5238) KbSP = exp(0.3224) KbPA = exp(0.3224) KbLI = exp(1.7604) KbST = exp(0.3224) KbGU = exp(1.2026) KbKI = exp(1.3171) ##----------------------------------------- S15 = VVB*BP/1000 C15 = Venous_Blood/S15 ##----------------------------------------- d/dt(Lungs) = QLU*(Venous_Blood/VVB - Lungs/KbLU/VLU) d/dt(Heart) = QHT*(Arterial_Blood/VAB - Heart/KbHT/VHT) d/dt(Brain) = QBR*(Arterial_Blood/VAB - Brain/KbBR/VBR) d/dt(Muscles) = QMU*(Arterial_Blood/VAB - Muscles/KbMU/VMU) d/dt(Adipose) = QAD*(Arterial_Blood/VAB - Adipose/KbAD/VAD) d/dt(Skin) = QSK*(Arterial_Blood/VAB - Skin/KbSK/VSK) d/dt(Spleen) = QSP*(Arterial_Blood/VAB - Spleen/KbSP/VSP) d/dt(Pancreas) = QPA*(Arterial_Blood/VAB - Pancreas/KbPA/VPA) d/dt(Liver) = QHA*Arterial_Blood/VAB + QSP*Spleen/KbSP/VSP + QPA*Pancreas/KbPA/VPA + QST*Stomach/KbST/VST + QGU*Gut/KbGU/VGU - CLint*fub*Liver/KbLI/VLI - QLI*Liver/KbLI/VLI d/dt(Stomach) = QST*(Arterial_Blood/VAB - Stomach/KbST/VST) d/dt(Gut) = QGU*(Arterial_Blood/VAB - Gut/KbGU/VGU) d/dt(Bones) = QBO*(Arterial_Blood/VAB - Bones/KbBO/VBO) d/dt(Kidneys) = QKI*(Arterial_Blood/VAB - Kidneys/KbKI/VKI) d/dt(Arterial_Blood) = QLU*(Lungs/KbLU/VLU - Arterial_Blood/VAB) d/dt(Venous_Blood) = QHT*Heart/KbHT/VHT + QBR*Brain/KbBR/VBR + QMU*Muscles/KbMU/VMU + QAD*Adipose/KbAD/VAD + QSK*Skin/KbSK/VSK + QLI*Liver/KbLI/VLI + QBO*Bones/KbBO/VBO + QKI*Kidneys/KbKI/VKI + QRB*Rest_of_Body/KbRB/VRB - QLU*Venous_Blood/VVB d/dt(Rest_of_Body) = QRB*(Arterial_Blood/VAB - Rest_of_Body/KbRB/VRB) }) } pbpk <- pbpk() print(pbpk) #> -- rxode2-based free-form 16-cmt ODE model ------------------------------------- #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 Lungs #> 2 2 Heart #> 3 3 Brain #> 4 4 Muscles #> 5 5 Adipose #> 6 6 Skin #> 7 7 Spleen #> 8 8 Pancreas #> 9 9 Liver #> 10 10 Stomach #> 11 11 Gut #> 12 12 Bones #> 13 13 Kidneys #> 14 14 Arterial_Blood #> 15 15 Venous_Blood #> 16 16 Rest_of_Body #> -- Model (Normalized Syntax): -- #> function() { #> model({ #> KbBR = exp(lKbBR) #> KbMU = exp(lKbMU) #> KbAD = exp(lKbAD) #> CLint = exp(lCLint + eta.LClint) #> KbBO = exp(lKbBO) #> KbRB = exp(lKbRB) #> CO = (187 * WT^0.81) * 60/1000 #> QHT = 4 * CO/100 #> QBR = 12 * CO/100 #> QMU = 17 * CO/100 #> QAD = 5 * CO/100 #> QSK = 5 * CO/100 #> QSP = 3 * CO/100 #> QPA = 1 * CO/100 #> QLI = 25.5 * CO/100 #> QST = 1 * CO/100 #> QGU = 14 * CO/100 #> QHA = QLI - (QSP + QPA + QST + QGU) #> QBO = 5 * CO/100 #> QKI = 19 * CO/100 #> QRB = CO - (QHT + QBR + QMU + QAD + QSK + QLI + QBO + #> QKI) #> QLU = QHT + QBR + QMU + QAD + QSK + QLI + QBO + QKI + #> QRB #> VLU = (0.76 * WT/100)/1.051 #> VHT = (0.47 * WT/100)/1.03 #> VBR = (2 * WT/100)/1.036 #> VMU = (40 * WT/100)/1.041 #> VAD = (21.42 * WT/100)/0.916 #> VSK = (3.71 * WT/100)/1.116 #> VSP = (0.26 * WT/100)/1.054 #> VPA = (0.14 * WT/100)/1.045 #> VLI = (2.57 * WT/100)/1.04 #> VST = (0.21 * WT/100)/1.05 #> VGU = (1.44 * WT/100)/1.043 #> VBO = (14.29 * WT/100)/1.99 #> VKI = (0.44 * WT/100)/1.05 #> VAB = (2.81 * WT/100)/1.04 #> VVB = (5.62 * WT/100)/1.04 #> VRB = (3.86 * WT/100)/1.04 #> BP = 0.61 #> fup = 0.028 #> fub = fup/BP #> KbLU = exp(0.8334) #> KbHT = exp(1.1205) #> KbSK = exp(-0.5238) #> KbSP = exp(0.3224) #> KbPA = exp(0.3224) #> KbLI = exp(1.7604) #> KbST = exp(0.3224) #> KbGU = exp(1.2026) #> KbKI = exp(1.3171) #> S15 = VVB * BP/1000 #> C15 = Venous_Blood/S15 #> d/dt(Lungs) = QLU * (Venous_Blood/VVB - Lungs/KbLU/VLU) #> d/dt(Heart) = QHT * (Arterial_Blood/VAB - Heart/KbHT/VHT) #> d/dt(Brain) = QBR * (Arterial_Blood/VAB - Brain/KbBR/VBR) #> d/dt(Muscles) = QMU * (Arterial_Blood/VAB - Muscles/KbMU/VMU) #> d/dt(Adipose) = QAD * (Arterial_Blood/VAB - Adipose/KbAD/VAD) #> d/dt(Skin) = QSK * (Arterial_Blood/VAB - Skin/KbSK/VSK) #> d/dt(Spleen) = QSP * (Arterial_Blood/VAB - Spleen/KbSP/VSP) #> d/dt(Pancreas) = QPA * (Arterial_Blood/VAB - Pancreas/KbPA/VPA) #> d/dt(Liver) = QHA * Arterial_Blood/VAB + QSP * Spleen/KbSP/VSP + #> QPA * Pancreas/KbPA/VPA + QST * Stomach/KbST/VST + #> QGU * Gut/KbGU/VGU - CLint * fub * Liver/KbLI/VLI - #> QLI * Liver/KbLI/VLI #> d/dt(Stomach) = QST * (Arterial_Blood/VAB - Stomach/KbST/VST) #> d/dt(Gut) = QGU * (Arterial_Blood/VAB - Gut/KbGU/VGU) #> d/dt(Bones) = QBO * (Arterial_Blood/VAB - Bones/KbBO/VBO) #> d/dt(Kidneys) = QKI * (Arterial_Blood/VAB - Kidneys/KbKI/VKI) #> d/dt(Arterial_Blood) = QLU * (Lungs/KbLU/VLU - Arterial_Blood/VAB) #> d/dt(Venous_Blood) = QHT * Heart/KbHT/VHT + QBR * Brain/KbBR/VBR + #> QMU * Muscles/KbMU/VMU + QAD * Adipose/KbAD/VAD + #> QSK * Skin/KbSK/VSK + QLI * Liver/KbLI/VLI + QBO * #> Bones/KbBO/VBO + QKI * Kidneys/KbKI/VKI + QRB * Rest_of_Body/KbRB/VRB - #> QLU * Venous_Blood/VVB #> d/dt(Rest_of_Body) = QRB * (Arterial_Blood/VAB - Rest_of_Body/KbRB/VRB) #> }) #> } pbpk <- pbpk$simulationModel #> using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’ summary(pbpk) #> rxode2 2.1.1.9000 model named rx_45cececb1f44bc6825377e86555bf32a model (ready). #> DLL: /tmp/RtmpQvsiAp/rxode2/rx_45cececb1f44bc6825377e86555bf32a__.rxd/rx_45cececb1f44bc6825377e86555bf32a_.so #> NULL #> #> Calculated Variables: #> [1] \"KbBR\" \"KbMU\" \"KbAD\" \"CLint\" \"KbBO\" \"KbRB\" \"CO\" \"QHT\" \"QBR\" #> [10] \"QMU\" \"QAD\" \"QSK\" \"QSP\" \"QPA\" \"QLI\" \"QST\" \"QGU\" \"QHA\" #> [19] \"QBO\" \"QKI\" \"QRB\" \"QLU\" \"VLU\" \"VHT\" \"VBR\" \"VMU\" \"VAD\" #> [28] \"VSK\" \"VSP\" \"VPA\" \"VLI\" \"VST\" \"VGU\" \"VBO\" \"VKI\" \"VAB\" #> [37] \"VVB\" \"VRB\" \"fub\" \"KbLU\" \"KbHT\" \"KbSK\" \"KbSP\" \"KbPA\" \"KbLI\" #> [46] \"KbST\" \"KbGU\" \"KbKI\" \"S15\" \"C15\" #> -- rxode2 Model Syntax -- #> rxode2({ #> param(lKbBR, lKbMU, lKbAD, lCLint, eta.LClint, lKbBO, lKbRB, #> WT) #> KbBR = exp(lKbBR) #> KbMU = exp(lKbMU) #> KbAD = exp(lKbAD) #> CLint = exp(lCLint + eta.LClint) #> KbBO = exp(lKbBO) #> KbRB = exp(lKbRB) #> CO = (187 * WT^0.81) * 60/1000 #> QHT = 4 * CO/100 #> QBR = 12 * CO/100 #> QMU = 17 * CO/100 #> QAD = 5 * CO/100 #> QSK = 5 * CO/100 #> QSP = 3 * CO/100 #> QPA = 1 * CO/100 #> QLI = 25.5 * CO/100 #> QST = 1 * CO/100 #> QGU = 14 * CO/100 #> QHA = QLI - (QSP + QPA + QST + QGU) #> QBO = 5 * CO/100 #> QKI = 19 * CO/100 #> QRB = CO - (QHT + QBR + QMU + QAD + QSK + QLI + QBO + QKI) #> QLU = QHT + QBR + QMU + QAD + QSK + QLI + QBO + QKI + QRB #> VLU = (0.76 * WT/100)/1.051 #> VHT = (0.47 * WT/100)/1.03 #> VBR = (2 * WT/100)/1.036 #> VMU = (40 * WT/100)/1.041 #> VAD = (21.42 * WT/100)/0.916 #> VSK = (3.71 * WT/100)/1.116 #> VSP = (0.26 * WT/100)/1.054 #> VPA = (0.14 * WT/100)/1.045 #> VLI = (2.57 * WT/100)/1.04 #> VST = (0.21 * WT/100)/1.05 #> VGU = (1.44 * WT/100)/1.043 #> VBO = (14.29 * WT/100)/1.99 #> VKI = (0.44 * WT/100)/1.05 #> VAB = (2.81 * WT/100)/1.04 #> VVB = (5.62 * WT/100)/1.04 #> VRB = (3.86 * WT/100)/1.04 #> BP = 0.61 #> fup = 0.028 #> fub = fup/BP #> KbLU = exp(0.8334) #> KbHT = exp(1.1205) #> KbSK = exp(-0.5238) #> KbSP = exp(0.3224) #> KbPA = exp(0.3224) #> KbLI = exp(1.7604) #> KbST = exp(0.3224) #> KbGU = exp(1.2026) #> KbKI = exp(1.3171) #> S15 = VVB * BP/1000 #> C15 = Venous_Blood/S15 #> d/dt(Lungs) = QLU * (Venous_Blood/VVB - Lungs/KbLU/VLU) #> d/dt(Heart) = QHT * (Arterial_Blood/VAB - Heart/KbHT/VHT) #> d/dt(Brain) = QBR * (Arterial_Blood/VAB - Brain/KbBR/VBR) #> d/dt(Muscles) = QMU * (Arterial_Blood/VAB - Muscles/KbMU/VMU) #> d/dt(Adipose) = QAD * (Arterial_Blood/VAB - Adipose/KbAD/VAD) #> d/dt(Skin) = QSK * (Arterial_Blood/VAB - Skin/KbSK/VSK) #> d/dt(Spleen) = QSP * (Arterial_Blood/VAB - Spleen/KbSP/VSP) #> d/dt(Pancreas) = QPA * (Arterial_Blood/VAB - Pancreas/KbPA/VPA) #> d/dt(Liver) = QHA * Arterial_Blood/VAB + QSP * Spleen/KbSP/VSP + #> QPA * Pancreas/KbPA/VPA + QST * Stomach/KbST/VST + QGU * #> Gut/KbGU/VGU - CLint * fub * Liver/KbLI/VLI - QLI * Liver/KbLI/VLI #> d/dt(Stomach) = QST * (Arterial_Blood/VAB - Stomach/KbST/VST) #> d/dt(Gut) = QGU * (Arterial_Blood/VAB - Gut/KbGU/VGU) #> d/dt(Bones) = QBO * (Arterial_Blood/VAB - Bones/KbBO/VBO) #> d/dt(Kidneys) = QKI * (Arterial_Blood/VAB - Kidneys/KbKI/VKI) #> d/dt(Arterial_Blood) = QLU * (Lungs/KbLU/VLU - Arterial_Blood/VAB) #> d/dt(Venous_Blood) = QHT * Heart/KbHT/VHT + QBR * Brain/KbBR/VBR + #> QMU * Muscles/KbMU/VMU + QAD * Adipose/KbAD/VAD + QSK * #> Skin/KbSK/VSK + QLI * Liver/KbLI/VLI + QBO * Bones/KbBO/VBO + #> QKI * Kidneys/KbKI/VKI + QRB * Rest_of_Body/KbRB/VRB - #> QLU * Venous_Blood/VVB #> d/dt(Rest_of_Body) = QRB * (Arterial_Blood/VAB - Rest_of_Body/KbRB/VRB) #> })"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-cmt.html","id":"changing-compartment-numbers-by-pre-declaring-the-compartments","dir":"Articles","previous_headings":"","what":"Changing compartment numbers by pre-declaring the compartments","title":"Changing rxode2 compartment numbers","text":"add compartments rxode2 model order desire simply need pre-declare compartments cmt. example specifying Venous_Blood Skin 1st 2nd compartments, respectively, simple: can see change simple printout first two compartments Venous_Blood followed Skin.","code":"pbpk2 <- function() { model({ ## Now this is the first compartment, ie cmt=1 cmt(Venous_Blood) ## Skin may be a compartment you wish to dose to as well, ## so it is now cmt=2 cmt(Skin) KbBR = exp(lKbBR) KbMU = exp(lKbMU) KbAD = exp(lKbAD) CLint= exp(lCLint + eta.LClint) KbBO = exp(lKbBO) KbRB = exp(lKbRB) ## Regional blood flows # Cardiac output (L/h) from White et al (1968)m CO = (187.00*WT^0.81)*60/1000; QHT = 4.0 *CO/100; QBR = 12.0*CO/100; QMU = 17.0*CO/100; QAD = 5.0 *CO/100; QSK = 5.0 *CO/100; QSP = 3.0 *CO/100; QPA = 1.0 *CO/100; QLI = 25.5*CO/100; QST = 1.0 *CO/100; QGU = 14.0*CO/100; QHA = QLI - (QSP + QPA + QST + QGU); # Hepatic artery blood flow QBO = 5.0 *CO/100; QKI = 19.0*CO/100; QRB = CO - (QHT + QBR + QMU + QAD + QSK + QLI + QBO + QKI); QLU = QHT + QBR + QMU + QAD + QSK + QLI + QBO + QKI + QRB; ## Organs' volumes = organs' weights / organs' density VLU = (0.76 *WT/100)/1.051; VHT = (0.47 *WT/100)/1.030; VBR = (2.00 *WT/100)/1.036; VMU = (40.00*WT/100)/1.041; VAD = (21.42*WT/100)/0.916; VSK = (3.71 *WT/100)/1.116; VSP = (0.26 *WT/100)/1.054; VPA = (0.14 *WT/100)/1.045; VLI = (2.57 *WT/100)/1.040; VST = (0.21 *WT/100)/1.050; VGU = (1.44 *WT/100)/1.043; VBO = (14.29*WT/100)/1.990; VKI = (0.44 *WT/100)/1.050; VAB = (2.81 *WT/100)/1.040; VVB = (5.62 *WT/100)/1.040; VRB = (3.86 *WT/100)/1.040; ## Fixed parameters BP = 0.61; # Blood:plasma partition coefficient fup = 0.028; # Fraction unbound in plasma fub = fup/BP; # Fraction unbound in blood KbLU = exp(0.8334); KbHT = exp(1.1205); KbSK = exp(-.5238); KbSP = exp(0.3224); KbPA = exp(0.3224); KbLI = exp(1.7604); KbST = exp(0.3224); KbGU = exp(1.2026); KbKI = exp(1.3171); ##----------------------------------------- S15 = VVB*BP/1000; C15 = Venous_Blood/S15 ##----------------------------------------- d/dt(Lungs) = QLU*(Venous_Blood/VVB - Lungs/KbLU/VLU); d/dt(Heart) = QHT*(Arterial_Blood/VAB - Heart/KbHT/VHT); d/dt(Brain) = QBR*(Arterial_Blood/VAB - Brain/KbBR/VBR); d/dt(Muscles) = QMU*(Arterial_Blood/VAB - Muscles/KbMU/VMU); d/dt(Adipose) = QAD*(Arterial_Blood/VAB - Adipose/KbAD/VAD); d/dt(Skin) = QSK*(Arterial_Blood/VAB - Skin/KbSK/VSK); d/dt(Spleen) = QSP*(Arterial_Blood/VAB - Spleen/KbSP/VSP); d/dt(Pancreas) = QPA*(Arterial_Blood/VAB - Pancreas/KbPA/VPA); d/dt(Liver) = QHA*Arterial_Blood/VAB + QSP*Spleen/KbSP/VSP + QPA*Pancreas/KbPA/VPA + QST*Stomach/KbST/VST + QGU*Gut/KbGU/VGU - CLint*fub*Liver/KbLI/VLI - QLI*Liver/KbLI/VLI; d/dt(Stomach) = QST*(Arterial_Blood/VAB - Stomach/KbST/VST); d/dt(Gut) = QGU*(Arterial_Blood/VAB - Gut/KbGU/VGU); d/dt(Bones) = QBO*(Arterial_Blood/VAB - Bones/KbBO/VBO); d/dt(Kidneys) = QKI*(Arterial_Blood/VAB - Kidneys/KbKI/VKI); d/dt(Arterial_Blood) = QLU*(Lungs/KbLU/VLU - Arterial_Blood/VAB); d/dt(Venous_Blood) = QHT*Heart/KbHT/VHT + QBR*Brain/KbBR/VBR + QMU*Muscles/KbMU/VMU + QAD*Adipose/KbAD/VAD + QSK*Skin/KbSK/VSK + QLI*Liver/KbLI/VLI + QBO*Bones/KbBO/VBO + QKI*Kidneys/KbKI/VKI + QRB*Rest_of_Body/KbRB/VRB - QLU*Venous_Blood/VVB; d/dt(Rest_of_Body) = QRB*(Arterial_Blood/VAB - Rest_of_Body/KbRB/VRB); }) } pbpk2 <- pbpk2() pbpk2 #> -- rxode2-based free-form 16-cmt ODE model ------------------------------------- #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 Venous_Blood #> 2 2 Skin #> 3 3 Lungs #> 4 4 Heart #> 5 5 Brain #> 6 6 Muscles #> 7 7 Adipose #> 8 8 Spleen #> 9 9 Pancreas #> 10 10 Liver #> 11 11 Stomach #> 12 12 Gut #> 13 13 Bones #> 14 14 Kidneys #> 15 15 Arterial_Blood #> 16 16 Rest_of_Body #> -- Model (Normalized Syntax): -- #> function() { #> model({ #> cmt(Venous_Blood) #> cmt(Skin) #> KbBR = exp(lKbBR) #> KbMU = exp(lKbMU) #> KbAD = exp(lKbAD) #> CLint = exp(lCLint + eta.LClint) #> KbBO = exp(lKbBO) #> KbRB = exp(lKbRB) #> CO = (187 * WT^0.81) * 60/1000 #> QHT = 4 * CO/100 #> QBR = 12 * CO/100 #> QMU = 17 * CO/100 #> QAD = 5 * CO/100 #> QSK = 5 * CO/100 #> QSP = 3 * CO/100 #> QPA = 1 * CO/100 #> QLI = 25.5 * CO/100 #> QST = 1 * CO/100 #> QGU = 14 * CO/100 #> QHA = QLI - (QSP + QPA + QST + QGU) #> QBO = 5 * CO/100 #> QKI = 19 * CO/100 #> QRB = CO - (QHT + QBR + QMU + QAD + QSK + QLI + QBO + #> QKI) #> QLU = QHT + QBR + QMU + QAD + QSK + QLI + QBO + QKI + #> QRB #> VLU = (0.76 * WT/100)/1.051 #> VHT = (0.47 * WT/100)/1.03 #> VBR = (2 * WT/100)/1.036 #> VMU = (40 * WT/100)/1.041 #> VAD = (21.42 * WT/100)/0.916 #> VSK = (3.71 * WT/100)/1.116 #> VSP = (0.26 * WT/100)/1.054 #> VPA = (0.14 * WT/100)/1.045 #> VLI = (2.57 * WT/100)/1.04 #> VST = (0.21 * WT/100)/1.05 #> VGU = (1.44 * WT/100)/1.043 #> VBO = (14.29 * WT/100)/1.99 #> VKI = (0.44 * WT/100)/1.05 #> VAB = (2.81 * WT/100)/1.04 #> VVB = (5.62 * WT/100)/1.04 #> VRB = (3.86 * WT/100)/1.04 #> BP = 0.61 #> fup = 0.028 #> fub = fup/BP #> KbLU = exp(0.8334) #> KbHT = exp(1.1205) #> KbSK = exp(-0.5238) #> KbSP = exp(0.3224) #> KbPA = exp(0.3224) #> KbLI = exp(1.7604) #> KbST = exp(0.3224) #> KbGU = exp(1.2026) #> KbKI = exp(1.3171) #> S15 = VVB * BP/1000 #> C15 = Venous_Blood/S15 #> d/dt(Lungs) = QLU * (Venous_Blood/VVB - Lungs/KbLU/VLU) #> d/dt(Heart) = QHT * (Arterial_Blood/VAB - Heart/KbHT/VHT) #> d/dt(Brain) = QBR * (Arterial_Blood/VAB - Brain/KbBR/VBR) #> d/dt(Muscles) = QMU * (Arterial_Blood/VAB - Muscles/KbMU/VMU) #> d/dt(Adipose) = QAD * (Arterial_Blood/VAB - Adipose/KbAD/VAD) #> d/dt(Skin) = QSK * (Arterial_Blood/VAB - Skin/KbSK/VSK) #> d/dt(Spleen) = QSP * (Arterial_Blood/VAB - Spleen/KbSP/VSP) #> d/dt(Pancreas) = QPA * (Arterial_Blood/VAB - Pancreas/KbPA/VPA) #> d/dt(Liver) = QHA * Arterial_Blood/VAB + QSP * Spleen/KbSP/VSP + #> QPA * Pancreas/KbPA/VPA + QST * Stomach/KbST/VST + #> QGU * Gut/KbGU/VGU - CLint * fub * Liver/KbLI/VLI - #> QLI * Liver/KbLI/VLI #> d/dt(Stomach) = QST * (Arterial_Blood/VAB - Stomach/KbST/VST) #> d/dt(Gut) = QGU * (Arterial_Blood/VAB - Gut/KbGU/VGU) #> d/dt(Bones) = QBO * (Arterial_Blood/VAB - Bones/KbBO/VBO) #> d/dt(Kidneys) = QKI * (Arterial_Blood/VAB - Kidneys/KbKI/VKI) #> d/dt(Arterial_Blood) = QLU * (Lungs/KbLU/VLU - Arterial_Blood/VAB) #> d/dt(Venous_Blood) = QHT * Heart/KbHT/VHT + QBR * Brain/KbBR/VBR + #> QMU * Muscles/KbMU/VMU + QAD * Adipose/KbAD/VAD + #> QSK * Skin/KbSK/VSK + QLI * Liver/KbLI/VLI + QBO * #> Bones/KbBO/VBO + QKI * Kidneys/KbKI/VKI + QRB * Rest_of_Body/KbRB/VRB - #> QLU * Venous_Blood/VVB #> d/dt(Rest_of_Body) = QRB * (Arterial_Blood/VAB - Rest_of_Body/KbRB/VRB) #> }) #> }"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-cmt.html","id":"appending-compartments-to-the-model","dir":"Articles","previous_headings":"","what":"Appending compartments to the model","title":"Changing rxode2 compartment numbers","text":"can also append “compartments” model. ODE solving internals, add fake compartments model differential equations defined. example legal: can see clearly underlying classic rxode2 model: compartments defined differential equations supported; model : give error:","code":"ode.1c.ka <- function(){ model({ C2 = center/V d / dt(depot) = -KA * depot d/dt(center) = KA * depot - CL*C2 cmt(eff) }) } ode.1c.ka <- ode.1c.ka() print(ode.1c.ka) #> -- rxode2-based free-form 2-cmt ODE model -------------------------------------- #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> -- Model (Normalized Syntax): -- #> function() { #> model({ #> C2 = center/V #> d/dt(depot) = -KA * depot #> d/dt(center) = KA * depot - CL * C2 #> cmt(eff) #> }) #> } ode.1c.ka$simulationModel #> using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’ #> rxode2 2.1.1.9000 model named rx_3c2c707bde58bb58ac7dd2fb5996f24e model (ready). #> x$state: depot, center #> x$stateExtra: eff #> x$params: V, KA, CL #> x$lhs: C2 ode.1c.ka <- rxode2({ cmt(eff) C2 = center/V; d / dt(depot) = -KA * depot d/dt(center) = KA * depot - CL*C2 }) Error in rxModelVars_(obj) : Evaluation error: Compartment 'eff' needs differential equations defined."},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-covariates.html","id":"individual-covariates","dir":"Articles","previous_headings":"","what":"Individual Covariates","title":"rxode2 Covariates","text":"individual covariate wish solve may specify iCov dataset:","code":"library(rxode2) ## rxode2 2.1.1.9000 using 2 threads (see ?getRxThreads) ## no cache: create with `rxCreateCache()` library(units) ## udunits database from /usr/share/xml/udunits/udunits2.xml library(xgxr) mod3 <- function() { ini({ TKA <- 2.94E-01 ## Clearance with individuals TCL <- 1.86E+01 TV2 <-4.02E+01 TQ <-1.05E+01 TV3 <-2.97E+02 TKin <- 1 TKout <- 1 TEC50 <-200 }) model({ KA <- TKA CL <- TCL * (WT / 70) ^ 0.75 V2 <- TV2 Q <- TQ V3 <- TV3 Kin <- TKin Kout <- TKout EC50 <- TEC50 Tz <- 8 amp <- 0.1 C2 <- central/V2 C3 <- peri/V3 d/dt(depot) <- -KA*depot d/dt(central) <- KA*depot - CL*C2 - Q*C2 + Q*C3 d/dt(peri) <- Q*C2 - Q*C3 d/dt(eff) <- Kin - Kout*(1-C2/(EC50+C2))*eff eff(0) <- 1 ## This specifies that the effect compartment starts at 1. }) } ev <- et(amount.units=\"mg\", time.units=\"hours\") %>% et(amt=10000, cmt=1) %>% et(0,48,length.out=100) %>% et(id=1:4) set.seed(10) rxSetSeed(10) ## Now use iCov to simulate a 4-id sample r1 <- solve(mod3, ev, # Create individual covariate data-frame iCov=data.frame(id=1:4, WT=rnorm(4, 70, 10))) ## using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’ print(r1) ## ── Solved rxode2 object ── ## ── Parameters ($params): ── ## TKA TCL TV2 TQ TV3 TKin TKout TEC50 Tz amp ## 0.294 18.600 40.200 10.500 297.000 1.000 1.000 200.000 8.000 0.100 ## ── Initial Conditions ($inits): ── ## depot central peri eff ## 0 0 0 1 ## ── First part of data (object): ── ## # A tibble: 400 × 17 ## id time KA CL V2 Q V3 Kin Kout EC50 C2 C3 depot ## [h] ## 1 1 0 0.294 18.6 40.2 10.5 297 1 1 200 0 0 10000 ## 2 1 0.485 0.294 18.6 40.2 10.5 297 1 1 200 27.8 0.257 8671. ## 3 1 0.970 0.294 18.6 40.2 10.5 297 1 1 200 43.7 0.873 7519. ## 4 1 1.45 0.294 18.6 40.2 10.5 297 1 1 200 51.7 1.68 6520. ## 5 1 1.94 0.294 18.6 40.2 10.5 297 1 1 200 54.7 2.56 5654. ## 6 1 2.42 0.294 18.6 40.2 10.5 297 1 1 200 54.5 3.45 4903. ## # ℹ 394 more rows ## # ℹ 4 more variables: central , peri , eff , WT plot(r1, C2, log=\"y\") ## Warning: Transformation introduced infinite values in continuous y-axis"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-covariates.html","id":"time-varying-covariates","dir":"Articles","previous_headings":"","what":"Time Varying Covariates","title":"rxode2 Covariates","text":"Covariates easy specify rxode2, can specify variable. Time-varying covariates, like clock time circadian rhythm model, can also used. Extending indirect response model already discussed, : Now covariate present event dataset, system can solved combining dataset model: solving ODE equations, solver may sample times outside data. happens, ODE solver can use linear interpolation covariate values. equivalent R’s approxfun method=\"linear\". Note linear approximation case leads kinks solved system 24-hours covariate linear interpolation near 24 near 0. linear seems reasonable, cases like clock time make interpolation methods attractive. rxode2 default covariate interpolation last observation carried forward (locf), constant approximation. equivalent R’s approxfun method=\"constant\". gives following plots: case, plots seem smoother. can also use NONMEM’s preferred interpolation style next observation carried backward (NOCB): gives following plots:","code":"library(rxode2) library(units) mod4 <- mod3 %>% model(d/dt(eff) <- Kin - Kout*(1-C2/(EC50+C2))*eff) %>% model(-Kin) %>% model(Kin <- TKin + amp *cos(2*pi*(ctime-Tz)/24), append=C2, cov=\"ctime\") ev <- et(amountUnits=\"mg\", timeUnits=\"hours\") %>% et(amt=10000, cmt=1) %>% et(0,48,length.out=100) ## Create data frame of 8 am dosing for the first dose This is done ## with base R but it can be done with dplyr or data.table ev$ctime <- (ev$time+set_units(8,hr)) %% 24 ev$WT <- 70 r1 <- solve(mod4, ev, covsInterpolation=\"linear\") print(r1) #> ── Solved rxode2 object ── #> ── Parameters ($params): ── #> TKA TCL TV2 TQ TV3 TKout TEC50 #> 0.294000 18.600000 40.200000 10.500000 297.000000 1.000000 200.000000 #> TKin Tz amp pi #> 1.000000 8.000000 0.100000 3.141593 #> ── Initial Conditions ($inits): ── #> depot central peri eff #> 0 0 0 1 #> ── First part of data (object): ── #> # A tibble: 100 × 17 #> time KA CL V2 Q V3 Kout EC50 C2 Kin C3 depot #> [h] #> 1 0 0.294 18.6 40.2 10.5 297 1 200 0 1.1 0 10000 #> 2 0.485 0.294 18.6 40.2 10.5 297 1 200 27.8 1.10 0.257 8671. #> 3 0.970 0.294 18.6 40.2 10.5 297 1 200 43.7 1.10 0.874 7519. #> 4 1.45 0.294 18.6 40.2 10.5 297 1 200 51.8 1.09 1.68 6520. #> 5 1.94 0.294 18.6 40.2 10.5 297 1 200 54.8 1.09 2.56 5654. #> 6 2.42 0.294 18.6 40.2 10.5 297 1 200 54.6 1.08 3.45 4903. #> # ℹ 94 more rows #> # ℹ 5 more variables: central , peri , eff , ctime [h], WT plot(r1,C2, ylab=\"Central Concentration\") plot(r1,eff) + ylab(\"Effect\") + xlab(\"Time\") r1 <- solve(mod4, ev,covsInterpolation=\"locf\") print(r1) #> ── Solved rxode2 object ── #> ── Parameters ($params): ── #> TKA TCL TV2 TQ TV3 TKout TEC50 #> 0.294000 18.600000 40.200000 10.500000 297.000000 1.000000 200.000000 #> TKin Tz amp pi #> 1.000000 8.000000 0.100000 3.141593 #> ── Initial Conditions ($inits): ── #> depot central peri eff #> 0 0 0 1 #> ── First part of data (object): ── #> # A tibble: 100 × 17 #> time KA CL V2 Q V3 Kout EC50 C2 Kin C3 depot #> [h] #> 1 0 0.294 18.6 40.2 10.5 297 1 200 0 1.1 0 10000 #> 2 0.485 0.294 18.6 40.2 10.5 297 1 200 27.8 1.10 0.257 8671. #> 3 0.970 0.294 18.6 40.2 10.5 297 1 200 43.7 1.10 0.874 7519. #> 4 1.45 0.294 18.6 40.2 10.5 297 1 200 51.8 1.09 1.68 6520. #> 5 1.94 0.294 18.6 40.2 10.5 297 1 200 54.8 1.09 2.56 5654. #> 6 2.42 0.294 18.6 40.2 10.5 297 1 200 54.6 1.08 3.45 4903. #> # ℹ 94 more rows #> # ℹ 5 more variables: central , peri , eff , ctime [h], WT plot(r1,C2, ylab=\"Central Concentration\", xlab=\"Time\") plot(r1,eff, ylab=\"Effect\", xlab=\"Time\") r1 <- solve(mod4, ev,covsInterpolation=\"nocb\") print(r1) #> ── Solved rxode2 object ── #> ── Parameters ($params): ── #> TKA TCL TV2 TQ TV3 TKout TEC50 #> 0.294000 18.600000 40.200000 10.500000 297.000000 1.000000 200.000000 #> TKin Tz amp pi #> 1.000000 8.000000 0.100000 3.141593 #> ── Initial Conditions ($inits): ── #> depot central peri eff #> 0 0 0 1 #> ── First part of data (object): ── #> # A tibble: 100 × 17 #> time KA CL V2 Q V3 Kout EC50 C2 Kin C3 depot #> [h] #> 1 0 0.294 18.6 40.2 10.5 297 1 200 0 1.1 0 10000 #> 2 0.485 0.294 18.6 40.2 10.5 297 1 200 27.8 1.10 0.257 8671. #> 3 0.970 0.294 18.6 40.2 10.5 297 1 200 43.7 1.10 0.874 7519. #> 4 1.45 0.294 18.6 40.2 10.5 297 1 200 51.8 1.09 1.68 6520. #> 5 1.94 0.294 18.6 40.2 10.5 297 1 200 54.8 1.09 2.56 5654. #> 6 2.42 0.294 18.6 40.2 10.5 297 1 200 54.6 1.08 3.45 4903. #> # ℹ 94 more rows #> # ℹ 5 more variables: central , peri , eff , ctime [h], WT plot(r1,C2, ylab=\"Central Concentration\", xlab=\"Time\") plot(r1,eff, ylab=\"Effect\", xlab=\"Time\")"},{"path":[]},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-data-frame.html","id":"creating-an-interactive-data-frame","dir":"Articles","previous_headings":"Using rxode2 data frames","what":"Creating an interactive data frame","title":"rxode2 Data Frames","text":"rxode2 supports returning solved object modified data-frame. done predict(), solve(), rxSolve() methods.","code":"library(rxode2) library(units) ## Setup example model mod1 <- function() { ini({ # central KA <- 2.94E-01 CL <- 1.86E+01 # peripheral V2 <- 4.02E+01 Q <- 1.05E+01 V3 <- 2.97E+02 # effects Kin <- 1 Kout <- 1 EC50 <- 200 }) model({ C2 <- centr/V2 C3 <- peri/V3 d/dt(depot) <- -KA*depot d/dt(centr) <- KA*depot - CL*C2 - Q*C2 + Q*C3 d/dt(peri) <- Q*C2 - Q*C3 d/dt(eff) <- Kin - Kout*(1-C2/(EC50+C2))*eff eff(0) <- 1 }) } ## Seup parameters and initial conditions ## Setup dosing event information ev <- et(amountUnits=\"mg\", timeUnits = \"hours\") %>% et(amt=10000, addl=9, ii=12) %>% et(amt=20000, addl=4, time=120, ii=24) %>% et(0:240) ## Now solve x <- predict(mod1, ev) x #> -- Solved rxode2 object -- #> -- Parameters (x$params): -- #> KA CL V2 Q V3 Kin Kout EC50 #> 0.294 18.600 40.200 10.500 297.000 1.000 1.000 200.000 #> -- Initial Conditions (x$inits): -- #> depot centr peri eff #> 0 0 0 1 #> -- First part of data (object): -- #> # A tibble: 241 x 7 #> time C2 C3 depot centr peri eff #> [h] #> 1 0 0 0 10000 0 0 1 #> 2 1 44.4 0.920 7453. 1784. 273. 1.08 #> 3 2 54.9 2.67 5554. 2206. 794. 1.18 #> 4 3 51.9 4.46 4140. 2087. 1324. 1.23 #> 5 4 44.5 5.98 3085. 1789. 1776. 1.23 #> 6 5 36.5 7.18 2299. 1467. 2132. 1.21 #> # i 235 more rows"},{"path":[]},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-data-frame.html","id":"using-the-solved-object-as-a-simple-data-frame","dir":"Articles","previous_headings":"Using rxode2 data frames","what":"Using the solved object as a simple data frame","title":"rxode2 Data Frames","text":"solved object acts data.frame tbl can filtered dpylr. example filter easily.","code":"library(dplyr) ## You can drop units for comparisons and filtering x <- mod1 %>% solve(ev) %>% drop_units() %>% filter(time <= 3) %>% as_tibble() ## or keep them and compare with the proper units. x <- mod1 %>% solve(ev) %>% filter(time <= set_units(3, hr)) %>% as_tibble() x #> # A tibble: 4 x 7 #> time C2 C3 depot centr peri eff #> [h] #> 1 0 0 0 10000 0 0 1 #> 2 1 44.4 0.920 7453. 1784. 273. 1.08 #> 3 2 54.9 2.67 5554. 2206. 794. 1.18 #> 4 3 51.9 4.46 4140. 2087. 1324. 1.23"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-data-frame.html","id":"updating-the-data-set-interactively","dir":"Articles","previous_headings":"","what":"Updating the data-set interactively","title":"rxode2 Data Frames","text":"However isn’t just simple data object. can use solved object update parameters fly, even change sampling time. First need recreate original solved system:","code":"x <- mod1 %>% solve(ev) print(x) #> -- Solved rxode2 object -- #> -- Parameters ($params): -- #> KA CL V2 Q V3 Kin Kout EC50 #> 0.294 18.600 40.200 10.500 297.000 1.000 1.000 200.000 #> -- Initial Conditions ($inits): -- #> depot centr peri eff #> 0 0 0 1 #> -- First part of data (object): -- #> # A tibble: 241 x 7 #> time C2 C3 depot centr peri eff #> [h] #> 1 0 0 0 10000 0 0 1 #> 2 1 44.4 0.920 7453. 1784. 273. 1.08 #> 3 2 54.9 2.67 5554. 2206. 794. 1.18 #> 4 3 51.9 4.46 4140. 2087. 1324. 1.23 #> 5 4 44.5 5.98 3085. 1789. 1776. 1.23 #> 6 5 36.5 7.18 2299. 1467. 2132. 1.21 #> # i 235 more rows"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-data-frame.html","id":"modifying-observation-times-for-rxode2","dir":"Articles","previous_headings":"Updating the data-set interactively","what":"Modifying observation times for rxode2","title":"rxode2 Data Frames","text":"Notice initial effect now 2. can also change sampling times easily method changing t time. example:","code":"x$t <- seq(0,5,length.out=20) print(x) #> -- Solved rxode2 object -- #> -- Parameters ($params): -- #> KA CL V2 Q V3 Kin Kout EC50 #> 0.294 18.600 40.200 10.500 297.000 1.000 1.000 200.000 #> -- Initial Conditions ($inits): -- #> depot centr peri eff #> 0 0 0 1 #> -- First part of data (object): -- #> # A tibble: 20 x 7 #> time C2 C3 depot centr peri eff #> [h] #> 1 0 0 0 10000 0 0 1 #> 2 0.263 16.8 0.0817 9255. 677. 24.3 1.01 #> 3 0.526 29.5 0.299 8566. 1187. 88.7 1.03 #> 4 0.789 38.9 0.615 7929. 1562. 183. 1.06 #> 5 1.05 45.5 1.00 7338. 1830. 298. 1.09 #> 6 1.32 50.1 1.44 6792. 2013. 427. 1.12 #> # i 14 more rows plot(x)"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-data-frame.html","id":"modifying-simulation-parameters","dir":"Articles","previous_headings":"Updating the data-set interactively","what":"Modifying simulation parameters","title":"rxode2 Data Frames","text":"can also access change parameters $ operator. example, accessing KA can done : may change assigning new value. can access/change parameters, initialization(s) events $params, $inits, $events accessor syntax, similar used . syntax makes easy update explore effect various parameters solved object.","code":"x$KA #> [1] 0.294 x$KA <- 1 print(x) #> -- Solved rxode2 object -- #> -- Parameters ($params): -- #> KA CL V2 Q V3 Kin Kout EC50 #> 1.0 18.6 40.2 10.5 297.0 1.0 1.0 200.0 #> -- Initial Conditions ($inits): -- #> depot centr peri eff #> 0 0 0 1 #> -- First part of data (object): -- #> # A tibble: 20 x 7 #> time C2 C3 depot centr peri eff #> [h] #> 1 0 0 0 10000 0 0 1 #> 2 0.263 52.2 0.261 7686. 2098. 77.6 1.03 #> 3 0.526 83.3 0.900 5908. 3348. 267. 1.09 #> 4 0.789 99.8 1.75 4541. 4010. 519. 1.15 #> 5 1.05 106. 2.69 3490. 4273. 800. 1.21 #> 6 1.32 106. 3.66 2683. 4272. 1086. 1.26 #> # i 14 more rows plot(x)"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-datasets.html","id":"datasets-for-rxode2-nlmixr","dir":"Articles","previous_headings":"","what":"Datasets for rxode2 & nlmixr","title":"rxode2 Event Types","text":"Data input nlmixr type data input rxode2, similar data NONMEM (NONMEM-ready datasets can used directly nlmixr).","code":""},{"path":[]},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-datasets.html","id":"subject-identification-columns","dir":"Articles","previous_headings":"Columns Described by Type of Use","what":"Subject Identification Columns","title":"rxode2 Event Types","text":"subject identification column separates subjects identification random effects. ID: subject identifier may integer, character, factor.","code":""},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-datasets.html","id":"observation-columns","dir":"Articles","previous_headings":"Columns Described by Type of Use","what":"Observation Columns","title":"rxode2 Event Types","text":"Observation columns used indicate dependent variable use measure . DV: numeric column measurement CENS: numeric column indication censoring, limit quantification assay. LIMIT: numeric column helping indicate type censoring, limit quantification assay. MDV: indicator missing DV values CMT: name number compartment DVID: dependent variable identifier EVID event identifier","code":""},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-datasets.html","id":"dosing-columns","dir":"Articles","previous_headings":"Columns Described by Type of Use","what":"Dosing Columns","title":"rxode2 Event Types","text":"AMT: amount dose CMT: name number compartment EVID: event identifier ADDL: number additional doses RATE DUR: rate duration dose","code":""},{"path":[]},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-datasets.html","id":"details-for-specific-dataset-columns","dir":"Articles","previous_headings":"","what":"Details for Specific Dataset Columns","title":"rxode2 Event Types","text":"details sorted alphabetically column name. grouping use, see documentation .","code":""},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-datasets.html","id":"amt-column","dir":"Articles","previous_headings":"Details for Specific Dataset Columns","what":"AMT Column","title":"rxode2 Event Types","text":"AMT column defines amount dose. observation rows, 0 NA. dosing rows, amount dose administered CMT. dose zero-order rate (constant infusion), infusion may setup using RATE DUR column.","code":""},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-datasets.html","id":"censlimit-columns","dir":"Articles","previous_headings":"Details for Specific Dataset Columns","what":"CENS/LIMIT Columns","title":"rxode2 Event Types","text":"CENS column indicator column indicating censoring occurred. pharmacokinetic modeling, censoring typically sample limit quantification. Internally rxode2 saves values nlmixr can use likelihood calculations. CENS = 0 indicates value DV measured without censoring. CENS = 1 indicates value left censored (limit quantitation) value DV censoring/quantitation limit. CENS = -1 indicates value right censored (limit quantitation) value DV censoring/quantitation limit. LIMIT additional information censoring handled nlmixr stored rxode2’s data structure well. value left censored, like limit 1 may also believe value certain threshold, like zero. case, limit 0 indicates censored value 0 1. short : CENS = 0 LIMIT ignored observation censored CENS = 1 value censored (LIMIT, DV) CENS = -1 value censored (DV, LIMIT)","code":""},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-datasets.html","id":"cmt-column","dir":"Articles","previous_headings":"Details for Specific Dataset Columns","what":"CMT Column","title":"rxode2 Event Types","text":"CMT column indicates compartment event occurs. given character string factor (preferred method), matched name model. given integer, matched order compartments appear model.","code":""},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-datasets.html","id":"dur-column","dir":"Articles","previous_headings":"Details for Specific Dataset Columns","what":"DUR Column","title":"rxode2 Event Types","text":"DUR column defines duration infusion. used set duration zero-order rate infusion.","code":""},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-datasets.html","id":"dv-column","dir":"Articles","previous_headings":"Details for Specific Dataset Columns","what":"DV Column","title":"rxode2 Event Types","text":"DV column indicates current measurement current compartment (see CMT) current measurement identifier (see DVID) may missing (see MDV) censored (see CENS).","code":""},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-datasets.html","id":"dvid-column","dir":"Articles","previous_headings":"Details for Specific Dataset Columns","what":"DVID Column","title":"rxode2 Event Types","text":"TODO","code":""},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-datasets.html","id":"evid-column","dir":"Articles","previous_headings":"Details for Specific Dataset Columns","what":"EVID Column","title":"rxode2 Event Types","text":"EVID column event identifier row data. observation records, 0. normal dosing records, 1. Many EVID values detailed rxode2 Event Types Classic rxode2 Events vignettes.","code":""},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-datasets.html","id":"id-column","dir":"Articles","previous_headings":"Details for Specific Dataset Columns","what":"ID Column","title":"rxode2 Event Types","text":"ID column subject identifier. column used separate one individual (usually single person animal) another. model, ID column used separate individuals. numerical integrator re-initializes new individual, new values random effects selected.","code":""},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-datasets.html","id":"rate-column","dir":"Articles","previous_headings":"Details for Specific Dataset Columns","what":"RATE Column","title":"rxode2 Event Types","text":"TODO","code":""},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-event-table.html","id":"creating-rxode2s-event-tables","dir":"Articles","previous_headings":"","what":"Creating rxode2’s event tables","title":"Easy rxode2 Event Tables","text":"event table rxode2 specialized data frame acts container rxode2’s events observation times. create rxode2 event table may use code eventTable(), et(), even create data frame right event information contained . closely related types events rxode2 supports. event table can add sampling/observations doses piping direct access. short table two main functions create dosing Sampling times can added add.sampling( sampling times ) et( sampling times ). Dosing intervals sampling windows also supported. documentation using et() syntax, though supported. models, can illustrate using model shared rxode2 tutorial:","code":"library(rxode2) #> rxode2 2.1.1.9000 using 2 threads (see ?getRxThreads) #> no cache: create with `rxCreateCache()` library(units) #> udunits database from /usr/share/xml/udunits/udunits2.xml (ev <- et()) #> -- EventTable with 0 records -- #> 0 dosing records (see x$get.dosing(); add with add.dosing or et) #> 0 observation times (see x$get.sampling(); add with add.sampling or et) (ev <- et()) #> -- EventTable with 0 records -- #> 0 dosing records (see x$get.dosing(); add with add.dosing or et) #> 0 observation times (see x$get.sampling(); add with add.sampling or et) ## Model from rxode2 tutorial m1 <-function() { ini({ KA <- 2.94E-01 CL <- 1.86E+01 V2 <- 4.02E+01 Q <- 1.05E+01 V3 <- 2.97E+02 Kin <- 1 Kout <- 1 EC50 <- 200 ## Added modeled bioavaiblity, duration and rate fdepot <- 1 durDepot <- 8 rateDepot <- 1250 }) model({ C2 <- centr/V2 C3 <- peri/V3 d/dt(depot) <- -KA*depot f(depot) <- fdepot dur(depot) <- durDepot rate(depot) <- rateDepot d/dt(centr) <- KA*depot - CL*C2 - Q*C2 + Q*C3 d/dt(peri) <- Q*C2 - Q*C3 d/dt(eff) <- Kin - Kout*(1-C2/(EC50+C2))*eff; eff(0) <- 1 }) }"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-event-table.html","id":"adding-doses-to-the-event-table","dir":"Articles","previous_headings":"Creating rxode2’s event tables","what":"Adding doses to the event table","title":"Easy rxode2 Event Tables","text":"created can add dosing event table add.dosing(), et() functions. Using add.dosing() function : Notice units specified table. specified, units use units package keep track units convert needed. Additionally, ggforce uses label ggplot axes. set_units drop_units useful set drop rxode2 event table units. example, can see time axes labeled: familiar NONMEM/rxode2 event records, can also specify dosing using et dose elements directly: gives: shows easy creating event tables can .","code":"ev <- eventTable(amount.units=\"mg\", time.units=\"hr\") ## The methods ar attached to the event table, so you can use ## them directly ev$add.dosing(dose=10000, nbr.doses = 3)# loading doses ## Starts at time 0; Default dosing interval is 24 ## You can also pipe the event tables to these methods. ev <- ev %>% add.dosing(dose=5000, nbr.doses=14, dosing.interval=12)# maintenance ev #> -- EventTable with 2 records -- #> 2 dosing records (see x$get.dosing(); add with add.dosing or et) #> 0 observation times (see x$get.sampling(); add with add.sampling or et) #> multiple doses in `addl` columns, expand with x$expand(); or etExpand(x) #> -- First part of x: -- #> # A tibble: 2 x 5 #> time amt ii addl evid #> [h] [mg] [h] #> 1 0 10000 24 2 1:Dose (Add) #> 2 0 5000 12 13 1:Dose (Add) rxSolve(m1, ev) %>% plot(C2) #> using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’ ev <- et(timeUnits=\"hr\") %>% et(amt=10000, until = set_units(3, days), ii=12) # loading doses ev #> -- EventTable with 1 records -- #> 1 dosing records (see x$get.dosing(); add with add.dosing or et) #> 0 observation times (see x$get.sampling(); add with add.sampling or et) #> multiple doses in `addl` columns, expand with x$expand(); or etExpand(x) #> -- First part of x: -- #> # A tibble: 1 x 5 #> time amt ii addl evid #> [h] [h] #> 1 0 10000 12 6 1:Dose (Add) rxSolve(m1, ev) %>% plot(C2) #> using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-event-table.html","id":"adding-sampling-to-an-event-table","dir":"Articles","previous_headings":"Creating rxode2’s event tables","what":"Adding sampling to an event table","title":"Easy rxode2 Event Tables","text":"notice examples, rxode2 generated default sampling times since sampling times. wish control sampling time, add samples rxode2 event table add.sampling et gives: use et can simply add similar way add.sampling: gives following rxode2 solve: Note jagged nature plots since sample times.","code":"ev <- eventTable(amount.units=\"mg\", time.units=\"hr\") ## The methods ar attached to the event table, so you can use them ## directly ev$add.dosing(dose=10000, nbr.doses = 3)# loading doses ev$add.sampling(seq(0,24,by=4)) ev #> -- EventTable with 8 records -- #> 1 dosing records (see x$get.dosing(); add with add.dosing or et) #> 7 observation times (see x$get.sampling(); add with add.sampling or et) #> multiple doses in `addl` columns, expand with x$expand(); or etExpand(x) #> -- First part of x: -- #> # A tibble: 8 x 5 #> time amt ii addl evid #> [h] [mg] [h] #> 1 0 NA NA NA 0:Observation #> 2 0 10000 24 2 1:Dose (Add) #> 3 4 NA NA NA 0:Observation #> 4 8 NA NA NA 0:Observation #> 5 12 NA NA NA 0:Observation #> 6 16 NA NA NA 0:Observation #> 7 20 NA NA NA 0:Observation #> 8 24 NA NA NA 0:Observation solve(m1, ev) %>% plot(C2) ev <- et(timeUnits=\"hr\") %>% et(amt=10000, until = set_units(3, days), ii=12) %>% # loading doses et(seq(0,24,by=4)) ev #> -- EventTable with 8 records -- #> 1 dosing records (see x$get.dosing(); add with add.dosing or et) #> 7 observation times (see x$get.sampling(); add with add.sampling or et) #> multiple doses in `addl` columns, expand with x$expand(); or etExpand(x) #> -- First part of x: -- #> # A tibble: 8 x 5 #> time amt ii addl evid #> [h] [h] #> 1 0 NA NA NA 0:Observation #> 2 0 10000 12 6 1:Dose (Add) #> 3 4 NA NA NA 0:Observation #> 4 8 NA NA NA 0:Observation #> 5 12 NA NA NA 0:Observation #> 6 16 NA NA NA 0:Observation #> 7 20 NA NA NA 0:Observation #> 8 24 NA NA NA 0:Observation solve(m1, ev) %>% plot(C2)"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-event-table.html","id":"expand-the-event-table-to-a-multi-subject-event-table-","dir":"Articles","previous_headings":"Creating rxode2’s event tables","what":"Expand the event table to a multi-subject event table.","title":"Easy rxode2 Event Tables","text":"thing needed expand event table list IDs want expand; can see following simulation 4 individuals solved :","code":"ev <- et(timeUnits=\"hr\") %>% et(amt=10000, until = set_units(3, days), ii=12) %>% # loading doses et(seq(0,48,length.out=200)) %>% et(id=1:4) ev #> -- EventTable with 804 records -- #> 4 dosing records (see x$get.dosing(); add with add.dosing or et) #> 800 observation times (see x$get.sampling(); add with add.sampling or et) #> multiple doses in `addl` columns, expand with x$expand(); or etExpand(x) #> -- First part of x: -- #> # A tibble: 804 x 6 #> id time amt ii addl evid #> [h] [h] #> 1 1 0 NA NA NA 0:Observation #> 2 1 0 10000 12 6 1:Dose (Add) #> 3 1 0.241 NA NA NA 0:Observation #> 4 1 0.482 NA NA NA 0:Observation #> 5 1 0.724 NA NA NA 0:Observation #> 6 1 0.965 NA NA NA 0:Observation #> 7 1 1.21 NA NA NA 0:Observation #> 8 1 1.45 NA NA NA 0:Observation #> 9 1 1.69 NA NA NA 0:Observation #> 10 1 1.93 NA NA NA 0:Observation #> # i 794 more rows set.seed(42) rxSetSeed(42) solve(m1, ev, params=data.frame(KA=0.294*exp(rnorm(4)), CL=18.6*exp(rnorm(4)))) %>% plot(C2)"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-event-table.html","id":"add-doses-and-samples-within-a-sampling-window","dir":"Articles","previous_headings":"Creating rxode2’s event tables","what":"Add doses and samples within a sampling window","title":"Easy rxode2 Event Tables","text":"addition adding fixed doses fixed sampling times, can windows sample draw doses . dosing windows specify time ordered numerical vector lowest dosing time highest dosing time inside list. example, start dosing time 6 hour dosing window: can clearly see different dosing times following simulation: course reality dosing interval may 2 hours: sort thing can specified sampling times. specify sampling times terms sampling window, can create list sampling times. sampling time two element ordered numeric vector. shows flexibility dosing sampling rxode2 event tables allow.","code":"set.seed(42) rxSetSeed(42) ev <- et(timeUnits=\"hr\") %>% et(time=list(c(0,6)), amt=10000, until = set_units(2, days), ii=12) %>% # loading doses et(id=1:4) ev #> -- EventTable with 16 records -- #> 16 dosing records (see x$get.dosing(); add with add.dosing or et) #> 0 observation times (see x$get.sampling(); add with add.sampling or et) #> -- First part of x: -- #> # A tibble: 16 x 6 #> id low time high amt evid #> [h] [h] [h] #> 1 1 0 5.49 6 10000 1:Dose (Add) #> 2 1 12 17.0 18 10000 1:Dose (Add) #> 3 1 24 25.7 30 10000 1:Dose (Add) #> 4 1 36 41.6 42 10000 1:Dose (Add) #> 5 2 0 4.31 6 10000 1:Dose (Add) #> 6 2 12 14.7 18 10000 1:Dose (Add) #> 7 2 24 28.2 30 10000 1:Dose (Add) #> 8 2 36 39.9 42 10000 1:Dose (Add) #> 9 3 0 0.808 6 10000 1:Dose (Add) #> 10 3 12 16.4 18 10000 1:Dose (Add) #> 11 3 24 27.1 30 10000 1:Dose (Add) #> 12 3 36 39.9 42 10000 1:Dose (Add) #> 13 4 0 4.98 6 10000 1:Dose (Add) #> 14 4 12 13.7 18 10000 1:Dose (Add) #> 15 4 24 29.6 30 10000 1:Dose (Add) #> 16 4 36 41.5 42 10000 1:Dose (Add) ev <- ev %>% et(seq(0,48,length.out=200)) solve(m1, ev, params=data.frame(KA=0.294*exp(rnorm(4)), CL=18.6*exp(rnorm(4)))) %>% plot(C2) set.seed(42) rxSetSeed(42) ev <- et(timeUnits=\"hr\") %>% et(time=list(c(0,2)), amt=10000, until = set_units(2, days), ii=12) %>% # loading doses et(id=1:4) %>% et(seq(0,48,length.out=200)) solve(m1, ev, params=data.frame(KA=0.294*exp(rnorm(4)), CL=18.6*exp(rnorm(4)))) %>% plot(C2) rxSetSeed(42) set.seed(42) ev <- et(timeUnits=\"hr\") %>% et(time=list(c(0,2)), amt=10000, until = set_units(2, days), ii=12) %>% # loading doses et(id=1:4) ## Create 20 samples in the first 24 hours and 20 samples in the ## second 24 hours samples <- c(lapply(1:20, function(...){c(0,24)}), lapply(1:20, function(...){c(20,48)})) ## Add the random collection to the event table ev <- ev %>% et(samples) library(ggplot2) solve(m1, ev, params=data.frame(KA=0.294*exp(rnorm(4)), CL=18.6*exp(rnorm(4)))) %>% plot(C2) + geom_point()"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-event-table.html","id":"combining-event-tables","dir":"Articles","previous_headings":"Creating rxode2’s event tables","what":"Combining event tables","title":"Easy rxode2 Event Tables","text":"Since can create dosing records sampling records, can create complex dosing regimen wish. addition, rxode2 allows combine event tables c, seq, rep, rbind.","code":""},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-event-table.html","id":"sequencing-event-tables","dir":"Articles","previous_headings":"Creating rxode2’s event tables","what":"Sequencing event tables","title":"Easy rxode2 Event Tables","text":"One way combine event table sequence c, seq etSeq. takes two dosing groups adds least one inter-dose interval : sequencing events, can also separate sequence period time; example wanted separate week, easily following sequence event tables: Note example time bid qd event tables exactly one week, 1 week plus 24 hours inter-dose interval. want behavior, can sequence using wait=\"+ii\". Also note, rxode2 assumes dosing want space event tables , clears sampling records combine event tables. true, can also use option samples=\"use\"","code":"## bid for 5 days bid <- et(timeUnits=\"hr\") %>% et(amt=10000,ii=12,until=set_units(5, \"days\")) ## qd for 5 days qd <- et(timeUnits=\"hr\") %>% et(amt=20000,ii=24,until=set_units(5, \"days\")) ## bid for 5 days followed by qd for 5 days et <- seq(bid,qd) %>% et(seq(0,11*24,length.out=100)); rxSolve(m1, et) %>% plot(C2) ## bid for 5 days followed by qd for 5 days et <- seq(bid,set_units(1, \"week\"), qd) %>% et(seq(0,18*24,length.out=100)); rxSolve(m1, et) %>% plot(C2) ## bid for 5 days followed by qd for 5 days et <- seq(bid,set_units(1, \"week\"), qd,wait=\"+ii\") %>% et(seq(0,18*24,length.out=100)); rxSolve(m1, et) %>% plot(C2)"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-event-table.html","id":"repeating-event-tables","dir":"Articles","previous_headings":"Creating rxode2’s event tables","what":"Repeating event tables","title":"Easy rxode2 Event Tables","text":"can event table can repeat etRep rep. example 4 rounds 2 weeks QD therapy 1 week therapy can simply specified: simplified way use sequence event tables. Therefore, many options still apply; samples cleared unless use samples=\"use\", time event tables least inter-dose interval. can adjust timing wait option.","code":"qd <-et(timeUnits = \"hr\") %>% et(amt=10000, ii=24, until=set_units(2, \"weeks\"), cmt=\"depot\") et <- rep(qd, times=4, wait=set_units(1,\"weeks\")) %>% add.sampling(set_units(seq(0, 12.5,by=0.005),weeks)) rxSolve(m1, et) %>% plot(C2)"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-event-table.html","id":"combining-event-tables-with-rbind","dir":"Articles","previous_headings":"Creating rxode2’s event tables","what":"Combining event tables with rbind","title":"Easy rxode2 Event Tables","text":"may combine event tables rbind. consider event times combining event tables, keeps times. space event tables waiting period, also consider inter-dose interval. Using previous seq can clearly see difference. sequence: bind together rbind Still waiting period applies (consider inter-dose interval) can also bind tables together make ID event table unique; can good combine cohorts different expected dosing sampling times. requires id=\"unique\" option; Using first example shows different case:","code":"## bid for 5 days bid <- et(timeUnits=\"hr\") %>% et(amt=10000,ii=12,until=set_units(5, \"days\")) ## qd for 5 days qd <- et(timeUnits=\"hr\") %>% et(amt=20000,ii=24,until=set_units(5, \"days\")) et <- seq(bid,qd) %>% et(seq(0,18*24,length.out=500)); rxSolve(m1, et) %>% plot(C2) ## bid for 5 days et <- rbind(bid,qd) %>% et(seq(0,18*24,length.out=500)); rxSolve(m1, et) %>% plot(C2) et <- rbind(bid,wait=set_units(10,days),qd) %>% et(seq(0,18*24,length.out=500)); rxSolve(m1, et) %>% plot(C2) ## bid for 5 days et <- etRbind(bid,qd, id=\"unique\") %>% et(seq(0,150,length.out=500)); library(ggplot2) rxSolve(m1, et) %>% plot(C2) + facet_wrap( ~ id)"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-event-table.html","id":"event-tables-in-rstudio-notebooks","dir":"Articles","previous_headings":"Creating rxode2’s event tables","what":"Event tables in Rstudio Notebooks","title":"Easy rxode2 Event Tables","text":"addition output console shown examples, Rstudio notebook output different can seen following screenshots; first screenshot shows event table looks evaluating Rstduio notebook simple dataframe allows page contents. click first box Rstudio notebook output, notes event table: ## Expanding events Event tables can expanded contain addl data item, like following example: can expand events addl items $expand() etExpand(ev): first, etExpand(ev) expands event table without modifying original data frame: can see addl events expanded, however original data frame remained intact: use ev$expand() modify ev object. similar object-oriented method:","code":"ev <- et() %>% et(dose=50, ii=8, until=48) ev #> -- EventTable with 1 records -- #> 1 dosing records (see x$get.dosing(); add with add.dosing or et) #> 0 observation times (see x$get.sampling(); add with add.sampling or et) #> multiple doses in `addl` columns, expand with x$expand(); or etExpand(x) #> -- First part of x: -- #> # A tibble: 1 x 5 #> time amt ii addl evid #> #> 1 0 50 8 6 1:Dose (Add) etExpand(ev) #> -- EventTable with 7 records -- #> 7 dosing records (see x$get.dosing(); add with add.dosing or et) #> 0 observation times (see x$get.sampling(); add with add.sampling or et) #> -- First part of x: -- #> # A tibble: 7 x 4 #> time amt ii evid #> #> 1 0 50 0 1:Dose (Add) #> 2 8 50 0 1:Dose (Add) #> 3 16 50 0 1:Dose (Add) #> 4 24 50 0 1:Dose (Add) #> 5 32 50 0 1:Dose (Add) #> 6 40 50 0 1:Dose (Add) #> 7 48 50 0 1:Dose (Add) print(ev) #> -- EventTable with 1 records -- #> 1 dosing records (see $get.dosing(); add with add.dosing or et) #> 0 observation times (see $get.sampling(); add with add.sampling or et) #> multiple doses in `addl` columns, expand with $expand(); or etExpand() #> -- First part of : -- #> # A tibble: 1 x 5 #> time amt ii addl evid #> #> 1 0 50 8 6 1:Dose (Add) ev$expand() ev #> -- EventTable with 7 records -- #> 7 dosing records (see x$get.dosing(); add with add.dosing or et) #> 0 observation times (see x$get.sampling(); add with add.sampling or et) #> -- First part of x: -- #> # A tibble: 7 x 4 #> time amt ii evid #> #> 1 0 50 0 1:Dose (Add) #> 2 8 50 0 1:Dose (Add) #> 3 16 50 0 1:Dose (Add) #> 4 24 50 0 1:Dose (Add) #> 5 32 50 0 1:Dose (Add) #> 6 40 50 0 1:Dose (Add) #> 7 48 50 0 1:Dose (Add)"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-event-types.html","id":"rxode2-event-tables","dir":"Articles","previous_headings":"","what":"rxode2 event tables","title":"rxode2 Event Types","text":"general, rxode2 event tables follow NONMEM dataset convention exceptions: may turn compartment negative compartment number “-cmt” cmt compartment name. compartment data item (cmt) can still number, number compartment defined appearance compartment name model. can tedious count, can specify compartment numbers easier using cmt(cmtName) beginning model. Bioavailability changes change rate infusion since dur/amt fixed input data. Similarly, specifying rate/amt infusion, bioavailability change infusion duration since rate/amt fixed input data. infrequent NONMEM columns supported: pcmt, call. evid=5 replace event; replaces value compartment value specified amt column. equivalent deSolve=replace. evid=6 multiply event; multiplies value compartment value specified amt column. equivalent deSolve=multiply. evid=7 transit compartment model/phantom event. puts dose dose() function calculates time since last dose tad() doesn’t actually put dose compartment. allows transit() function easily apply compartment. legal entries data table: notes: evid can classic RxODE (described ) NONMEM-style evid described . NONMEM’s DV required; rxode2 ODE solving framework. NONMEM’s MDV required, since captured EVID. Instead NONMEM-compatible data, can accept deSolve compatible data-frames. returning rxode2 solved data-set additional event ids (EVID) may see depending solving options: EVID = -1 modeled rate ends (corresponds rate = -1) EVID = -2 modeled duration ends (corresponds rate=-2) EVID = -10 rate specified zero-order infusion ends (corresponds rate > 0) EVID = -20 duration specified zero-order infusion ends (corresponds dur > 0) EVID = 101, 102, 103,... correspond 1, 2, 3, … modeled time (mtime). can accessed solving option combination addDosing=TRUE subsetNonmem=FALSE. want see classic EVID equivalents can use addDosing=NA. illustrate event types use model original rxode2 tutorial.","code":"library(rxode2) #> rxode2 2.1.1.9000 using 2 threads (see ?getRxThreads) #> no cache: create with `rxCreateCache()` ## Model from rxode2 tutorial m1 <- function() { ini({ KA <- 2.94E-01 CL <- 1.86E+01 V2 <- 4.02E+01 Q <- 1.05E+01 V3 <- 2.97E+02 Kin <- 1 Kout <- 1 EC50 <- 200 ## Added modeled bioavaiblity, duration and rate fdepot <- 1 durDepot <- 8 rateDepot <- 1250 }) model({ C2 <- centr/V2 C3 <- peri/V3 d/dt(depot) <- -KA*depot f(depot) <- fdepot dur(depot) <- durDepot rate(depot) <- rateDepot d/dt(centr) <- KA*depot - CL*C2 - Q*C2 + Q*C3 d/dt(peri) <- Q*C2 - Q*C3 d/dt(eff) <- Kin - Kout*(1-C2/(EC50+C2))*eff eff(0) <- 1 }) }"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-event-types.html","id":"bolusadditive-doses","dir":"Articles","previous_headings":"","what":"Bolus/Additive Doses","title":"rxode2 Event Types","text":"bolus dose default type dose rxode2 requires amt/dose. Note uses convenience function et() described rxode2 event tables","code":"ev <- et(timeUnits=\"hr\") %>% et(amt=10000, ii=12,until=24) %>% et(seq(0, 24, length.out=100)) ev #> -- EventTable with 101 records -- #> 1 dosing records (see x$get.dosing(); add with add.dosing or et) #> 100 observation times (see x$get.sampling(); add with add.sampling or et) #> multiple doses in `addl` columns, expand with x$expand(); or etExpand(x) #> -- First part of x: -- #> # A tibble: 101 x 5 #> time amt ii addl evid #> [h] [h] #> 1 0 NA NA NA 0:Observation #> 2 0 10000 12 2 1:Dose (Add) #> 3 0.242 NA NA NA 0:Observation #> 4 0.485 NA NA NA 0:Observation #> 5 0.727 NA NA NA 0:Observation #> 6 0.970 NA NA NA 0:Observation #> 7 1.21 NA NA NA 0:Observation #> 8 1.45 NA NA NA 0:Observation #> 9 1.70 NA NA NA 0:Observation #> 10 1.94 NA NA NA 0:Observation #> # i 91 more rows rxSolve(m1, ev) %>% plot(C2) + xlab(\"Time\")"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-event-types.html","id":"infusion-doses","dir":"Articles","previous_headings":"","what":"Infusion Doses","title":"rxode2 Event Types","text":"different type infusions rxode2 supports: Constant Rate Infusion (rate) Constant Duration Infusion (dur) Estimated Rate Infusion Estimated Duration Infusion","code":""},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-event-types.html","id":"constant-infusion-in-terms-of-duration-and-rate","dir":"Articles","previous_headings":"Infusion Doses","what":"Constant Infusion (in terms of duration and rate)","title":"rxode2 Event Types","text":"next type event infusion; two ways specify infusion; first dur keyword. example : can also specified rate component: exception bioavailability changes infusion. case modeling rate, bioavailability decrease, decreases infusion duration, NONMEM. example: Similarly increasing bioavailability increases infusion duration. rationale behavior rate amt specified event table, thing can change bioavailability increase duration infusion. specify amt dur components event table, bioavailability changes affect rate infusion. can see side--side comparison bioavailability changes affecting rate instead duration records following plots:","code":"ev <- et(timeUnits=\"hr\") %>% et(amt=10000, ii=12,until=24, dur=8) %>% et(seq(0, 24, length.out=100)) ev #> -- EventTable with 101 records -- #> 1 dosing records (see x$get.dosing(); add with add.dosing or et) #> 100 observation times (see x$get.sampling(); add with add.sampling or et) #> multiple doses in `addl` columns, expand with x$expand(); or etExpand(x) #> -- First part of x: -- #> # A tibble: 101 x 6 #> time amt ii addl evid dur #> [h] [h] [h] #> 1 0 NA NA NA 0:Observation NA #> 2 0 10000 12 2 1:Dose (Add) 8 #> 3 0.242 NA NA NA 0:Observation NA #> 4 0.485 NA NA NA 0:Observation NA #> 5 0.727 NA NA NA 0:Observation NA #> 6 0.970 NA NA NA 0:Observation NA #> 7 1.21 NA NA NA 0:Observation NA #> 8 1.45 NA NA NA 0:Observation NA #> 9 1.70 NA NA NA 0:Observation NA #> 10 1.94 NA NA NA 0:Observation NA #> # i 91 more rows rxSolve(m1, ev) %>% plot(depot, C2) + xlab(\"Time\") ev <- et(timeUnits=\"hr\") %>% et(amt=10000, ii=12,until=24, rate=10000/8) %>% et(seq(0, 24, length.out=100)) ev #> -- EventTable with 101 records -- #> 1 dosing records (see x$get.dosing(); add with add.dosing or et) #> 100 observation times (see x$get.sampling(); add with add.sampling or et) #> multiple doses in `addl` columns, expand with x$expand(); or etExpand(x) #> -- First part of x: -- #> # A tibble: 101 x 6 #> time amt rate ii addl evid #> [h] [h] #> 1 0 NA NA NA NA 0:Observation #> 2 0 10000 1250 12 2 1:Dose (Add) #> 3 0.242 NA NA NA NA 0:Observation #> 4 0.485 NA NA NA NA 0:Observation #> 5 0.727 NA NA NA NA 0:Observation #> 6 0.970 NA NA NA NA 0:Observation #> 7 1.21 NA NA NA NA 0:Observation #> 8 1.45 NA NA NA NA 0:Observation #> 9 1.70 NA NA NA NA 0:Observation #> 10 1.94 NA NA NA NA 0:Observation #> # i 91 more rows rxSolve(m1, ev) %>% plot(depot, C2) + xlab(\"Time\") rxSolve(m1, ev, c(fdepot=0.25)) %>% plot(depot, C2) + xlab(\"Time\") rxSolve(m1, ev, c(fdepot=1.25)) %>% plot(depot, C2) + xlab(\"Time\") ev <- et(timeUnits=\"hr\") %>% et(amt=10000, ii=12,until=24, dur=8) %>% et(seq(0, 24, length.out=100)) library(ggplot2) library(patchwork) p1 <- rxSolve(m1, ev, c(fdepot=1.25)) %>% plot(depot) + xlab(\"Time\") + ylim(0,5000) p2 <- rxSolve(m1, ev, c(fdepot=0.25)) %>% plot(depot) + xlab(\"Time\")+ ylim(0,5000) ## Use patchwork syntax to combine plots p1 * p2"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-event-types.html","id":"modeled-rate-and-duration-of-infusion","dir":"Articles","previous_headings":"Infusion Doses","what":"Modeled Rate and Duration of Infusion","title":"rxode2 Event Types","text":"can model duration, equivalent NONMEM’s rate=-2. Similarly, may also model rate. equivalent NONMEM’s rate=-1 rxode2’s event table specifies data item well.","code":"ev <- et(timeUnits=\"hr\") %>% et(amt=10000, ii=12,until=24, rate=-2) %>% et(seq(0, 24, length.out=100)) ev #> -- EventTable with 101 records -- #> 1 dosing records (see x$get.dosing(); add with add.dosing or et) #> 100 observation times (see x$get.sampling(); add with add.sampling or et) #> multiple doses in `addl` columns, expand with x$expand(); or etExpand(x) #> -- First part of x: -- #> # A tibble: 101 x 6 #> time amt rate ii addl evid #> [h] [h] #> 1 0 NA NA NA NA 0:Observation #> 2 0 10000 -2:dur 12 2 1:Dose (Add) #> 3 0.242 NA NA NA NA 0:Observation #> 4 0.485 NA NA NA NA 0:Observation #> 5 0.727 NA NA NA NA 0:Observation #> 6 0.970 NA NA NA NA 0:Observation #> 7 1.21 NA NA NA NA 0:Observation #> 8 1.45 NA NA NA NA 0:Observation #> 9 1.70 NA NA NA NA 0:Observation #> 10 1.94 NA NA NA NA 0:Observation #> # i 91 more rows rxSolve(m1, ev, c(durDepot=7)) %>% plot(depot, C2) + xlab(\"Time\") ev <- et(timeUnits=\"hr\") %>% et(amt=10000, ii=12,until=24, rate=-1) %>% et(seq(0, 24, length.out=100)) ev #> -- EventTable with 101 records -- #> 1 dosing records (see x$get.dosing(); add with add.dosing or et) #> 100 observation times (see x$get.sampling(); add with add.sampling or et) #> multiple doses in `addl` columns, expand with x$expand(); or etExpand(x) #> -- First part of x: -- #> # A tibble: 101 x 6 #> time amt rate ii addl evid #> [h] [h] #> 1 0 NA NA NA NA 0:Observation #> 2 0 10000 -1:rate 12 2 1:Dose (Add) #> 3 0.242 NA NA NA NA 0:Observation #> 4 0.485 NA NA NA NA 0:Observation #> 5 0.727 NA NA NA NA 0:Observation #> 6 0.970 NA NA NA NA 0:Observation #> 7 1.21 NA NA NA NA 0:Observation #> 8 1.45 NA NA NA NA 0:Observation #> 9 1.70 NA NA NA NA 0:Observation #> 10 1.94 NA NA NA NA 0:Observation #> # i 91 more rows rxSolve(m1, ev, c(rateDepot=10000/3)) %>% plot(depot, C2) + xlab(\"Time\")"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-event-types.html","id":"steady-state","dir":"Articles","previous_headings":"","what":"Steady State","title":"rxode2 Event Types","text":"doses solved steady state reached constant inter-dose interval.","code":"ev <- et(timeUnits=\"hr\") %>% et(amt=10000, ii=12, ss=1) %>% et(seq(0, 24, length.out=100)) ev #> -- EventTable with 101 records -- #> 1 dosing records (see x$get.dosing(); add with add.dosing or et) #> 100 observation times (see x$get.sampling(); add with add.sampling or et) #> -- First part of x: -- #> # A tibble: 101 x 5 #> time amt ii evid ss #> [h] [h] #> 1 0 NA NA 0:Observation NA #> 2 0 10000 12 1:Dose (Add) 1 #> 3 0.242 NA NA 0:Observation NA #> 4 0.485 NA NA 0:Observation NA #> 5 0.727 NA NA 0:Observation NA #> 6 0.970 NA NA 0:Observation NA #> 7 1.21 NA NA 0:Observation NA #> 8 1.45 NA NA 0:Observation NA #> 9 1.70 NA NA 0:Observation NA #> 10 1.94 NA NA 0:Observation NA #> # i 91 more rows rxSolve(m1, ev) %>% plot(C2)"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-event-types.html","id":"steady-state-for-complex-dosing","dir":"Articles","previous_headings":"Steady State","what":"Steady state for complex dosing","title":"rxode2 Event Types","text":"using ss=2 flag, can use super-positioning principle linear kinetics get steady state nonstandard dosing (.e. morning 100 mg vs evening 150 mg). done : Saving state values Resetting states solving system steady state Adding back prior state values can see takes full dose cycle reach true complex steady state dosing.","code":"ev <- et(timeUnits=\"hr\") %>% et(amt=10000, ii=24, ss=1) %>% et(time=12, amt=15000, ii=24, ss=2) %>% et(time=24, amt=10000, ii=24, addl=3) %>% et(time=36, amt=15000, ii=24, addl=3) %>% et(seq(0, 64, length.out=500)) library(ggplot2) rxSolve(m1, ev,maxsteps=10000) %>% plot(C2) + annotate(\"rect\", xmin=0, xmax=24, ymin=-Inf, ymax=Inf, alpha=0.2) + annotate(\"text\", x=12.5, y=7, label=\"Initial Steady State Period\") + annotate(\"text\", x=44, y=7, label=\"Steady State AM/PM dosing\")"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-event-types.html","id":"steady-state-for-constant-infusion-or-zero-order-processes","dir":"Articles","previous_headings":"Steady State","what":"Steady state for constant infusion or zero order processes","title":"rxode2 Event Types","text":"last type steady state rxode2 supports steady-state constant infusion rate. can specified way NONMEM, : inter-dose interval ii=0 steady state dose, ie ss=1 Either positive rate (rate>0) estimated rate rate=-1. zero dose, ie amt=0 steady-state constant infusion achieved, infusion turned using record, just like NONMEM. Note rate=-2 model duration infusion doesn’t make much sense since solving infusion steady state. duration specified steady state solution. Also note bioavailability changes steady state infusion also make sense neither change rate duration steady state infusion. Hence modeled bioavailability type dosing event ignored. example: can used PK, can used steady-state disease processes.","code":"ev <- et(timeUnits=\"hr\") %>% et(amt=0, ss=1,rate=10000/8) p1 <- rxSolve(m1, ev) %>% plot(C2, eff) ev <- et(timeUnits=\"hr\") %>% et(amt=200000, rate=10000/8) %>% et(0, 250, length.out=1000) p2 <- rxSolve(m1, ev) %>% plot(C2, eff) library(patchwork) p1 / p2"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-event-types.html","id":"reset-events","dir":"Articles","previous_headings":"","what":"Reset Events","title":"rxode2 Event Types","text":"Reset events implemented evid=3 evid=reset, reset evid=4 reset dose. solving show happens system system reset 6 hours post-dose. can see compartments reset initial values. next dose start dosing cycle . case, whole system reset dose given","code":"ev <- et(timeUnits=\"hr\") %>% et(amt=10000, ii=12, addl=3) %>% et(time=6, evid=reset) %>% et(seq(0, 24, length.out=100)) ev #> -- EventTable with 102 records -- #> 2 dosing records (see x$get.dosing(); add with add.dosing or et) #> 100 observation times (see x$get.sampling(); add with add.sampling or et) #> multiple doses in `addl` columns, expand with x$expand(); or etExpand(x) #> -- First part of x: -- #> # A tibble: 102 x 5 #> time amt ii addl evid #> [h] [h] #> 1 0 NA NA NA 0:Observation #> 2 0 10000 12 3 1:Dose (Add) #> 3 0.242 NA NA NA 0:Observation #> 4 0.485 NA NA NA 0:Observation #> 5 0.727 NA NA NA 0:Observation #> 6 0.970 NA NA NA 0:Observation #> 7 1.21 NA NA NA 0:Observation #> 8 1.45 NA NA NA 0:Observation #> 9 1.70 NA NA NA 0:Observation #> 10 1.94 NA NA NA 0:Observation #> # i 92 more rows rxSolve(m1, ev) %>% plot(depot,C2, eff) ev <- et(timeUnits=\"hr\") %>% et(amt=10000, ii=12, addl=3) %>% et(time=6, amt=10000, evid=4) %>% et(seq(0, 24, length.out=100)) ev #> -- EventTable with 102 records -- #> 2 dosing records (see x$get.dosing(); add with add.dosing or et) #> 100 observation times (see x$get.sampling(); add with add.sampling or et) #> multiple doses in `addl` columns, expand with x$expand(); or etExpand(x) #> -- First part of x: -- #> # A tibble: 102 x 5 #> time amt ii addl evid #> [h] [h] #> 1 0 NA NA NA 0:Observation #> 2 0 10000 12 3 1:Dose (Add) #> 3 0.242 NA NA NA 0:Observation #> 4 0.485 NA NA NA 0:Observation #> 5 0.727 NA NA NA 0:Observation #> 6 0.970 NA NA NA 0:Observation #> 7 1.21 NA NA NA 0:Observation #> 8 1.45 NA NA NA 0:Observation #> 9 1.70 NA NA NA 0:Observation #> 10 1.94 NA NA NA 0:Observation #> # i 92 more rows rxSolve(m1, ev) %>% plot(depot,C2, eff)"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-event-types.html","id":"turning-off-compartments","dir":"Articles","previous_headings":"","what":"Turning off compartments","title":"rxode2 Event Types","text":"may also turn compartment, similar reset event. Solving shows system: case, depot turned , depot compartment concentrations set initial values compartment concentrations/levels reset. another dose depot administered depot compartment turned back . Note dose compartment turns back compartment dosed. Hence turn effect compartment, continues another dose depot. turn back compartment, zero-dose compartment evid=2 compartment needed.","code":"ev <- et(timeUnits=\"hr\") %>% et(amt=10000, ii=12, addl=3) %>% et(time=6, cmt=\"-depot\", evid=2) %>% et(seq(0, 24, length.out=100)) ev #> -- EventTable with 102 records -- #> 2 dosing records (see x$get.dosing(); add with add.dosing or et) #> 100 observation times (see x$get.sampling(); add with add.sampling or et) #> multiple doses in `addl` columns, expand with x$expand(); or etExpand(x) #> -- First part of x: -- #> # A tibble: 102 x 6 #> time cmt amt ii addl evid #> [h] [h] #> 1 0 (obs) NA NA NA 0:Observation #> 2 0 (default) 10000 12 3 1:Dose (Add) #> 3 0.242 (obs) NA NA NA 0:Observation #> 4 0.485 (obs) NA NA NA 0:Observation #> 5 0.727 (obs) NA NA NA 0:Observation #> 6 0.970 (obs) NA NA NA 0:Observation #> 7 1.21 (obs) NA NA NA 0:Observation #> 8 1.45 (obs) NA NA NA 0:Observation #> 9 1.70 (obs) NA NA NA 0:Observation #> 10 1.94 (obs) NA NA NA 0:Observation #> # i 92 more rows rxSolve(m1, ev) %>% plot(depot,C2, eff) ev <- et(timeUnits=\"hr\") %>% et(amt=10000, ii=12, addl=3) %>% et(time=6, cmt=\"-eff\", evid=2) %>% et(seq(0, 24, length.out=100)) rxSolve(m1, ev) %>% plot(depot,C2, eff) ev <- et(timeUnits=\"hr\") %>% et(amt=10000, ii=12, addl=3) %>% et(time=6, cmt=\"-eff\", evid=2) %>% et(time=12,cmt=\"eff\",evid=2) %>% et(seq(0, 24, length.out=100)) rxSolve(m1, ev) %>% plot(depot,C2, eff)"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-events-classic.html","id":"classic-rxode-evid-values","dir":"Articles","previous_headings":"","what":"Classic RxODE evid values","title":"Classic rxode2 Events","text":"Originally RxODE supported compound event IDs; rxode2 still supports parameters, often useful use normal NONMEM dataset standard used many modeling tools like NONMEM, Monolix nlmixr, described rxode2 types article. Classically, RxODE supported event coding single event id evid described following table. classic EVID concatenate numbers table, infusion compartment 1 10101 infusion compartment 199 119901. EVID = 0 (observations), EVID=2 (type event) EVID=3 supported. Internally EVID=9 non-observation event makes sure system initialized zero; EVID=9 manually set. EVID 10-99 represents modeled time interventions, similar NONMEM’s MTIME. along amount (amt) time columns specify events ODE system. infusions specified EVIDs > 100 amt column represents rate value. Infusion flags 1 2 +amt turn infusion specific compartment -amt turn infusion specific compartment. specify dose/duration place dosing records time duration starts stops. modeled rate/duration infusion flags infusion flag must followed infusion record. number concatenated together form full RxODE event ID, shown following examples:","code":""},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-events-classic.html","id":"bolus-dose-examples","dir":"Articles","previous_headings":"Classic RxODE evid values","what":"Bolus Dose Examples","title":"Classic rxode2 Events","text":"100 bolus dose compartment #1 time 0 100 bolus dose compartment #99 time 0 100 bolus dose compartment #199 time 0","code":""},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-events-classic.html","id":"infusion-event-examples","dir":"Articles","previous_headings":"Classic RxODE evid values","what":"Infusion Event Examples","title":"Classic rxode2 Events","text":"Bolus infusion rate 50 compartment 1 1.5 hr, (modeled bioavailability changes duration infusion) Bolus infusion rate 50 compartment 1 1.5 hr (modeled bioavailability changes rate infusion) Modeled rate amount 50 Modeled duration amount 50","code":""},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-events-classic.html","id":"steady-state-for-classic-rxode-evid-example","dir":"Articles","previous_headings":"Classic RxODE evid values","what":"Steady State for classic RxODE EVID example","title":"Classic rxode2 Events","text":"Steady state dose cmt 1 Steady State super-positioning principle 50 pm 100 dose","code":""},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-events-classic.html","id":"steady-state-with-lagged-dose-for-classic-rxode-evid","dir":"Articles","previous_headings":"Classic RxODE evid values","what":"Steady state with lagged dose for classic RxODE evid","title":"Classic rxode2 Events","text":"Steady state lagged dose bolus dose: time | evid | amt | ii | 0 | 109 | 100 | 24 | 0 | 101 | 100 | 0 | event 109 calculates trough amount steady state passed (ii-lag_time) event 101 applies next steady state dose. Steady state (=2) lagged bolus dose Steady state infusion lag time time | evid | amt | ii | 0 | 10109 | 5 | 24 | 0 | 10108 | -5 | 24 | 0 | 10101 | 5 | | 20 | 10101 | -5 | | case bolus, 10109 event calculates trough concentration ii=24, may (may ) still infusion running. infusion running 10108 event turn infusion appropriate time. infusion completed, 10108 event ignored. next 2 events 10101 represent event times (assuming bioavailability applied).","code":""},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-events-classic.html","id":"turning-off-a-compartment-with-classic-rxode-evid","dir":"Articles","previous_headings":"Classic RxODE evid values","what":"Turning off a compartment with classic RxODE EVID","title":"Classic rxode2 Events","text":"Turn first compartment time 12 Event coding rxode2 encoded single event number evid. compartments 100, coded : event 0 observation events. 100*(Compartment Number) + 1 dose captured amt 10000 + 100*(Compartment Number) + 1 infusion rate captured amt column infusion turned subtracting amt evid stop infusion. compartments greater equal 100, 100s place digits transferred 100,000th place digit. doses 99th compartment evid bolus dose 9901 evid infusion 19901. bolus dose 199th compartment evid bolus dose 109901. infusion dosing record 199th compartment 119901.","code":""},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-intro.html","id":"introduction","dir":"Articles","previous_headings":"","what":"Introduction","title":"Introduction to rxode2","text":"rxode2 R package facilitates simulation ODE models R. designed pharmacometrics models mind, can applied generally ODE model.","code":""},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-intro.html","id":"description-of-rxode2-illustrated-through-an-example","dir":"Articles","previous_headings":"","what":"Description of rxode2 illustrated through an example","title":"Introduction to rxode2","text":"model equations can specified text string, model file R expression. differential algebraic equations permitted. Differential equations specified d/dt(var_name) =. equation can separated semicolon. load rxode2 package compile model: Model parameters may specified ini({}) model block, initial conditions can specified within model cmt(0)= X, like model eff(0) <- 1. may also specify subject variability initial conditions residual error components just like nlmixr2. allows single interface nlmixr2/rxode2 models. Also note, classic rxode2 interface still works just like past (don’t worry breaking code time). fact, can get classic rxode2 model $simulationModel ui object:","code":"library(rxode2) #> rxode2 2.1.1.9000 using 2 threads (see ?getRxThreads) #> no cache: create with `rxCreateCache()` mod1 <- function() { ini({ # central KA=2.94E-01 CL=1.86E+01 V2=4.02E+01 # peripheral Q=1.05E+01 V3=2.97E+02 # effects Kin=1 Kout=1 EC50=200 }) model({ C2 <- centr/V2 C3 <- peri/V3 d/dt(depot) <- -KA*depot d/dt(centr) <- KA*depot - CL*C2 - Q*C2 + Q*C3 d/dt(peri) <- Q*C2 - Q*C3 eff(0) <- 1 d/dt(eff) <- Kin - Kout*(1-C2/(EC50+C2))*eff }) } mod1 <- mod1() # create the ui object (can also use `rxode2(mod1)`) mod1 summary(mod1$simulationModel)"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-intro.html","id":"specify-dosing-and-sampling-in-rxode2","dir":"Articles","previous_headings":"Description of rxode2 illustrated through an example","what":"Specify Dosing and sampling in rxode2","title":"Introduction to rxode2","text":"rxode2 provides simple flexible way specify dosing sampling functions generate event table. First, empty event table generated “et()” function. interface similar NONMEM event tables: can see code, can dose compartment named rxode2 model. slight deviation NONMEM can reduce need compartment renumbering. events can also combined expanded (multi-subject events complex regimens) rbind, c, seq, rep. information creating complex dosing regimens using rxode2 see rxode2 events vignette.","code":"ev <- et(amountUnits=\"mg\", timeUnits=\"hours\") %>% et(amt=10000, addl=9,ii=12,cmt=\"depot\") %>% et(time=120, amt=2000, addl=4, ii=14, cmt=\"depot\") %>% et(0:240) # Add sampling"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-intro.html","id":"solving-odes","dir":"Articles","previous_headings":"Description of rxode2 illustrated through an example","what":"Solving ODEs","title":"Introduction to rxode2","text":"ODE can now solved using rxSolve: returns modified data frame. can see compartment values plot : , Note labels automatically labeled units initial event table. rxode2 extracts units label plot (present).","code":"x <- mod1 %>% rxSolve(ev) #> using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’ x #> ── Solved rxode2 object ── #> ── Parameters (x$params): ── #> KA CL V2 Q V3 Kin Kout EC50 #> 0.294 18.600 40.200 10.500 297.000 1.000 1.000 200.000 #> ── Initial Conditions (x$inits): ── #> depot centr peri eff #> 0 0 0 1 #> ── First part of data (object): ── #> # A tibble: 241 × 7 #> time C2 C3 depot centr peri eff #> [h] #> 1 0 0 0 10000 0 0 1 #> 2 1 44.4 0.920 7453. 1784. 273. 1.08 #> 3 2 54.9 2.67 5554. 2206. 794. 1.18 #> 4 3 51.9 4.46 4140. 2087. 1324. 1.23 #> 5 4 44.5 5.98 3085. 1789. 1776. 1.23 #> 6 5 36.5 7.18 2299. 1467. 2132. 1.21 #> # ℹ 235 more rows library(ggplot2) plot(x,C2) + ylab(\"Central Concentration\") plot(x,eff) + ylab(\"Effect\")"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-model-types.html","id":"prediction-only-models","dir":"Articles","previous_headings":"","what":"Prediction only models","title":"rxode2 additional model types","text":"Prediction models simple create. use rxode2 syntax without ODE systems . simple example one-compartment model. Solving rxode2 models saving simple ODE system, faster course.","code":"library(rxode2) ## rxode2 2.1.1.9000 using 2 threads (see ?getRxThreads) ## no cache: create with `rxCreateCache()` mod <- function(){ model({ ipre <- 10 * exp(-ke * t) }) } et <- et(seq(0,24,length.out=50)) cmt1 <- rxSolve(mod,et,params=c(ke=0.5)) ## using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’ cmt1 ## -- Solved rxode2 object -- ## -- Parameters (x$params): -- ## ke ## 0.5 ## -- Initial Conditions (x$inits): -- ## named numeric(0) ## -- First part of data (object): -- ## # A tibble: 50 x 2 ## time ipre ## ## 1 0 10 ## 2 0.490 7.83 ## 3 0.980 6.13 ## 4 1.47 4.80 ## 5 1.96 3.75 ## 6 2.45 2.94 ## # i 44 more rows"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-model-types.html","id":"solved-compartment-models","dir":"Articles","previous_headings":"","what":"Solved compartment models","title":"rxode2 additional model types","text":"Solved models also simple create. simply place linCmt() psuedo-function code. linCmt() function figures type model use based parameter names specified. often, pharmacometric models parameterized terms volume clearances. Clearances specified NONMEM-style names CL, Q, Q1, Q2, etc. distributional clearances CLD, CLD2. Volumes specified Central (VC V), Peripheral/Tissue (VP, VT). translations available, example translations : Another popular parameterization terms micro-constants. rxode2 assumes compartment 1 central compartment. elimination constant specified K, Ke Kel. example translations : last parameterization possible using alpha V //B/C. example translations : linCmt() sleuthing complete, 1, 2 3 compartment model solution used value linCmt(). compartments can dose linear solved system depot central linear absorption constant model ka. Without additional ODEs, compartments numbered depot=1 central=2. absorption constant ka missing, may dose central compartment. Without additional ODEs compartment number central=1. compartments take sort events ODE model can take, discussed rxode2 events vignette. acts ODE model; specify dose depot compartment solve system:","code":"mod <- function() { ini({ kel <- 0.5 V <- 1 }) model({ ipre <- linCmt(V, kel) }) } et <- et(amt=10,time=0,cmt=depot) %>% et(seq(0,24,length.out=50)) cmt1 <- rxSolve(mod,et) ## using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’ cmt1 ## -- Solved rxode2 object -- ## -- Parameters (x$params): -- ## kel V ## 0.5 1.0 ## -- Initial Conditions (x$inits): -- ## named numeric(0) ## -- First part of data (object): -- ## # A tibble: 50 x 2 ## time ipre ## ## 1 0 10 ## 2 0.490 7.83 ## 3 0.980 6.13 ## 4 1.47 4.80 ## 5 1.96 3.75 ## 6 2.45 2.94 ## # i 44 more rows"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-model-types.html","id":"mixing-solved-systems-and-odes","dir":"Articles","previous_headings":"","what":"Mixing Solved Systems and ODEs","title":"rxode2 additional model types","text":"addition pure ODEs, may mix solved systems ODEs. prior 2-compartment indirect response model can simplified linCmt() function: allows indirect response model assign 2-compartment model C2 variable used indirect response model. mixing solved systems ODEs, solved system’s compartment always last compartment. solved system technically isn’t compartment solved. Adding dosing compartment end interfere actual ODE solved. Therefore,two-compartment indirect response model, effect compartment compartment #1 PK dosing compartment depot compartment #2. compartment model requires new event table since compartment number changed: can solved following command: Note solving require specifying effect compartment initial condition 1. Rather, already pre-specified eff(0)=1. can solved different initial conditions easily: rxode2 detective also require specify variables linCmt() function already defined block. Therefore, following function also work solve system. Note specify parameters solving system since built model, can override parameters:","code":"library(rxode2) ## Setup example model mod1 <-function() { model({ C2 = centr/V2 C3 = peri/V3 d/dt(depot) =-KA*depot d/dt(centr) = KA*depot - CL*C2 - Q*C2 + Q*C3 d/dt(peri) = Q*C2 - Q*C3 d/dt(eff) = Kin - Kout*(1-C2/(EC50+C2))*eff }) } ## Seup parameters and initial conditions theta <- c(KA=2.94E-01, CL=1.86E+01, V2=4.02E+01, # central Q=1.05E+01, V3=2.97E+02, # peripheral Kin=1, Kout=1, EC50=200) # effects inits <- c(eff=1) ## Setup dosing event information ev <- et(amountUnits=\"mg\", timeUnits=\"hours\") %>% et(amt=10000, addl=9, ii=12) %>% et(amt=20000, addl=4, time=120, ii=24) %>% add.sampling(0:240) ## Setup a mixed solved/ode system: mod2 <- function() { model({ ## the order of variables do not matter, the type of compartmental ## model is determined by the parameters specified. C2 = linCmt(KA, CL, V2, Q, V3); eff(0) = 1 ## This specifies that the effect compartment starts at 1. d/dt(eff) = Kin - Kout*(1-C2/(EC50+C2))*eff; }) } ev <- et(amountUnits='mg', timeUnits='hours') %>% et(amt=10000, addl=9, ii=12, cmt=2) %>% et(amt=20000, addl=4, time=120, ii=24, cmt=2) %>% et(0:240) x <- mod2 %>% solve(theta, ev) ## using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’ print(x) ## -- Solved rxode2 object -- ## -- Parameters ($params): -- ## KA CL V2 Q V3 Kin Kout EC50 ## 0.294 18.600 40.200 10.500 297.000 1.000 1.000 200.000 ## -- Initial Conditions ($inits): -- ## eff ## 1 ## -- First part of data (object): -- ## # A tibble: 241 x 3 ## time C2 eff ## [h] ## 1 0 249. 1 ## 2 1 121. 1.35 ## 3 2 60.3 1.38 ## 4 3 31.0 1.28 ## 5 4 17.0 1.18 ## 6 5 10.2 1.11 ## # i 235 more rows x <- mod2 %>% solve(theta, ev,c(eff=2)) print(x) ## -- Solved rxode2 object -- ## -- Parameters ($params): -- ## KA CL V2 Q V3 Kin Kout EC50 ## 0.294 18.600 40.200 10.500 297.000 1.000 1.000 200.000 ## -- Initial Conditions ($inits): -- ## eff ## 2 ## -- First part of data (object): -- ## # A tibble: 241 x 3 ## time C2 eff ## [h] ## 1 0 249. 2 ## 2 1 121. 1.93 ## 3 2 60.3 1.67 ## 4 3 31.0 1.41 ## 5 4 17.0 1.23 ## 6 5 10.2 1.13 ## # i 235 more rows mod3 <- function() { ini({ KA <- 2.94E-01 CL <- 1.86E+01 V2 <- 4.02E+01 Q <- 1.05E+01 V3 <- 2.97E+02 Kin <- 1 Kout <- 1 EC50 <- 200 }) model({ # Since the parameters are in the ini block, put them in linCmt so # that the model is detected correctly C2 <- linCmt(KA, CL, V2, Q, V3) eff(0) <- 1 ## This specifies that the effect compartment starts at 1. d/dt(eff) <- Kin - Kout*(1-C2/(EC50+C2))*eff; }) } x <- mod3 %>% solve(ev) print(x) ## -- Solved rxode2 object -- ## -- Parameters ($params): -- ## KA CL V2 Q V3 Kin Kout EC50 ## 0.294 18.600 40.200 10.500 297.000 1.000 1.000 200.000 ## -- Initial Conditions ($inits): -- ## eff ## 1 ## -- First part of data (object): -- ## # A tibble: 241 x 3 ## time C2 eff ## [h] ## 1 0 249. 1 ## 2 1 121. 1.35 ## 3 2 60.3 1.38 ## 4 3 31.0 1.28 ## 5 4 17.0 1.18 ## 6 5 10.2 1.11 ## # i 235 more rows x <- mod3 %>% solve(c(KA=10),ev) print(x) ## -- Solved rxode2 object -- ## -- Parameters ($params): -- ## KA CL V2 Q V3 Kin Kout EC50 ## 10.0 18.6 40.2 10.5 297.0 1.0 1.0 200.0 ## -- Initial Conditions ($inits): -- ## eff ## 1 ## -- First part of data (object): -- ## # A tibble: 241 x 3 ## time C2 eff ## [h] ## 1 0 249. 1 ## 2 1 121. 1.35 ## 3 2 60.3 1.38 ## 4 3 31.0 1.28 ## 5 4 17.0 1.18 ## 6 5 10.2 1.11 ## # i 235 more rows"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-nesting.html","id":"nesting-in-rxode2","dir":"Articles","previous_headings":"","what":"Nesting in rxode2","title":"Nesting levels in rxode2","text":"one level nesting possible rxode2; example using following uncertainties sources variability:","code":""},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-nesting.html","id":"event-table","dir":"Articles","previous_headings":"Nesting in rxode2","what":"Event table","title":"Nesting levels in rxode2","text":"event table contains nesting variables: inv: investigator id id: subject id eye: eye id (left right) occ: occasion","code":"library(rxode2) #> rxode2 2.1.1.9000 using 2 threads (see ?getRxThreads) #> no cache: create with `rxCreateCache()` library(dplyr) #> #> Attaching package: 'dplyr' #> The following objects are masked from 'package:stats': #> #> filter, lag #> The following objects are masked from 'package:base': #> #> intersect, setdiff, setequal, union et(amountUnits=\"mg\", timeUnits=\"hours\") %>% et(amt=10000, addl=9,ii=12,cmt=\"depot\") %>% et(time=120, amt=2000, addl=4, ii=14, cmt=\"depot\") %>% et(seq(0, 240, by=4)) %>% # Assumes sampling when there is no dosing information et(seq(0, 240, by=4) + 0.1) %>% ## adds 0.1 for separate eye et(id=1:20) %>% ## Add an occasion per dose mutate(occ=cumsum(!is.na(amt))) %>% mutate(occ=ifelse(occ == 0, 1, occ)) %>% mutate(occ=2- occ %% 2) %>% mutate(eye=ifelse(round(time) == time, 1, 2)) %>% mutate(inv=ifelse(id < 10, 1, 2)) %>% as_tibble -> ev"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-nesting.html","id":"rxode2-model","dir":"Articles","previous_headings":"Nesting in rxode2","what":"rxode2 model","title":"Nesting levels in rxode2","text":"creates rxode2 model multi-level nesting. Note variables inv.Cl, inv.Ka, eta.Cl etc; need one variable level nesting.","code":"mod <- rxode2({ ## Clearance with individuals eff(0) = 1 C2 = centr/V2*(1+prop.sd) C3 = peri/V3 CL = TCl*exp(eta.Cl + eye.Cl + iov.Cl + inv.Cl) KA = TKA * exp(eta.Ka + eye.Ka + iov.Cl + inv.Ka) d/dt(depot) =-KA*depot d/dt(centr) = KA*depot - CL*C2 - Q*C2 + Q*C3 d/dt(peri) = Q*C2 - Q*C3 d/dt(eff) = Kin - Kout*(1-C2/(EC50+C2))*eff ef0 = eff + add.sd }) #> using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-nesting.html","id":"uncertainty-in-model-parameters","dir":"Articles","previous_headings":"Nesting in rxode2","what":"Uncertainty in Model parameters","title":"Nesting levels in rxode2","text":"","code":"theta <- c(\"TKA\"=0.294, \"TCl\"=18.6, \"V2\"=40.2, \"Q\"=10.5, \"V3\"=297, \"Kin\"=1, \"Kout\"=1, \"EC50\"=200) ## Creating covariance matrix tmp <- matrix(rnorm(8^2), 8, 8) tMat <- tcrossprod(tmp, tmp) / (8 ^ 2) dimnames(tMat) <- list(names(theta), names(theta)) tMat #> TKA TCl V2 Q V3 Kin #> TKA 0.097505124 -0.062632381 0.002185946 -0.05914820 -0.03199291 0.05191104 #> TCl -0.062632381 0.143171198 -0.008142099 0.05343880 -0.05722191 0.02899693 #> V2 0.002185946 -0.008142099 0.154042336 -0.02971687 0.05260648 -0.01051195 #> Q -0.059148203 0.053438800 -0.029716875 0.22633127 -0.03319782 -0.02766129 #> V3 -0.031992913 -0.057221913 0.052606476 -0.03319782 0.13971052 -0.05199069 #> Kin 0.051911038 0.028996932 -0.010511954 -0.02766129 -0.05199069 0.07440267 #> Kout 0.002767053 -0.029273941 0.027177995 0.05301177 -0.01928564 -0.01900449 #> EC50 0.042999966 0.029589661 0.025228785 -0.02581527 -0.06561574 0.05785742 #> Kout EC50 #> TKA 0.002767053 0.04299997 #> TCl -0.029273941 0.02958966 #> V2 0.027177995 0.02522879 #> Q 0.053011769 -0.02581527 #> V3 -0.019285641 -0.06561574 #> Kin -0.019004494 0.05785742 #> Kout 0.084064882 0.01531464 #> EC50 0.015314645 0.07068059"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-nesting.html","id":"nesting-variability","dir":"Articles","previous_headings":"Nesting in rxode2","what":"Nesting Variability","title":"Nesting levels in rxode2","text":"specify multiple levels nesting, can specify nested lotri matrix; using approach use condition operator | specify variable nesting occurs ; Bayesian simulation need specify much information parameter; rxode2 nu parameter. case: - id, nu=100 model came 100 subjects - eye, nu=200 model came 200 eyes - occ, nu=200 model came 200 occasions - inv, nu=10 model came 10 investigators specify lotri can use | var(nu=X), :","code":"omega <- lotri(lotri(eta.Cl ~ 0.1, eta.Ka ~ 0.1) | id(nu=100), lotri(eye.Cl ~ 0.05, eye.Ka ~ 0.05) | eye(nu=200), lotri(iov.Cl ~ 0.01, iov.Ka ~ 0.01) | occ(nu=200), lotri(inv.Cl ~ 0.02, inv.Ka ~ 0.02) | inv(nu=10)) omega #> $id #> eta.Cl eta.Ka #> eta.Cl 0.1 0.0 #> eta.Ka 0.0 0.1 #> #> $eye #> eye.Cl eye.Ka #> eye.Cl 0.05 0.00 #> eye.Ka 0.00 0.05 #> #> $occ #> iov.Cl iov.Ka #> iov.Cl 0.01 0.00 #> iov.Ka 0.00 0.01 #> #> $inv #> inv.Cl inv.Ka #> inv.Cl 0.02 0.00 #> inv.Ka 0.00 0.02 #> #> Properties: nu"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-nesting.html","id":"unexplained-variability","dir":"Articles","previous_headings":"Nesting in rxode2","what":"Unexplained variability","title":"Nesting levels in rxode2","text":"last piece variability specify unexplained variability","code":"sigma <- lotri(prop.sd ~ .25, add.sd~ 0.125)"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-nesting.html","id":"solving-the-problem","dir":"Articles","previous_headings":"Nesting in rxode2","what":"Solving the problem","title":"Nesting levels in rxode2","text":"multiple investigators study; investigator number individuals enrolled site. rxode2 automatically determines number investigators simulate effect investigator. output, inv.Cl(inv==1) inv.Cl investigator 1, inv.Cl(inv==2) inv.Cl investigator 2, etc. inv.Cl(inv==1), inv.Cl(inv==2), etc simulated study combined form investigator variability. equation form represent following: look simulated parameters can see inv.Cl(inv==1) inv.Cl(inv==2) s$params; study: eye variability occasion variability individual simulates number variables become eye occasion variability; case eye: look simulation variables (ie eye.Cl(eye==1), eye.Cl(eye==2), etc) change individual combined make eye variability occasion variability can seen pharamcometric models.","code":"s <- rxSolve(mod, theta, ev, thetaMat=tMat, omega=omega, sigma=sigma, sigmaDf=400, nStud=400) #> using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’ #> unhandled error message: EE:[lsoda] 70000 steps taken before reaching tout #> @(lsoda.c:751 #> Warning: some ID(s) could not solve the ODEs correctly; These values are #> replaced with 'NA' print(s) #> -- Solved rxode2 object -- #> -- Parameters ($params): -- #> # A tibble: 8,000 x 24 #> sim.id id `inv.Cl(inv==1)` `inv.Cl(inv==2)` `inv.Ka(inv==1)` #> #> 1 1 1 0.0561 0.00268 0.0989 #> 2 1 2 0.0561 0.00268 0.0989 #> 3 1 3 0.0561 0.00268 0.0989 #> 4 1 4 0.0561 0.00268 0.0989 #> 5 1 5 0.0561 0.00268 0.0989 #> 6 1 6 0.0561 0.00268 0.0989 #> 7 1 7 0.0561 0.00268 0.0989 #> 8 1 8 0.0561 0.00268 0.0989 #> 9 1 9 0.0561 0.00268 0.0989 #> 10 1 10 0.0561 0.00268 0.0989 #> # i 7,990 more rows #> # i 19 more variables: `inv.Ka(inv==2)` , `eye.Cl(eye==1)` , #> # `eye.Cl(eye==2)` , `eye.Ka(eye==1)` , `eye.Ka(eye==2)` , #> # `iov.Cl(occ==1)` , `iov.Cl(occ==2)` , `iov.Ka(occ==1)` , #> # `iov.Ka(occ==2)` , V2 , V3 , TCl , eta.Cl , #> # TKA , eta.Ka , Q , Kin , Kout , EC50 #> -- Initial Conditions ($inits): -- #> depot centr peri eff #> 0 0 0 1 #> #> Simulation with uncertainty in: #> * parameters ($thetaMat for changes) #> * omega matrix ($omegaList) #> #> -- First part of data (object): -- #> # A tibble: 976,000 x 21 #> sim.id id time inv.Cl inv.Ka eye.Cl eye.Ka iov.Cl iov.Ka C2 C3 #> [h]
#> using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’
summary(pbpk)
#> rxode2 2.1.1.9000 model named rx_45cececb1f44bc6825377e86555bf32a model (ready).
-#> DLL: /tmp/RtmpQvsiAp/rxode2/rx_45cececb1f44bc6825377e86555bf32a__.rxd/rx_45cececb1f44bc6825377e86555bf32a_.so
+#> rxode2 2.1.1.9000 model named rx_888e3ca6bf91062251a0666640a91082 model (ready).
+#> DLL: /tmp/RtmpVdj7Cq/rxode2/rx_888e3ca6bf91062251a0666640a91082__.rxd/rx_888e3ca6bf91062251a0666640a91082_.so
#> NULL
#>
#> Calculated Variables:
@@ -732,7 +732,7 @@ Appending compartments to the model
ode.1c.ka$simulationModel
#> using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’
-#> rxode2 2.1.1.9000 model named rx_3c2c707bde58bb58ac7dd2fb5996f24e model (ready).
+#> rxode2 2.1.1.9000 model named rx_155ca4092dddb690ae2ee099e46ed405 model (ready).
#> x$state: depot, center
#> x$stateExtra: eff
#> x$params: V, KA, CL
diff --git a/articles/rxode2-covariates.html b/articles/rxode2-covariates.html
index 97d129071..efd67a70e 100644
--- a/articles/rxode2-covariates.html
+++ b/articles/rxode2-covariates.html
@@ -158,7 +158,7 @@ Advanced Features, Model Types, Techni
rxode2 Covariates
- 2024-01-23
+ 2024-01-30
Source: vignettes/rxode2-covariates.Rmd
rxode2-covariates.Rmd
diff --git a/articles/rxode2-data-frame.html b/articles/rxode2-data-frame.html
index 4da1dcdf8..cec9e4b81 100644
--- a/articles/rxode2-data-frame.html
+++ b/articles/rxode2-data-frame.html
@@ -158,7 +158,7 @@ Advanced Features, Model Types, Techni
rxode2 Data Frames
- 2024-01-23
+ 2024-01-30
Source: vignettes/rxode2-data-frame.Rmd
rxode2-data-frame.Rmd
diff --git a/articles/rxode2-datasets.html b/articles/rxode2-datasets.html
index 443f4dc2c..d21dd8b4e 100644
--- a/articles/rxode2-datasets.html
+++ b/articles/rxode2-datasets.html
@@ -158,7 +158,7 @@ Advanced Features, Model Types, Techni
rxode2 Event Types
- 2024-01-23
+ 2024-01-30
Source: vignettes/rxode2-datasets.Rmd
rxode2-datasets.Rmd
diff --git a/articles/rxode2-event-table.html b/articles/rxode2-event-table.html
index 0ed76ab13..4411f4d04 100644
--- a/articles/rxode2-event-table.html
+++ b/articles/rxode2-event-table.html
@@ -158,7 +158,7 @@ Advanced Features, Model Types, Techni
Easy rxode2 Event Tables
- 2024-01-23
+ 2024-01-30
Source: vignettes/rxode2-event-table.Rmd
rxode2-event-table.Rmd
diff --git a/articles/rxode2-event-types.html b/articles/rxode2-event-types.html
index fed1a2e76..48e10dc65 100644
--- a/articles/rxode2-event-types.html
+++ b/articles/rxode2-event-types.html
@@ -158,7 +158,7 @@ Advanced Features, Model Types, Techni
rxode2 Event Types
- 2024-01-23
+ 2024-01-30
Source: vignettes/rxode2-event-types.Rmd
rxode2-event-types.Rmd
diff --git a/articles/rxode2-events-classic.html b/articles/rxode2-events-classic.html
index d605a6f18..a9c20453f 100644
--- a/articles/rxode2-events-classic.html
+++ b/articles/rxode2-events-classic.html
@@ -158,7 +158,7 @@ Advanced Features, Model Types, Techni
Classic rxode2 Events
- 2024-01-23
+ 2024-01-30
Source: vignettes/rxode2-events-classic.Rmd
rxode2-events-classic.Rmd
diff --git a/articles/rxode2-intro.html b/articles/rxode2-intro.html
index 2cd49edb8..b91a3649e 100644
--- a/articles/rxode2-intro.html
+++ b/articles/rxode2-intro.html
@@ -158,7 +158,7 @@ Advanced Features, Model Types, Techni
Introduction to rxode2
- 2024-01-23
+ 2024-01-30
Source: vignettes/rxode2-intro.Rmd
rxode2-intro.Rmd
diff --git a/articles/rxode2-model-types.html b/articles/rxode2-model-types.html
index 4d1ff19d0..5bf5d26de 100644
--- a/articles/rxode2-model-types.html
+++ b/articles/rxode2-model-types.html
@@ -163,7 +163,7 @@ Advanced Features, Model Types, Techni
rxode2 additional model types
- 2024-01-23
+ 2024-01-30
Source: vignettes/rxode2-model-types.Rmd
rxode2-model-types.Rmd
@@ -238,18 +238,18 @@ Solved compartment modelsVC or V
),
Peripheral/Tissue (VP
, VT
). While more
translations are available, some example translations are below:
-
-Another popular parameterization is in terms of micro-constants.
+
+Another popular parameterization is in terms of micro-constants.
rxode2 assumes compartment 1
is the central compartment.
The elimination constant would be specified by K
,
Ke
or Kel
. Some example translations are
below:
-
-The last parameterization possible is using alpha
and
+
+The last parameterization possible is using alpha
and
V
and/or A
/B
/C
. Some
example translations are below:
-
-Once the linCmt()
sleuthing is complete, the
+
+Once the linCmt()
sleuthing is complete, the
1
, 2
or 3
compartment model
solution is used as the value of linCmt()
.
The compartments where you can dose in a linear solved system are
diff --git a/articles/rxode2-nesting.html b/articles/rxode2-nesting.html
index 8baf1307b..6b027bb80 100644
--- a/articles/rxode2-nesting.html
+++ b/articles/rxode2-nesting.html
@@ -158,7 +158,7 @@
Advanced Features, Model Types, Techni
Nesting levels in rxode2
- 2024-01-23
+ 2024-01-30
Source: vignettes/rxode2-nesting.Rmd
rxode2-nesting.Rmd
@@ -313,24 +313,24 @@ Uncertainty in Model parametersdimnames(tMat) <- list(names(theta), names(theta))
tMat
-#> TKA TCl V2 Q V3 Kin
-#> TKA 0.097505124 -0.062632381 0.002185946 -0.05914820 -0.03199291 0.05191104
-#> TCl -0.062632381 0.143171198 -0.008142099 0.05343880 -0.05722191 0.02899693
-#> V2 0.002185946 -0.008142099 0.154042336 -0.02971687 0.05260648 -0.01051195
-#> Q -0.059148203 0.053438800 -0.029716875 0.22633127 -0.03319782 -0.02766129
-#> V3 -0.031992913 -0.057221913 0.052606476 -0.03319782 0.13971052 -0.05199069
-#> Kin 0.051911038 0.028996932 -0.010511954 -0.02766129 -0.05199069 0.07440267
-#> Kout 0.002767053 -0.029273941 0.027177995 0.05301177 -0.01928564 -0.01900449
-#> EC50 0.042999966 0.029589661 0.025228785 -0.02581527 -0.06561574 0.05785742
-#> Kout EC50
-#> TKA 0.002767053 0.04299997
-#> TCl -0.029273941 0.02958966
-#> V2 0.027177995 0.02522879
-#> Q 0.053011769 -0.02581527
-#> V3 -0.019285641 -0.06561574
-#> Kin -0.019004494 0.05785742
-#> Kout 0.084064882 0.01531464
-#> EC50 0.015314645 0.07068059
+#> TKA TCl V2 Q V3
+#> TKA 0.126848583 -0.032826578 -0.01782012 0.073985411 0.059556312
+#> TCl -0.032826578 0.151271663 0.03931559 -0.051646177 -0.007039095
+#> V2 -0.017820116 0.039315589 0.12984576 -0.020526430 -0.020795502
+#> Q 0.073985411 -0.051646177 -0.02052643 0.117838807 0.038811836
+#> V3 0.059556312 -0.007039095 -0.02079550 0.038811836 0.143854965
+#> Kin 0.045394641 -0.081603448 -0.09260154 0.041152976 0.040346612
+#> Kout 0.000167824 0.003345854 0.05728777 0.001139339 0.049801997
+#> EC50 -0.027327195 -0.038015655 -0.07461475 -0.001034485 -0.001467119
+#> Kin Kout EC50
+#> TKA 0.045394641 0.000167824 -0.027327195
+#> TCl -0.081603448 0.003345854 -0.038015655
+#> V2 -0.092601542 0.057287774 -0.074614754
+#> Q 0.041152976 0.001139339 -0.001034485
+#> V3 0.040346612 0.049801997 -0.001467119
+#> Kin 0.164699412 0.005776729 0.058097097
+#> Kout 0.005776729 0.093264071 -0.020050191
+#> EC50 0.058097097 -0.020050191 0.066070112
Nesting Variability
@@ -408,16 +408,16 @@ Solving the problem#> # A tibble: 8,000 x 24
#> sim.id id `inv.Cl(inv==1)` `inv.Cl(inv==2)` `inv.Ka(inv==1)`
#> <int> <fct> <dbl> <dbl> <dbl>
-#> 1 1 1 0.0561 0.00268 0.0989
-#> 2 1 2 0.0561 0.00268 0.0989
-#> 3 1 3 0.0561 0.00268 0.0989
-#> 4 1 4 0.0561 0.00268 0.0989
-#> 5 1 5 0.0561 0.00268 0.0989
-#> 6 1 6 0.0561 0.00268 0.0989
-#> 7 1 7 0.0561 0.00268 0.0989
-#> 8 1 8 0.0561 0.00268 0.0989
-#> 9 1 9 0.0561 0.00268 0.0989
-#> 10 1 10 0.0561 0.00268 0.0989
+#> 1 1 1 -0.122 0.155 -0.132
+#> 2 1 2 -0.122 0.155 -0.132
+#> 3 1 3 -0.122 0.155 -0.132
+#> 4 1 4 -0.122 0.155 -0.132
+#> 5 1 5 -0.122 0.155 -0.132
+#> 6 1 6 -0.122 0.155 -0.132
+#> 7 1 7 -0.122 0.155 -0.132
+#> 8 1 8 -0.122 0.155 -0.132
+#> 9 1 9 -0.122 0.155 -0.132
+#> 10 1 10 -0.122 0.155 -0.132
#> # i 7,990 more rows
#> # i 19 more variables: `inv.Ka(inv==2)` <dbl>, `eye.Cl(eye==1)` <dbl>,
#> # `eye.Cl(eye==2)` <dbl>, `eye.Ka(eye==1)` <dbl>, `eye.Ka(eye==2)` <dbl>,
@@ -434,14 +434,14 @@ Solving the problem#>
#> -- First part of data (object): --
#> # A tibble: 976,000 x 21
-#> sim.id id time inv.Cl inv.Ka eye.Cl eye.Ka iov.Cl iov.Ka C2 C3
-#> <int> <int> [h] <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
-#> 1 1 1 0 0.0561 0.0989 -0.369 0.216 0.0635 -0.0104 0 0
-#> 2 1 1 0.1 0.0561 0.0989 0.339 0.195 0.0635 -0.0104 -0.671 -0.00418
-#> 3 1 1 4 0.0561 0.0989 -0.369 0.216 0.0635 -0.0104 -11.2 -2.33
-#> 4 1 1 4.1 0.0561 0.0989 0.339 0.195 0.0635 -0.0104 -27.5 -2.41
-#> 5 1 1 8 0.0561 0.0989 -0.369 0.216 0.0635 -0.0104 -44.1 -6.06
-#> 6 1 1 8.1 0.0561 0.0989 0.339 0.195 0.0635 -0.0104 -16.4 -6.17
+#> sim.id id time inv.Cl inv.Ka eye.Cl eye.Ka iov.Cl iov.Ka C2 C3
+#> <int> <int> [h] <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
+#> 1 1 1 0 -0.122 -0.132 0.178 0.202 0.140 -0.114 0 0
+#> 2 1 1 0.1 -0.122 -0.132 0.0179 0.590 0.140 -0.114 21.4 0.0308
+#> 3 1 1 4 -0.122 -0.132 0.178 0.202 0.140 -0.114 27.4 8.06
+#> 4 1 1 4.1 -0.122 -0.132 0.0179 0.590 0.140 -0.114 16.5 8.11
+#> 5 1 1 8 -0.122 -0.132 0.178 0.202 0.140 -0.114 5.53 8.05
+#> 6 1 1 8.1 -0.122 -0.132 0.0179 0.590 0.140 -0.114 2.26 8.03
#> # i 975,994 more rows
#> # i 10 more variables: CL <dbl>, KA <dbl>, ef0 <dbl>, depot <dbl>, centr <dbl>,
#> # peri <dbl>, eff <dbl>, occ <fct>, eye <fct>, inv <fct>
@@ -463,63 +463,63 @@ Solving the problem
print(head(s$params))
#> sim.id id inv.Cl(inv==1) inv.Cl(inv==2) inv.Ka(inv==1) inv.Ka(inv==2)
-#> 1 1 1 0.05613725 0.002676121 0.09886939 -0.1145422
-#> 2 1 2 0.05613725 0.002676121 0.09886939 -0.1145422
-#> 3 1 3 0.05613725 0.002676121 0.09886939 -0.1145422
-#> 4 1 4 0.05613725 0.002676121 0.09886939 -0.1145422
-#> 5 1 5 0.05613725 0.002676121 0.09886939 -0.1145422
-#> 6 1 6 0.05613725 0.002676121 0.09886939 -0.1145422
+#> 1 1 1 -0.1215069 0.1545973 -0.1315419 0.04715879
+#> 2 1 2 -0.1215069 0.1545973 -0.1315419 0.04715879
+#> 3 1 3 -0.1215069 0.1545973 -0.1315419 0.04715879
+#> 4 1 4 -0.1215069 0.1545973 -0.1315419 0.04715879
+#> 5 1 5 -0.1215069 0.1545973 -0.1315419 0.04715879
+#> 6 1 6 -0.1215069 0.1545973 -0.1315419 0.04715879
#> eye.Cl(eye==1) eye.Cl(eye==2) eye.Ka(eye==1) eye.Ka(eye==2) iov.Cl(occ==1)
-#> 1 -0.36889783 0.33918164 0.2162948 0.19535253 0.06345274
-#> 2 -0.14895018 0.07424926 0.1097794 0.15293130 0.05229912
-#> 3 -0.15606853 0.11696081 -0.1158629 0.07757864 0.02750855
-#> 4 0.01562668 -0.19437159 0.3422191 -0.19985282 0.07953385
-#> 5 0.06257184 -0.37364710 -0.3959396 -0.01406317 0.03389101
-#> 6 0.07229385 0.43743875 -0.3090004 0.24403413 0.04431553
+#> 1 0.17768102 0.01792468 0.20248907 0.59034041 0.14004312
+#> 2 0.06489535 0.29199480 0.29632489 0.21877654 0.11411853
+#> 3 0.26209113 0.24908804 0.02238583 0.19128359 -0.03635801
+#> 4 -0.05790927 0.11175879 0.29045175 0.10784750 -0.11147278
+#> 5 0.11253973 -0.54106107 0.12217645 -0.06972935 0.11371664
+#> 6 -0.12160938 0.21721757 0.16076583 0.19466692 0.14876658
#> iov.Cl(occ==2) iov.Ka(occ==1) iov.Ka(occ==2) V2 V3 TCl
-#> 1 0.079961183 -0.01035850 0.05980327 40.18099 296.9346 19.00838
-#> 2 0.144455837 -0.02503950 -0.05779184 40.18099 296.9346 19.00838
-#> 3 0.009428645 0.21422583 0.04698294 40.18099 296.9346 19.00838
-#> 4 -0.064550794 -0.11564902 -0.05483477 40.18099 296.9346 19.00838
-#> 5 -0.006710996 -0.15198013 0.04304332 40.18099 296.9346 19.00838
-#> 6 0.014598965 -0.06497242 -0.02679635 40.18099 296.9346 19.00838
-#> eta.Cl TKA eta.Ka Q Kin Kout EC50
-#> 1 0.325220393 -0.1308913 -0.70691415 10.82697 0.8761277 1.110527 199.9781
-#> 2 -0.239072540 -0.1308913 0.09798957 10.82697 0.8761277 1.110527 199.9781
-#> 3 -0.365966014 -0.1308913 -0.22095613 10.82697 0.8761277 1.110527 199.9781
-#> 4 -0.385975216 -0.1308913 0.43595833 10.82697 0.8761277 1.110527 199.9781
-#> 5 -0.494204338 -0.1308913 -0.43747789 10.82697 0.8761277 1.110527 199.9781
-#> 6 -0.005687513 -0.1308913 0.18786647 10.82697 0.8761277 1.110527 199.9781
+#> 1 0.006036892 -0.114443871 0.12691051 39.87968 297.0515 18.18964
+#> 2 -0.045177500 0.088364808 -0.05786029 39.87968 297.0515 18.18964
+#> 3 -0.071183712 0.055763391 0.05496106 39.87968 297.0515 18.18964
+#> 4 -0.008961117 -0.001915763 -0.12189986 39.87968 297.0515 18.18964
+#> 5 -0.044598387 -0.015648688 0.03349536 39.87968 297.0515 18.18964
+#> 6 0.082074695 0.088764338 -0.04455202 39.87968 297.0515 18.18964
+#> eta.Cl TKA eta.Ka Q Kin Kout EC50
+#> 1 0.346512208 0.5115992 0.15779437 10.4914 1.230806 0.550272 200.0012
+#> 2 -0.429153012 0.5115992 -0.06162353 10.4914 1.230806 0.550272 200.0012
+#> 3 -0.594006469 0.5115992 0.41790229 10.4914 1.230806 0.550272 200.0012
+#> 4 -0.017669131 0.5115992 -0.21379448 10.4914 1.230806 0.550272 200.0012
+#> 5 0.005789727 0.5115992 0.02455379 10.4914 1.230806 0.550272 200.0012
+#> 6 -0.244988767 0.5115992 -0.34299309 10.4914 1.230806 0.550272 200.0012
#> sim.id id inv.Cl(inv==1) inv.Cl(inv==2) inv.Ka(inv==1) inv.Ka(inv==2)
-#> 1 2 1 0.3716316 0.1462637 0.2201585 -0.1795746
-#> 2 2 2 0.3716316 0.1462637 0.2201585 -0.1795746
-#> 3 2 3 0.3716316 0.1462637 0.2201585 -0.1795746
-#> 4 2 4 0.3716316 0.1462637 0.2201585 -0.1795746
-#> 5 2 5 0.3716316 0.1462637 0.2201585 -0.1795746
-#> 6 2 6 0.3716316 0.1462637 0.2201585 -0.1795746
+#> 1 2 1 -0.01057313 -0.2681566 0.1124571 -0.1934464
+#> 2 2 2 -0.01057313 -0.2681566 0.1124571 -0.1934464
+#> 3 2 3 -0.01057313 -0.2681566 0.1124571 -0.1934464
+#> 4 2 4 -0.01057313 -0.2681566 0.1124571 -0.1934464
+#> 5 2 5 -0.01057313 -0.2681566 0.1124571 -0.1934464
+#> 6 2 6 -0.01057313 -0.2681566 0.1124571 -0.1934464
#> eye.Cl(eye==1) eye.Cl(eye==2) eye.Ka(eye==1) eye.Ka(eye==2) iov.Cl(occ==1)
-#> 1 0.16696543 0.070457235 0.04083151 0.2307054 0.05856952
-#> 2 0.11722824 -0.017176892 -0.04952944 -0.2212587 0.08642440
-#> 3 0.02993742 -0.042805106 0.01951154 -0.3526755 0.22378102
-#> 4 -0.04845361 -0.071353576 -0.19917086 -0.7232118 0.08176182
-#> 5 -0.47189049 -0.009489383 0.07986463 0.2155951 -0.11265072
-#> 6 -0.30771112 -0.270450225 0.14291960 -0.1234880 -0.13191721
-#> iov.Cl(occ==2) iov.Ka(occ==1) iov.Ka(occ==2) V2 V3 TCl
-#> 1 0.11407708 -0.025806967 0.096592475 39.76595 296.7083 18.6806
-#> 2 0.03995586 -0.030545407 -0.064031061 39.76595 296.7083 18.6806
-#> 3 -0.05760596 0.040064339 -0.132986456 39.76595 296.7083 18.6806
-#> 4 0.10317142 -0.023111088 0.073936889 39.76595 296.7083 18.6806
-#> 5 0.03014249 -0.009342765 0.078688405 39.76595 296.7083 18.6806
-#> 6 0.03136129 0.038632834 0.007001786 39.76595 296.7083 18.6806
-#> eta.Cl TKA eta.Ka Q Kin Kout EC50
-#> 1 -0.1793494 -0.145803 0.2898582 10.44525 0.5898876 1.22986 199.855
-#> 2 0.5037215 -0.145803 -0.4326681 10.44525 0.5898876 1.22986 199.855
-#> 3 0.2406049 -0.145803 -0.1300759 10.44525 0.5898876 1.22986 199.855
-#> 4 -0.2885122 -0.145803 -0.8424224 10.44525 0.5898876 1.22986 199.855
-#> 5 -0.4313984 -0.145803 0.1490218 10.44525 0.5898876 1.22986 199.855
-#> 6 0.3886682 -0.145803 0.2832276 10.44525 0.5898876 1.22986 199.855
+#> 1 0.188192979 0.15446999 0.06496711 -0.0363898042 0.12166973
+#> 2 0.238059374 -0.15031874 -0.05673069 -0.0380056984 0.03976102
+#> 3 -0.009181288 0.27973679 -0.09273052 0.0008831785 -0.06182943
+#> 4 0.127782122 -0.25292487 -0.28648116 -0.2964420340 0.04841083
+#> 5 0.069248352 0.01308512 0.27893736 0.0179776517 -0.05728655
+#> 6 0.185834266 -0.34968461 -0.21868525 0.1113316292 0.30223133
+#> iov.Cl(occ==2) iov.Ka(occ==1) iov.Ka(occ==2) V2 V3 TCl
+#> 1 0.03663079 -0.11113535 0.03930488 40.30603 297.3599 18.67602
+#> 2 -0.06971917 0.04701878 -0.10809105 40.30603 297.3599 18.67602
+#> 3 -0.05006046 0.02070942 0.05511813 40.30603 297.3599 18.67602
+#> 4 -0.14295695 -0.13590835 -0.11438424 40.30603 297.3599 18.67602
+#> 5 0.01508066 0.04698955 -0.09478923 40.30603 297.3599 18.67602
+#> 6 0.14507034 0.12851272 0.06502513 40.30603 297.3599 18.67602
+#> eta.Cl TKA eta.Ka Q Kin Kout EC50
+#> 1 -0.43592595 0.4782224 0.09977002 10.54849 1.471684 1.390875 199.8732
+#> 2 -0.30435078 0.4782224 -0.16682736 10.54849 1.471684 1.390875 199.8732
+#> 3 0.09160909 0.4782224 0.05367372 10.54849 1.471684 1.390875 199.8732
+#> 4 0.36520870 0.4782224 0.10092741 10.54849 1.471684 1.390875 199.8732
+#> 5 0.42367115 0.4782224 -0.01304600 10.54849 1.471684 1.390875 199.8732
+#> 6 -0.49519424 0.4782224 0.03113892 10.54849 1.471684 1.390875 199.8732
For between eye variability and between occasion variability each
individual simulates a number of variables that become the between eye
and between occasion variability; In the case of the eye:
diff --git a/articles/rxode2-pipeline.html b/articles/rxode2-pipeline.html
index 1f288c049..3c7ffc3c7 100644
--- a/articles/rxode2-pipeline.html
+++ b/articles/rxode2-pipeline.html
@@ -158,7 +158,7 @@ Advanced Features, Model Types, Techni
rxode2 in a pipeline
- 2024-01-23
+ 2024-01-30
Source: vignettes/rxode2-pipeline.Rmd
rxode2-pipeline.Rmd
diff --git a/articles/rxode2-plot.html b/articles/rxode2-plot.html
index 05411e976..ccbafa63f 100644
--- a/articles/rxode2-plot.html
+++ b/articles/rxode2-plot.html
@@ -160,7 +160,7 @@ Advanced Features, Model Types, Techni
Matthew
Fidler
- 2024-01-23
+ 2024-01-30
Source: vignettes/rxode2-plot.Rmd
rxode2-plot.Rmd
diff --git a/articles/rxode2-plot_files/figure-html/unnamed-chunk-10-1.png b/articles/rxode2-plot_files/figure-html/unnamed-chunk-10-1.png
index 39dbb8a9a..3e6b366c8 100644
Binary files a/articles/rxode2-plot_files/figure-html/unnamed-chunk-10-1.png and b/articles/rxode2-plot_files/figure-html/unnamed-chunk-10-1.png differ
diff --git a/articles/rxode2-plot_files/figure-html/unnamed-chunk-6-1.png b/articles/rxode2-plot_files/figure-html/unnamed-chunk-6-1.png
index b18bb4ee0..5c11f93e4 100644
Binary files a/articles/rxode2-plot_files/figure-html/unnamed-chunk-6-1.png and b/articles/rxode2-plot_files/figure-html/unnamed-chunk-6-1.png differ
diff --git a/articles/rxode2-plot_files/figure-html/unnamed-chunk-7-1.png b/articles/rxode2-plot_files/figure-html/unnamed-chunk-7-1.png
index 09ceec962..b35b93d21 100644
Binary files a/articles/rxode2-plot_files/figure-html/unnamed-chunk-7-1.png and b/articles/rxode2-plot_files/figure-html/unnamed-chunk-7-1.png differ
diff --git a/articles/rxode2-plot_files/figure-html/unnamed-chunk-8-1.png b/articles/rxode2-plot_files/figure-html/unnamed-chunk-8-1.png
index 510b6544c..6136ebc84 100644
Binary files a/articles/rxode2-plot_files/figure-html/unnamed-chunk-8-1.png and b/articles/rxode2-plot_files/figure-html/unnamed-chunk-8-1.png differ
diff --git a/articles/rxode2-prior-data.html b/articles/rxode2-prior-data.html
index 1ea74691b..c463d1bb3 100644
--- a/articles/rxode2-prior-data.html
+++ b/articles/rxode2-prior-data.html
@@ -158,7 +158,7 @@ Advanced Features, Model Types, Techni
Using Prior Data for ODE solving
- 2024-01-23
+ 2024-01-30
Source: vignettes/rxode2-prior-data.Rmd
rxode2-prior-data.Rmd
diff --git a/articles/rxode2-rxUse.html b/articles/rxode2-rxUse.html
index c052658ad..9756d748c 100644
--- a/articles/rxode2-rxUse.html
+++ b/articles/rxode2-rxUse.html
@@ -160,7 +160,7 @@ Advanced Features, Model Types, Techni
Matthew
Fidler
- 2024-01-23
+ 2024-01-30
Source: vignettes/rxode2-rxUse.Rmd
rxode2-rxUse.Rmd
diff --git a/articles/rxode2-shiny.html b/articles/rxode2-shiny.html
index edc4b38f3..a8ad791c2 100644
--- a/articles/rxode2-shiny.html
+++ b/articles/rxode2-shiny.html
@@ -158,7 +158,7 @@ Advanced Features, Model Types, Techni
rxode2 and Shiny
- 2024-01-23
+ 2024-01-30
Source: vignettes/rxode2-shiny.Rmd
rxode2-shiny.Rmd
diff --git a/articles/rxode2-sim-var.html b/articles/rxode2-sim-var.html
index 5103d89f3..0cea68fbe 100644
--- a/articles/rxode2-sim-var.html
+++ b/articles/rxode2-sim-var.html
@@ -158,7 +158,7 @@ Advanced Features, Model Types, Techni
rxode2 Simulation
- 2024-01-23
+ 2024-01-30
Source: vignettes/rxode2-sim-var.Rmd
rxode2-sim-var.Rmd
diff --git a/articles/rxode2-single-subject.html b/articles/rxode2-single-subject.html
index 073042231..1d9eb6b93 100644
--- a/articles/rxode2-single-subject.html
+++ b/articles/rxode2-single-subject.html
@@ -158,7 +158,7 @@ Advanced Features, Model Types, Techni
Single Subject ODE solving -- differences from multiple subject
- 2024-01-23
+ 2024-01-30
Source: vignettes/rxode2-single-subject.Rmd
rxode2-single-subject.Rmd
diff --git a/articles/rxode2-speed.html b/articles/rxode2-speed.html
index 77d61d96a..ee26fc8ff 100644
--- a/articles/rxode2-speed.html
+++ b/articles/rxode2-speed.html
@@ -160,7 +160,7 @@ Advanced Features, Model Types, Techni
Matthew
Fidler
- 2024-01-23
+ 2024-01-30
Source: vignettes/rxode2-speed.Rmd
rxode2-speed.Rmd
@@ -263,8 +263,8 @@ A note about t
output. You can see the differences below:
summary(mod1$simulationModel)
-#> rxode2 2.1.1.9000 model named rx_dde7adafaa5c6f5a2e1f34b01767a0af model (✔ ready).
-#> DLL: /tmp/RtmpQvsiAp/rxode2/rx_dde7adafaa5c6f5a2e1f34b01767a0af__.rxd/rx_dde7adafaa5c6f5a2e1f34b01767a0af_.so
+#> rxode2 2.1.1.9000 model named rx_ec464bc9eace073a4527d87acadfddb4 model (✔ ready).
+#> DLL: /tmp/RtmpVdj7Cq/rxode2/rx_ec464bc9eace073a4527d87acadfddb4__.rxd/rx_ec464bc9eace073a4527d87acadfddb4_.so
#> NULL
#>
#> Calculated Variables:
@@ -282,8 +282,8 @@ A note about t
#> })
summary(mod1$simulationIniModel)
#> using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’
-#> rxode2 2.1.1.9000 model named rx_e44e9ee38545b57dae62d04510ccab81 model (✔ ready).
-#> DLL: /tmp/RtmpQvsiAp/rxode2/rx_e44e9ee38545b57dae62d04510ccab81__.rxd/rx_e44e9ee38545b57dae62d04510ccab81_.so
+#> rxode2 2.1.1.9000 model named rx_5a172c6836cda6d471133865d1613f08 model (✔ ready).
+#> DLL: /tmp/RtmpVdj7Cq/rxode2/rx_5a172c6836cda6d471133865d1613f08__.rxd/rx_5a172c6836cda6d471133865d1613f08_.so
#> NULL
#>
#> Calculated Variables:
@@ -309,8 +309,8 @@ A note about t
#> })
summary(mod2f$simulationModel)
#> using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’
-#> rxode2 2.1.1.9000 model named rx_525381b0d2a180cfde7f4fecb32b3a45 model (✔ ready).
-#> DLL: /tmp/RtmpQvsiAp/rxode2/rx_525381b0d2a180cfde7f4fecb32b3a45__.rxd/rx_525381b0d2a180cfde7f4fecb32b3a45_.so
+#> rxode2 2.1.1.9000 model named rx_d175dc97754e25b6601589d6579909e4 model (✔ ready).
+#> DLL: /tmp/RtmpVdj7Cq/rxode2/rx_d175dc97754e25b6601589d6579909e4__.rxd/rx_d175dc97754e25b6601589d6579909e4_.so
#> NULL
#>
#> Calculated Variables:
@@ -366,8 +366,8 @@ A note about t
#> })
summary(mod2f$simulationIniModel)
#> using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’
-#> rxode2 2.1.1.9000 model named rx_1e1e825cbc5725fe5238d9a808269d13 model (✔ ready).
-#> DLL: /tmp/RtmpQvsiAp/rxode2/rx_1e1e825cbc5725fe5238d9a808269d13__.rxd/rx_1e1e825cbc5725fe5238d9a808269d13_.so
+#> rxode2 2.1.1.9000 model named rx_1fa541ac46daeb5fc30a38552ebd1a28 model (✔ ready).
+#> DLL: /tmp/RtmpVdj7Cq/rxode2/rx_1fa541ac46daeb5fc30a38552ebd1a28__.rxd/rx_1fa541ac46daeb5fc30a38552ebd1a28_.so
#> NULL
#>
#> Calculated Variables:
@@ -553,10 +553,10 @@ Compare the times between all
print(bench)
#> Unit: milliseconds
#> expr min lq mean median uq max
-#> runFor() 272.68192 279.27422 293.81865 283.77730 296.50623 431.60477
-#> runSapply() 271.76756 279.56641 289.78392 281.80045 290.21712 399.43239
-#> runSingleThread() 27.14962 27.43392 28.53953 27.65254 28.09581 46.61663
-#> run2Thread() 16.18853 16.43165 17.36998 16.73554 17.11031 27.44037
+#> runFor() 275.27445 282.72659 296.32924 285.36428 296.59053 421.94861
+#> runSapply() 275.42242 282.27560 289.41330 284.19744 288.66425 340.32593
+#> runSingleThread() 27.80331 28.08948 28.58767 28.33210 28.62940 34.20171
+#> run2Thread() 16.46957 16.92515 18.70476 17.21281 17.81127 30.40426
#> neval
#> 100
#> 100
@@ -583,10 +583,10 @@ Compare the times between all
print(bench)
#> Unit: milliseconds
#> expr min lq mean median uq max neval
-#> runThread(1) 27.13695 27.62539 28.89258 28.21513 28.89024 50.12725 100
-#> runThread(2) 16.32435 16.75297 18.91421 17.30626 18.75373 29.18771 100
-#> runThread(3) 17.49259 18.48256 19.99102 20.16053 20.75537 25.10859 100
-#> runThread(4) 16.21415 16.76762 18.08898 17.12330 17.54657 37.09393 100
+#> runThread(1) 27.88072 28.08433 29.26498 28.41125 29.54402 48.86065 100
+#> runThread(2) 16.53631 16.85069 18.65513 17.31703 17.76293 32.22483 100
+#> runThread(3) 17.98543 19.65418 20.38128 20.00796 20.52825 26.88089 100
+#> runThread(4) 16.21520 16.54979 18.03119 17.11132 17.37072 36.57811 100
autoplot(bench)
@@ -675,8 +675,8 @@ Increasing speed with compiler o
print(bench)
#> Unit: milliseconds
#> expr min lq mean median uq max neval
-#> standardCompile 191.3855 300.3776 305.9900 301.8742 306.8112 354.7742 100
-#> fastCompile 193.4735 301.5670 307.5617 303.9288 309.4961 355.8324 100
+#> standardCompile 189.9879 310.2717 315.7530 312.1834 316.6587 372.8248 100
+#> fastCompile 194.8383 309.7847 316.1023 313.0658 319.1076 386.9029 100
autoplot(bench)
@@ -770,7 +770,7 @@ A real life exampleStoplapply <- Sys.time()
print(Stoplapply - Startlapply)
-#> Time difference of 11.60301 secs
+#> Time difference of 13.49471 secs
By applying some of the new parallel solving concepts you can simply
run the same simulation both with less code and faster:
@@ -811,7 +811,7 @@ A real life exampleres <- rxSolve(rx, ev, omega=omega, returnType="data.table")
endParallel <- Sys.time()
print(endParallel - startParallel)
-#> Time difference of 0.104939 secs
+#> Time difference of 0.1269417 secs
You can see a striking time difference between the two methods; A few
things to keep in mind:
+#> [1] gtable_0.3.4 xfun_0.41 bslib_0.6.1
+#> [4] RApiSerialize_0.1.2 lattice_0.21-9 vctrs_0.6.5
+#> [7] tools_4.3.2 generics_0.1.3 tibble_3.2.1
+#> [10] symengine_0.2.4 fansi_1.0.6 highr_0.10
+#> [13] pkgconfig_2.0.3 checkmate_2.3.1 desc_1.4.3
+#> [16] RcppParallel_5.1.7 lifecycle_1.0.4 compiler_4.3.2
+#> [19] farver_2.1.1 stringr_1.5.1 textshaping_0.3.7
+#> [22] munsell_0.5.0 qs_0.25.7 htmltools_0.5.7
+#> [25] sys_3.4.2 sass_0.4.8 yaml_2.3.8
+#> [28] lazyeval_0.2.2 pillar_1.9.0 pkgdown_2.0.7
+#> [31] crayon_1.5.2 jquerylib_0.1.4 cachem_1.0.8
+#> [34] nlme_3.1-163 tidyselect_1.2.0 digest_0.6.34
+#> [37] lotri_0.4.4 stringi_1.8.3 dplyr_1.1.4
+#> [40] purrr_1.0.2 rxode2ll_2.0.11.9000 fastmap_1.1.1
+#> [43] grid_4.3.2 colorspace_2.1-0 rxode2parse_2.0.18
+#> [46] cli_3.6.2 dparser_1.3.1-11 magrittr_2.0.3
+#> [49] utf8_1.2.4 withr_3.0.0 scales_1.3.0
+#> [52] backports_1.4.1 rmarkdown_2.25 ragg_1.2.7
+#> [55] stringfish_0.16.0 memoise_2.0.1 evaluate_0.23
+#> [58] knitr_1.45 rex_1.2.1 rxode2et_2.0.12
+#> [61] rxode2random_2.0.13 PreciseSums_0.6 rlang_1.1.3
+#> [64] Rcpp_1.0.12 glue_1.7.0 jsonlite_1.8.8
+#> [67] R6_2.5.1 systemfonts_1.0.5 fs_1.6.3
+#> [70] units_0.8-5
diff --git a/articles/rxode2-transit-compartments.html b/articles/rxode2-transit-compartments.html
index 46738f2b6..ddc71fe4d 100644
--- a/articles/rxode2-transit-compartments.html
+++ b/articles/rxode2-transit-compartments.html
@@ -158,7 +158,7 @@ Advanced Features, Model Types, Techni
rxode2 Transit Compartment Models
- 2024-01-23
+ 2024-01-30
Source: vignettes/rxode2-transit-compartments.Rmd
rxode2-transit-compartments.Rmd
diff --git a/articles/rxode2-wt.html b/articles/rxode2-wt.html
index 5b49fd487..838c79e7c 100644
--- a/articles/rxode2-wt.html
+++ b/articles/rxode2-wt.html
@@ -158,7 +158,7 @@ Advanced Features, Model Types, Techni
Weight Based Dosing in rxode2
- 2024-01-23
+ 2024-01-30
Source: vignettes/rxode2-wt.Rmd
rxode2-wt.Rmd
diff --git a/pkgdown.yml b/pkgdown.yml
index fd061d836..288b8d413 100644
--- a/pkgdown.yml
+++ b/pkgdown.yml
@@ -27,7 +27,7 @@ articles:
rxode2-transit-compartments: rxode2-transit-compartments.html
rxode2-tutorials: rxode2-tutorials.html
rxode2-wt: rxode2-wt.html
-last_built: 2024-01-23T05:35Z
+last_built: 2024-01-30T05:37Z
urls:
reference: https://nlmixr2.github.io/rxode2/reference
article: https://nlmixr2.github.io/rxode2/articles
diff --git a/reference/dot-rxWithWd.html b/reference/dot-rxWithWd.html
index 960340e85..98e1e0002 100644
--- a/reference/dot-rxWithWd.html
+++ b/reference/dot-rxWithWd.html
@@ -162,7 +162,7 @@ Examples.rxWithWd(tempdir(), {
getwd()
})
-#> [1] "/tmp/RtmpQvsiAp"
+#> [1] "/tmp/RtmpVdj7Cq"
getwd()
#> [1] "/home/runner/work/rxode2/rxode2/docs/reference"
diff --git a/reference/myapp/mod1.d/mod1_.c b/reference/myapp/mod1.d/mod1_.c
index 4cc8bf41c..0ce9dd16f 100644
--- a/reference/myapp/mod1.d/mod1_.c
+++ b/reference/myapp/mod1.d/mod1_.c
@@ -1,119 +1,119 @@
-#define _getRxSolve_ _rxmod1_90e78de85eae102082dac9d0e66faf820
-#define _evalUdf _rxmod1_90e78de85eae102082dac9d0e66faf821
-#define _solveData _rxmod1_90e78de85eae102082dac9d0e66faf822
-#define _assign_ptr _rxmod1_90e78de85eae102082dac9d0e66faf823
-#define _rxRmModelLib _rxmod1_90e78de85eae102082dac9d0e66faf824
-#define _rxGetModelLib _rxmod1_90e78de85eae102082dac9d0e66faf825
-#define _old_c _rxmod1_90e78de85eae102082dac9d0e66faf826
-#define _ptrid _rxmod1_90e78de85eae102082dac9d0e66faf827
-#define _rxIsCurrentC _rxmod1_90e78de85eae102082dac9d0e66faf828
-#define _sumPS _rxmod1_90e78de85eae102082dac9d0e66faf829
-#define _prodPS _rxmod1_90e78de85eae102082dac9d0e66faf8210
-#define _prodType _rxmod1_90e78de85eae102082dac9d0e66faf8211
-#define _sumType _rxmod1_90e78de85eae102082dac9d0e66faf8212
-#define _update_par_ptr _rxmod1_90e78de85eae102082dac9d0e66faf8213
-#define _getParCov _rxmod1_90e78de85eae102082dac9d0e66faf8214
-#define _rxode2_rxAssignPtr _rxmod1_90e78de85eae102082dac9d0e66faf8215
-#define _rxQr _rxmod1_90e78de85eae102082dac9d0e66faf8216
-#define _compareFactorVal _rxmod1_90e78de85eae102082dac9d0e66faf8217
-#define _sum _rxmod1_90e78de85eae102082dac9d0e66faf8218
-#define _udf _rxmod1_90e78de85eae102082dac9d0e66faf8219
-#define _sign _rxmod1_90e78de85eae102082dac9d0e66faf8220
-#define _prod _rxmod1_90e78de85eae102082dac9d0e66faf8221
-#define _max _rxmod1_90e78de85eae102082dac9d0e66faf8222
-#define _min _rxmod1_90e78de85eae102082dac9d0e66faf8223
-#define _transit4P _rxmod1_90e78de85eae102082dac9d0e66faf8224
-#define _transit3P _rxmod1_90e78de85eae102082dac9d0e66faf8225
-#define _assignFuns0 _rxmod1_90e78de85eae102082dac9d0e66faf8226
-#define _assignFuns _rxmod1_90e78de85eae102082dac9d0e66faf8227
-#define _rxord _rxmod1_90e78de85eae102082dac9d0e66faf8228
-#define __assignFuns2 _rxmod1_90e78de85eae102082dac9d0e66faf8229
-#define _llikCauchyDscale _rxmod1_90e78de85eae102082dac9d0e66faf8230
-#define _llikCauchyDlocation _rxmod1_90e78de85eae102082dac9d0e66faf8231
-#define _llikCauchy _rxmod1_90e78de85eae102082dac9d0e66faf8232
-#define _llikGammaDrate _rxmod1_90e78de85eae102082dac9d0e66faf8233
-#define _llikGammaDshape _rxmod1_90e78de85eae102082dac9d0e66faf8234
-#define _llikGamma _rxmod1_90e78de85eae102082dac9d0e66faf8235
-#define _llikWeibullDscale _rxmod1_90e78de85eae102082dac9d0e66faf8236
-#define _llikWeibullDshape _rxmod1_90e78de85eae102082dac9d0e66faf8237
-#define _llikWeibull _rxmod1_90e78de85eae102082dac9d0e66faf8238
-#define _llikUnifDbeta _rxmod1_90e78de85eae102082dac9d0e66faf8239
-#define _llikUnifDalpha _rxmod1_90e78de85eae102082dac9d0e66faf8240
-#define _llikUnif _rxmod1_90e78de85eae102082dac9d0e66faf8241
-#define _llikGeomDp _rxmod1_90e78de85eae102082dac9d0e66faf8242
-#define _llikGeom _rxmod1_90e78de85eae102082dac9d0e66faf8243
-#define _llikFDdf2 _rxmod1_90e78de85eae102082dac9d0e66faf8244
-#define _llikFDdf1 _rxmod1_90e78de85eae102082dac9d0e66faf8245
-#define _llikF _rxmod1_90e78de85eae102082dac9d0e66faf8246
-#define _llikExpDrate _rxmod1_90e78de85eae102082dac9d0e66faf8247
-#define _llikExp _rxmod1_90e78de85eae102082dac9d0e66faf8248
-#define _llikChisqDdf _rxmod1_90e78de85eae102082dac9d0e66faf8249
-#define _llikChisq _rxmod1_90e78de85eae102082dac9d0e66faf8250
-#define _llikTDsd _rxmod1_90e78de85eae102082dac9d0e66faf8251
-#define _llikTDmean _rxmod1_90e78de85eae102082dac9d0e66faf8252
-#define _llikTDdf _rxmod1_90e78de85eae102082dac9d0e66faf8253
-#define _llikT _rxmod1_90e78de85eae102082dac9d0e66faf8254
-#define _llikBetaDshape2 _rxmod1_90e78de85eae102082dac9d0e66faf8255
-#define _llikBetaDshape1 _rxmod1_90e78de85eae102082dac9d0e66faf8256
-#define _llikBeta _rxmod1_90e78de85eae102082dac9d0e66faf8257
-#define _llikNbinomMuDmu _rxmod1_90e78de85eae102082dac9d0e66faf8258
-#define _llikNbinomMu _rxmod1_90e78de85eae102082dac9d0e66faf8259
-#define _llikNbinomDprob _rxmod1_90e78de85eae102082dac9d0e66faf8260
-#define _llikNbinom _rxmod1_90e78de85eae102082dac9d0e66faf8261
-#define _llikBinomDprob _rxmod1_90e78de85eae102082dac9d0e66faf8262
-#define _llikBinom _rxmod1_90e78de85eae102082dac9d0e66faf8263
-#define _llikPoisDlambda _rxmod1_90e78de85eae102082dac9d0e66faf8264
-#define _llikPois _rxmod1_90e78de85eae102082dac9d0e66faf8265
-#define _llikNormDsd _rxmod1_90e78de85eae102082dac9d0e66faf8266
-#define _llikNormDmean _rxmod1_90e78de85eae102082dac9d0e66faf8267
-#define _llikNorm _rxmod1_90e78de85eae102082dac9d0e66faf8268
-#define simeps _rxmod1_90e78de85eae102082dac9d0e66faf8269
-#define simeta _rxmod1_90e78de85eae102082dac9d0e66faf8270
-#define expit _rxmod1_90e78de85eae102082dac9d0e66faf8271
-#define logit _rxmod1_90e78de85eae102082dac9d0e66faf8272
-#define gammapDer _rxmod1_90e78de85eae102082dac9d0e66faf8273
-#define lowergamma _rxmod1_90e78de85eae102082dac9d0e66faf8274
-#define uppergamma _rxmod1_90e78de85eae102082dac9d0e66faf8275
-#define gammaqInva _rxmod1_90e78de85eae102082dac9d0e66faf8276
-#define gammaqInv _rxmod1_90e78de85eae102082dac9d0e66faf8277
-#define gammapInva _rxmod1_90e78de85eae102082dac9d0e66faf8278
-#define gammapInv _rxmod1_90e78de85eae102082dac9d0e66faf8279
-#define gammaq _rxmod1_90e78de85eae102082dac9d0e66faf8280
-#define gammap _rxmod1_90e78de85eae102082dac9d0e66faf8281
-#define phi _rxmod1_90e78de85eae102082dac9d0e66faf8282
-#define riweibull _rxmod1_90e78de85eae102082dac9d0e66faf8283
-#define riunif _rxmod1_90e78de85eae102082dac9d0e66faf8284
-#define rit_ _rxmod1_90e78de85eae102082dac9d0e66faf8285
-#define ripois _rxmod1_90e78de85eae102082dac9d0e66faf8286
-#define ribeta _rxmod1_90e78de85eae102082dac9d0e66faf8287
-#define rigamma _rxmod1_90e78de85eae102082dac9d0e66faf8288
-#define rigeom _rxmod1_90e78de85eae102082dac9d0e66faf8289
-#define rif _rxmod1_90e78de85eae102082dac9d0e66faf8290
-#define riexp _rxmod1_90e78de85eae102082dac9d0e66faf8291
-#define richisq _rxmod1_90e78de85eae102082dac9d0e66faf8292
-#define ricauchy _rxmod1_90e78de85eae102082dac9d0e66faf8293
-#define rinbinomMu _rxmod1_90e78de85eae102082dac9d0e66faf8294
-#define rinbinom _rxmod1_90e78de85eae102082dac9d0e66faf8295
-#define ribinom _rxmod1_90e78de85eae102082dac9d0e66faf8296
-#define rinorm _rxmod1_90e78de85eae102082dac9d0e66faf8297
-#define rxweibull _rxmod1_90e78de85eae102082dac9d0e66faf8298
-#define rxunif _rxmod1_90e78de85eae102082dac9d0e66faf8299
-#define rxt_ _rxmod1_90e78de85eae102082dac9d0e66faf82100
-#define rxpois _rxmod1_90e78de85eae102082dac9d0e66faf82101
-#define rxbeta _rxmod1_90e78de85eae102082dac9d0e66faf82102
-#define rxgamma _rxmod1_90e78de85eae102082dac9d0e66faf82103
-#define rxgeom _rxmod1_90e78de85eae102082dac9d0e66faf82104
-#define rxf _rxmod1_90e78de85eae102082dac9d0e66faf82105
-#define rxexp _rxmod1_90e78de85eae102082dac9d0e66faf82106
-#define rxchisq _rxmod1_90e78de85eae102082dac9d0e66faf82107
-#define rxcauchy _rxmod1_90e78de85eae102082dac9d0e66faf82108
-#define rxnbinomMu _rxmod1_90e78de85eae102082dac9d0e66faf82109
-#define rxnbinom _rxmod1_90e78de85eae102082dac9d0e66faf82110
-#define rxbinom _rxmod1_90e78de85eae102082dac9d0e66faf82111
-#define rxnorm _rxmod1_90e78de85eae102082dac9d0e66faf82112
-#define linCmtC _rxmod1_90e78de85eae102082dac9d0e66faf82113
-#define linCmtB _rxmod1_90e78de85eae102082dac9d0e66faf82114
-#define linCmtA _rxmod1_90e78de85eae102082dac9d0e66faf82115
+#define _getRxSolve_ _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f10
+#define _evalUdf _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f11
+#define _solveData _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f12
+#define _assign_ptr _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f13
+#define _rxRmModelLib _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f14
+#define _rxGetModelLib _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f15
+#define _old_c _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f16
+#define _ptrid _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f17
+#define _rxIsCurrentC _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f18
+#define _sumPS _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f19
+#define _prodPS _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f110
+#define _prodType _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f111
+#define _sumType _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f112
+#define _update_par_ptr _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f113
+#define _getParCov _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f114
+#define _rxode2_rxAssignPtr _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f115
+#define _rxQr _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f116
+#define _compareFactorVal _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f117
+#define _sum _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f118
+#define _udf _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f119
+#define _sign _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f120
+#define _prod _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f121
+#define _max _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f122
+#define _min _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f123
+#define _transit4P _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f124
+#define _transit3P _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f125
+#define _assignFuns0 _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f126
+#define _assignFuns _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f127
+#define _rxord _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f128
+#define __assignFuns2 _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f129
+#define _llikCauchyDscale _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f130
+#define _llikCauchyDlocation _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f131
+#define _llikCauchy _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f132
+#define _llikGammaDrate _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f133
+#define _llikGammaDshape _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f134
+#define _llikGamma _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f135
+#define _llikWeibullDscale _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f136
+#define _llikWeibullDshape _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f137
+#define _llikWeibull _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f138
+#define _llikUnifDbeta _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f139
+#define _llikUnifDalpha _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f140
+#define _llikUnif _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f141
+#define _llikGeomDp _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f142
+#define _llikGeom _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f143
+#define _llikFDdf2 _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f144
+#define _llikFDdf1 _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f145
+#define _llikF _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f146
+#define _llikExpDrate _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f147
+#define _llikExp _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f148
+#define _llikChisqDdf _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f149
+#define _llikChisq _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f150
+#define _llikTDsd _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f151
+#define _llikTDmean _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f152
+#define _llikTDdf _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f153
+#define _llikT _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f154
+#define _llikBetaDshape2 _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f155
+#define _llikBetaDshape1 _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f156
+#define _llikBeta _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f157
+#define _llikNbinomMuDmu _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f158
+#define _llikNbinomMu _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f159
+#define _llikNbinomDprob _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f160
+#define _llikNbinom _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f161
+#define _llikBinomDprob _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f162
+#define _llikBinom _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f163
+#define _llikPoisDlambda _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f164
+#define _llikPois _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f165
+#define _llikNormDsd _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f166
+#define _llikNormDmean _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f167
+#define _llikNorm _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f168
+#define simeps _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f169
+#define simeta _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f170
+#define expit _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f171
+#define logit _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f172
+#define gammapDer _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f173
+#define lowergamma _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f174
+#define uppergamma _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f175
+#define gammaqInva _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f176
+#define gammaqInv _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f177
+#define gammapInva _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f178
+#define gammapInv _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f179
+#define gammaq _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f180
+#define gammap _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f181
+#define phi _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f182
+#define riweibull _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f183
+#define riunif _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f184
+#define rit_ _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f185
+#define ripois _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f186
+#define ribeta _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f187
+#define rigamma _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f188
+#define rigeom _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f189
+#define rif _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f190
+#define riexp _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f191
+#define richisq _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f192
+#define ricauchy _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f193
+#define rinbinomMu _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f194
+#define rinbinom _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f195
+#define ribinom _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f196
+#define rinorm _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f197
+#define rxweibull _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f198
+#define rxunif _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f199
+#define rxt_ _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f1100
+#define rxpois _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f1101
+#define rxbeta _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f1102
+#define rxgamma _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f1103
+#define rxgeom _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f1104
+#define rxf _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f1105
+#define rxexp _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f1106
+#define rxchisq _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f1107
+#define rxcauchy _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f1108
+#define rxnbinomMu _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f1109
+#define rxnbinom _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f1110
+#define rxbinom _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f1111
+#define rxnorm _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f1112
+#define linCmtC _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f1113
+#define linCmtB _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f1114
+#define linCmtA _rxmod1_3e6934e38eca2bcbb2cb11ab11d442f1115
#include
#define __MAX_PROD__ 0
#define _CMT CMT
@@ -684,9 +684,9 @@ extern SEXP mod1__model_vars(void){
SEXP _mv = PROTECT(_rxGetModelLib("mod1__model_vars"));pro++;
if (!_rxIsCurrentC(_mv)){
SEXP hash = PROTECT(allocVector(STRSXP, 1));pro++;
-#define __doBuf__ snprintf(buf, __doBufN__, "un]\"BAAA@QRtHACAAAAAAAY4zAAAv7#aT)CYk)MA==)a=W6xYB~1\"d|dB8o!;OnqKS@vXmkM/z7;*5%%*xp\"jec/578;vzk;OKH>XwJvmY\?a$`6:BS%%}aIXu!3tJt.A{CQ$jQwahw7dv;Ix)T_nf}I289xCIs\?N|;Uf{T+2k@+TT33s,I;LT[`4xdcs$XG=LaczKj/wZM2Nk3#f3a+Un!3z&Qq*|pVMO<^!Nl_+lj%%#W5*F}VoWc[^uBPlf)ocbDBmOU\"NmgT*1gp{q~o8Ff9|3d9~I99/Pt^EB)0P[9Mj9EO:MbIJ\"V1^kV*o]\?y1QJ4;9^V7v_52`mLpgeiO(is$p|(kQ=Cc(o{fflFPA6>jeFDMjH(@R73umRXk|,EkRTf!LBeGFR<7zV\"C95/bcLX2zd;*Rv&tbyK2IE]):w+VrF@oK5`sQt{r(@O1[$[CGU(*ZUJ4ZHAf7a!:u]qcUzFz%%%%Q_PE!vjci.>WWzQ>9b|wT\?*7FNA\?68.n2sG)YwMaOwzr6(!MHtl=Ja~jL");
- char buf[1056];
-#define __doBufN__ 1056
+#define __doBuf__ snprintf(buf, __doBufN__, "un]\"BAAA@QRtHACAAAAAAA6yzAAAv7#aT)^X\"&MAI<)agtVwYBaiiq@C2k[@I!7tc/r+VBI5mtRsmxuUu_%%x^gWz,0^AqZCeX/%%.hJt,A_CD,iw!LwDYJCje~*#TZ!$0>FFig!^t_uR&PgqW=\"s:>JW5>BTr;wk4A$r4:k2qg1}$^8[s$/*yk*JbCP60t^//j#VHiU:@ke\?Sp^KC}rlhn2@*}):>$FcNHjp7i<[BztU;aO3Z1/$aM`Ap1NzhggmRY\"1rH44itnvA2AF}gSX.Iq&f>LPMO@!!!xl;Vy65K!DiugR^$T5g.*_Kx^J@WALopypF!Qw\?K*PlFTr5@E6cZ7ez8bFjK+wxibE]^U,.,QQ$dpf~GM]Aw`I>O#U\"X^jn7xp#(x*+zKOMi/R[CLbRK%%+E\"NOhj5NXJ\?#TpE]Kn,ZMB]1wl=gt~J+%%$td$&y2jnQ96*>VzE9W:&\?DVlplF)26ZS}gY#0$$eNeiN(BG@>#},nG+{i[D&z$ptq^oc[@1!},fB)o$}JkZ42hXo=Z/6qgh<@*o&G~ZnPae#A{pk%%6NvHm)q,qdaUbeM*+7x_*/Y0Y,+&tEN\?ZVt\"J*+*YxJ$k$c$+26%%ob2\?I\?qXh]>R73umRXk|,EkRTf!LBeGFR<7zV\"C95/bcLX2zd;*Hv&tbyK27D]):w8^;zn.s(w=3lsBu#uZ{;5o@>ZP86_$/K79<9zscZVoDA%%u~P2ON4]KTa2l0[#m9]O7L[6i9qp~9\"CtLNgrVA#C,NMu[j51lt.M>rF@oK5`sQt{r(@O1[$[CGU(*ZUJ4ZHAf7a!:u]qcUzFz%%%%Q_PE!vjci.>WWzQ>9b|wT\?*7FNA\?68.n2sG)YwMaOwzr6(!MHu]}g4Hf");
+ char buf[1059];
+#define __doBufN__ 1059
__doBuf__
#undef __doBuf__
#undef __doBufN__
diff --git a/reference/myapp/mod1.d/mod1_.o b/reference/myapp/mod1.d/mod1_.o
index d9ba81804..2b2b9dfad 100644
Binary files a/reference/myapp/mod1.d/mod1_.o and b/reference/myapp/mod1.d/mod1_.o differ
diff --git a/reference/myapp/mod1.d/mod1_.so b/reference/myapp/mod1.d/mod1_.so
index ea6416b85..94758fc39 100755
Binary files a/reference/myapp/mod1.d/mod1_.so and b/reference/myapp/mod1.d/mod1_.so differ
diff --git a/reference/myapp/rx_shiny_data.rda b/reference/myapp/rx_shiny_data.rda
index 5214e22ee..a378af35e 100644
Binary files a/reference/myapp/rx_shiny_data.rda and b/reference/myapp/rx_shiny_data.rda differ
diff --git a/reference/rxCombineErrorLines.html b/reference/rxCombineErrorLines.html
index ccedcf0a4..5c6471685 100644
--- a/reference/rxCombineErrorLines.html
+++ b/reference/rxCombineErrorLines.html
@@ -383,7 +383,7 @@ Examples#>
#>
#> using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’
-#> rxode2 2.1.1.9000 model named rx_ffb5b3afd66c33175c304e3aaae51091 model (✔ ready).
+#> rxode2 2.1.1.9000 model named rx_50de6acd63214183c70f26383fc904b0 model (✔ ready).
#> $state: depot, gut, center, effect
#> $stateExtra: cp
#> $params: tktr, tka, tcl, tv, prop.err, pkadd.err, temax, tec50, tkout, te0, pdadd.err, eta.ktr, eta.ka, eta.cl, eta.v, eta.emax, eta.ec50, eta.kout, eta.e0, CMT, rxerr.cp, rxerr.effect
diff --git a/reference/rxExpandGrid.html b/reference/rxExpandGrid.html
index f12157c74..f726192b1 100644
--- a/reference/rxExpandGrid.html
+++ b/reference/rxExpandGrid.html
@@ -859,12 +859,12 @@ Examples# \donttest{
microbenchmark::microbenchmark(rxExpandGrid(letters, letters), expand.grid.jc(letters, letters))
#> Unit: microseconds
-#> expr min lq mean median uq
-#> rxExpandGrid(letters, letters) 11.511 12.6785 26.31728 13.5700 14.682
-#> expand.grid.jc(letters, letters) 15.269 17.2970 125.37047 18.4345 20.318
+#> expr min lq mean median uq
+#> rxExpandGrid(letters, letters) 12.533 14.7425 38.56275 17.4275 23.0235
+#> expand.grid.jc(letters, letters) 16.050 19.4310 171.23374 22.9025 31.9695
#> max neval
-#> 1267.291 100
-#> 5441.729 100
+#> 2010.680 100
+#> 6944.552 100
# }
diff --git a/reference/rxbeta.html b/reference/rxbeta.html
index 3dc37738f..87d9b4c18 100644
--- a/reference/rxbeta.html
+++ b/reference/rxbeta.html
@@ -202,8 +202,8 @@ Examples#> [1] 0.7852473 0.4552276 0.9643407 0.7309750 0.9217035 0.4459162 0.9446204
#> [8] 0.7547216 0.6014439 0.9971971
rxbeta(5, 1, n = 10, ncores = 2) # You can parallelize the simulation using openMP
-#> [1] 0.9863230 0.9691479 0.9796321 0.9713815 0.9617760 0.6733853 0.6034338
-#> [8] 0.7713400 0.6270114 0.7109119
+#> [1] 0.9863230 0.6787542 0.9691479 0.9634618 0.9796321 0.6733853 0.9617760
+#> [8] 0.7713400 0.6034338 0.7109119
rxbeta(1, 3)
#> [1] 0.2516317
diff --git a/search.json b/search.json
index 6d2253963..1f2b7f334 100644
--- a/search.json
+++ b/search.json
@@ -1 +1 @@
-[{"path":"https://nlmixr2.github.io/rxode2/articles/Integrating-User-Defined-Functions-into-rxode2.html","id":"user-defined-functions","dir":"Articles","previous_headings":"","what":"User Defined Functions","title":"Integrating User Defined Functions into rxode2","text":"defining models may wished write small R function make function integrate rxode2 somehow. article discusses 2 ways : R-based user function can loaded simple function certain circumstances translated C run efficiently C function define integrate code","code":"library(rxode2) #> rxode2 2.1.1.9000 using 2 threads (see ?getRxThreads) #> no cache: create with `rxCreateCache()`"},{"path":"https://nlmixr2.github.io/rxode2/articles/Integrating-User-Defined-Functions-into-rxode2.html","id":"r-based-user-functions","dir":"Articles","previous_headings":"","what":"R based user functions","title":"Integrating User Defined Functions into rxode2","text":"R-based user function convenient include ODE, slower done written C , C++ compiled language. requested github appropriate example; However, use simple example simply illustrate concepts. Now ODE compiled R functions called solving ODE. Since calling R, forces parallization turned since R single-threaded. also takes time solve since shuttling back forth R C. Lets see simple function performs: terribly bad, even though shuffling R C. can make better converting functions C: C version almost twice fast R version. may noticed conversion also created C versions first derivative. done automatically gives just C versions function, C versions derivatives registers rxode2. allows C versions work rxode2 nlmixr2 models. function setup advance allow type conversion. general derivatives calculated return() statement user defined function. means simply let R return last value instead explictly calling return(). Many people prefer method coding. Even return function, function converted C. github issue, used function convert derivatives: still helpful functions early returns, nlmixr2 models requiring derivatives calculated non-optimized finite differences occurs. gets internals rxode2 nlmixr2 can see easily calculating derivatives: Whereas originally defined function newAbs() use new derivatives calculated well: circumstances, conversion C possible, though can still use R function. requirements R functions integrated rxode2 system: function must set number arguments, variable arguments like f(…) currently allowed. function given argument single number, function return single number requirements met can use R function rxode2. Additional requirements conversion C include: functions use within R function must understood available rxode2. Practically speaking fun2() refers fun1(), fun1() must changed C code available rxode2 changing function fun2() C. functions can include /else assignments simple return statements (either returning value value line ). Special R control structures functions (like lapply) present. function refer package functions mentioned, return() statement present, derivative C functions rxode2’s derivative table updated.","code":"newAbs <- function(x) { if (x < 0) { -x } else { x } } f <- rxode2({ a <- newAbs(time) }) #> using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’ e <- et(-10, 10, length.out=40) mb1 <- microbenchmark::microbenchmark(withoutC=suppressWarnings(rxSolve(f,e))) library(ggplot2) autoplot(mb1) + rxTheme() # Create C functions automatically with `rxFun()` rxFun(newAbs) #> → finding duplicate expressions in d(newAbs)/d(x)... #> [====|====|====|====|====|====|====|====|====|====] 0:00:00 #> → optimizing duplicate expressions in d(newAbs)/d(x)... #> [====|====|====|====|====|====|====|====|====|====] 0:00:00 #> converted R function 'newAbs' to C (will now use in rxode2) #> converted R function 'rx_newAbs_d_x' to C (will now use in rxode2) #> Added derivative table for 'newAbs' # Recompile to use the C functions # Note it would recompile anyway if you didn't do this step, # it just makes sure that it doesn't recompile every step in # the benchmark f <- rxode2({ a <- newAbs(time) }) #> using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’ mb2 <- microbenchmark::microbenchmark(withC=rxSolve(f,e, cores=1)) mb <- rbind(mb1, mb2) autoplot(mb) + rxTheme() + xgxr::xgx_scale_y_log10() #> Scale for y is already present. #> Adding another scale for y, which will replace the existing scale. print(mb) #> Unit: milliseconds #> expr min lq mean median uq max neval #> withoutC 7.754378 8.111007 8.768889 8.302625 8.536936 14.293111 100 #> withC 2.065438 2.156628 2.514262 2.288734 2.795845 6.822972 100 # Light f_R <- function(actRad, k_0, a_k) { photfac <- a_k * actRad + k_0 if (photfac > 1) { photfac = 1 } return(photfac) } rxFun(f_R) #> function contains return statement; derivatives not calculated #> converted R function 'f_R' to C (will now use in rxode2) rxFromSE(\"Derivative(f_R(actRad, k_0, a_k),k_0)\") #> [1] \"(f_R(actRad,(k_0)+6.05545445239334e-06,a_k)-f_R(actRad,k_0,a_k))/6.05545445239334e-06\" rxFromSE(\"Derivative(newAbs(x),x)\") #> [1] \"rx_newAbs_d_x(x)\""},{"path":"https://nlmixr2.github.io/rxode2/articles/Integrating-User-Defined-Functions-into-rxode2.html","id":"c-based-functions","dir":"Articles","previous_headings":"","what":"C based functions","title":"Integrating User Defined Functions into rxode2","text":"can add C functions directly rxode2 well using rxFun(): wanted also use C functions expressions derivatives using rxD() function: Removing function rxRmFun() also remove derivative table:","code":"fun <- \" double fun(double a, double b, double c) { return a*a+b*a+c; } \" ## C-code for function rxFun(\"fun\", c(\"a\", \"b\", \"c\"), fun) rxD(\"fun\", list( function(a, b, c) { # derivative of arg1: a paste0(\"2*\", a, \"+\", b) }, function(a, b, c) { # derivative of arg2: b return(a) }, function(a, b, c) { # derivative of arg3: c return(\"0.0\") } )) rxRmFun(\"fun\")"},{"path":"https://nlmixr2.github.io/rxode2/articles/Modifying-Models.html","id":"modifying-model","dir":"Articles","previous_headings":"","what":"Modifying model","title":"Modifying Models","text":"tasks might want overall model: Change line model Add line model Rename parameters model Combine different models Create functions add certain model features model go model piping functions can use modify models even add functions modify models. cover model modification functions nlmixr2lib","code":""},{"path":"https://nlmixr2.github.io/rxode2/articles/Modifying-Models.html","id":"modifying-a-model-line","dir":"Articles","previous_headings":"Modifying model","what":"Modifying a model line","title":"Modifying Models","text":"opinion, modifying lines model likely common task modifying model. may wish modify model subject variability add covariate effects. begin course need base model modify. Let’s start simple PK example, using single-dose theophylline dataset generously provided Dr. Robert . Upton University California, San Francisco: believed enough absorption support subject variability can change line drop subject modifying single line. simply type line want model piping expression: expected, line modified. Also can notice initial estimate subject variability dropped since longer part model. reason wanted add back model can modify model add back: modification, eta.ka automatically assumed subject variability parameter. Also since eta.ka mu-referenced rxode2 points . automatic detection eta.ka name follows convention. Parameters starting ending following names assumed subject variability parameters: eta (NONMEM convention) ppv (per patient variability) psv (per subject variability) iiv (inter-individual variability) bsv (subject variability) bpv (patient variability) functioning correctly can change covariate can add type initial estimate later: seen , eta.ka model assumed data-input parameter covariate instead estimated parameter. can also note WT automatically recognized covariate covWt automatically recognized covariate parameter. general covariates typical/population parameters automatically converted estimated parameters based parameter name starting (ending ): tv (typical value) t (also typical value) pop (population parameter) err (error parameter) eff (effect parameter) cov (covariate parameters) notable exceptions parameters like (wt, sex crcl) assumed covariates. don’t want automatic variable conversion, can also use auto=FALSE: case additional parameters (eta.ka, WT, covWt) assumed parameters dataset.","code":"one.compartment <- function() { ini({ tka <- 0.45; label(\"Ka\") tcl <- 1; label(\"Cl\") tv <- 3.45; label(\"V\") eta.ka ~ 0.6 eta.cl ~ 0.3 eta.v ~ 0.1 add.sd <- 0.7 }) model({ ka <- exp(tka + eta.ka) cl <- exp(tcl + eta.cl) v <- exp(tv + eta.v) d/dt(depot) = -ka * depot d/dt(center) = ka * depot - cl / v * center cp = center / v cp ~ add(add.sd) }) } mod <- one.compartment |> model(ka <- exp(tka)) #> ! remove between subject variability `eta.ka` print(mod) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd #> 0.45 1.00 3.45 0.70 #> #> Omega ($omega): #> eta.cl eta.v #> eta.cl 0.3 0.0 #> eta.v 0.0 0.1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 tcl eta.cl id #> 2 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- 0.45 #> label(\"Ka\") #> tcl <- 1 #> label(\"Cl\") #> tv <- 3.45 #> label(\"V\") #> add.sd <- c(0, 0.7) #> eta.cl ~ 0.3 #> eta.v ~ 0.1 #> }) #> model({ #> ka <- exp(tka) #> cl <- exp(tcl + eta.cl) #> v <- exp(tv + eta.v) #> d/dt(depot) = -ka * depot #> d/dt(center) = ka * depot - cl/v * center #> cp = center/v #> cp ~ add(add.sd) #> }) #> } mod2 <- mod |> model(ka <- tka * exp(eta.ka)) #> ℹ add between subject variability `eta.ka` and set estimate to 1 print(mod2) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd #> 0.45 1.00 3.45 0.70 #> #> Omega ($omega): #> eta.cl eta.v eta.ka #> eta.cl 0.3 0.0 0 #> eta.v 0.0 0.1 0 #> eta.ka 0.0 0.0 1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 tcl eta.cl id #> 2 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- 0.45 #> label(\"Ka\") #> tcl <- 1 #> label(\"Cl\") #> tv <- 3.45 #> label(\"V\") #> add.sd <- c(0, 0.7) #> eta.cl ~ 0.3 #> eta.v ~ 0.1 #> eta.ka ~ 1 #> }) #> model({ #> ka <- tka * exp(eta.ka) #> cl <- exp(tcl + eta.cl) #> v <- exp(tv + eta.v) #> d/dt(depot) = -ka * depot #> d/dt(center) = ka * depot - cl/v * center #> cp = center/v #> cp ~ add(add.sd) #> }) #> } mod2 <- mod |> model(ka <- tka * exp(eta.ka) + WT * covWt, cov=\"eta.ka\") #> ℹ add covariate `eta.ka` (as requested by cov option) #> ℹ add covariate `WT` #> ℹ add population parameter `covWt` and set estimate to 1 print(mod2) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd covWt #> 0.45 1.00 3.45 0.70 1.00 #> #> Omega ($omega): #> eta.cl eta.v #> eta.cl 0.3 0.0 #> eta.v 0.0 0.1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level covariates #> 1 tcl eta.cl id #> 2 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- 0.45 #> label(\"Ka\") #> tcl <- 1 #> label(\"Cl\") #> tv <- 3.45 #> label(\"V\") #> add.sd <- c(0, 0.7) #> covWt <- 1 #> eta.cl ~ 0.3 #> eta.v ~ 0.1 #> }) #> model({ #> ka <- tka * exp(eta.ka) + WT * covWt #> cl <- exp(tcl + eta.cl) #> v <- exp(tv + eta.v) #> d/dt(depot) = -ka * depot #> d/dt(center) = ka * depot - cl/v * center #> cp = center/v #> cp ~ add(add.sd) #> }) #> } mod3 <- mod |> model(ka <- tka * exp(eta.ka) + WT * covWt, auto=FALSE) #> ℹ add covariate `eta.ka` #> ℹ add covariate `WT` #> ℹ add covariate `covWt` print(mod3) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd #> 0.45 1.00 3.45 0.70 #> #> Omega ($omega): #> eta.cl eta.v #> eta.cl 0.3 0.0 #> eta.v 0.0 0.1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level covariates #> 1 tcl eta.cl id #> 2 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- 0.45 #> label(\"Ka\") #> tcl <- 1 #> label(\"Cl\") #> tv <- 3.45 #> label(\"V\") #> add.sd <- c(0, 0.7) #> eta.cl ~ 0.3 #> eta.v ~ 0.1 #> }) #> model({ #> ka <- tka * exp(eta.ka) + WT * covWt #> cl <- exp(tcl + eta.cl) #> v <- exp(tv + eta.v) #> d/dt(depot) = -ka * depot #> d/dt(center) = ka * depot - cl/v * center #> cp = center/v #> cp ~ add(add.sd) #> }) #> }"},{"path":"https://nlmixr2.github.io/rxode2/articles/Modifying-Models.html","id":"note-on-automatic-detection-of-variables","dir":"Articles","previous_headings":"Modifying model","what":"Note on automatic detection of variables","title":"Modifying Models","text":"automatic detection variables convenient many models may suit style; like can always change using options(): option disabled, variables assumed covariates promote population parameters ini block last example option enabled none variables starting t added model course use turn back : can use withr::with_options(list(rxode2.autoVarPiping=FALSE), ...) turn option temporarily. don’t like defaults changing variables change well rxSetPipingAuto() example wanted variables starting ending te can change : requested population parameters starting te added ini block. want reset defaults simply call rxSetPipingAuto() without arguments:","code":"options(rxode2.autoVarPiping=FALSE) mod7 <- mod3 |> model({ emax <- exp(temax) e0 <- exp(te0 + eta.e0) ec50 <- exp(tec50) kin <- exp(tkin) kout <- exp(tkout) }, append=FALSE) print(mod7) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd #> 0.45 1.00 3.45 0.70 #> #> Omega ($omega): #> eta.cl eta.v #> eta.cl 0.3 0.0 #> eta.v 0.0 0.1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level covariates #> 1 tcl eta.cl id #> 2 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- 0.45 #> label(\"Ka\") #> tcl <- 1 #> label(\"Cl\") #> tv <- 3.45 #> label(\"V\") #> add.sd <- c(0, 0.7) #> eta.cl ~ 0.3 #> eta.v ~ 0.1 #> }) #> model({ #> emax <- exp(temax) #> e0 <- exp(te0 + eta.e0) #> ec50 <- exp(tec50) #> kin <- exp(tkin) #> kout <- exp(tkout) #> ka <- tka * exp(eta.ka) + WT * covWt #> cl <- exp(tcl + eta.cl) #> v <- exp(tv + eta.v) #> d/dt(depot) = -ka * depot #> d/dt(center) = ka * depot - cl/v * center #> cp = center/v #> cp ~ add(add.sd) #> }) #> } options(rxode2.autoVarPiping=TRUE) mod8 <- mod |> model({ emax <- exp(temax) e0 <- exp(te0 + eta.e0) ec50 <- exp(tec50) kin <- exp(tkin) kout <- exp(tkout) }, append=FALSE) #> ℹ promote `temax` to population parameter with initial estimate 1 #> ℹ promote `te0` to population parameter with initial estimate 1 #> ℹ promote `eta.e0` to between subject variability with initial estimate 1 #> ℹ promote `tec50` to population parameter with initial estimate 1 #> ℹ promote `tkin` to population parameter with initial estimate 1 #> ℹ promote `tkout` to population parameter with initial estimate 1 print(mod8) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd temax te0 tec50 tkin tkout #> 0.45 1.00 3.45 0.70 1.00 1.00 1.00 1.00 1.00 #> #> Omega ($omega): #> eta.cl eta.v eta.e0 #> eta.cl 0.3 0.0 0 #> eta.v 0.0 0.1 0 #> eta.e0 0.0 0.0 1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 te0 eta.e0 id #> 2 tcl eta.cl id #> 3 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- 0.45 #> label(\"Ka\") #> tcl <- 1 #> label(\"Cl\") #> tv <- 3.45 #> label(\"V\") #> add.sd <- c(0, 0.7) #> temax <- 1 #> te0 <- 1 #> tec50 <- 1 #> tkin <- 1 #> tkout <- 1 #> eta.cl ~ 0.3 #> eta.v ~ 0.1 #> eta.e0 ~ 1 #> }) #> model({ #> emax <- exp(temax) #> e0 <- exp(te0 + eta.e0) #> ec50 <- exp(tec50) #> kin <- exp(tkin) #> kout <- exp(tkout) #> ka <- exp(tka) #> cl <- exp(tcl + eta.cl) #> v <- exp(tv + eta.v) #> d/dt(depot) = -ka * depot #> d/dt(center) = ka * depot - cl/v * center #> cp = center/v #> cp ~ add(add.sd) #> }) #> } rxSetPipingAuto(thetamodelVars = rex::rex(\"te\")) mod9 <- mod |> model({ emax <- exp(temax) e0 <- exp(te0 + eta.e0) ec50 <- exp(tec50) kin <- exp(tkin) kout <- exp(tkout) }, append=FALSE) #> ℹ promote `temax` to population parameter with initial estimate 1 #> ℹ promote `te0` to population parameter with initial estimate 1 #> ℹ promote `eta.e0` to between subject variability with initial estimate 1 #> ℹ promote `tec50` to population parameter with initial estimate 1 print(mod9) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd temax te0 tec50 #> 0.45 1.00 3.45 0.70 1.00 1.00 1.00 #> #> Omega ($omega): #> eta.cl eta.v eta.e0 #> eta.cl 0.3 0.0 0 #> eta.v 0.0 0.1 0 #> eta.e0 0.0 0.0 1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 te0 eta.e0 id #> 2 tcl eta.cl id #> 3 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- 0.45 #> label(\"Ka\") #> tcl <- 1 #> label(\"Cl\") #> tv <- 3.45 #> label(\"V\") #> add.sd <- c(0, 0.7) #> temax <- 1 #> te0 <- 1 #> tec50 <- 1 #> eta.cl ~ 0.3 #> eta.v ~ 0.1 #> eta.e0 ~ 1 #> }) #> model({ #> emax <- exp(temax) #> e0 <- exp(te0 + eta.e0) #> ec50 <- exp(tec50) #> kin <- exp(tkin) #> kout <- exp(tkout) #> ka <- exp(tka) #> cl <- exp(tcl + eta.cl) #> v <- exp(tv + eta.v) #> d/dt(depot) = -ka * depot #> d/dt(center) = ka * depot - cl/v * center #> cp = center/v #> cp ~ add(add.sd) #> }) #> } rxSetPipingAuto() mod10 <- mod |> model({ emax <- exp(temax) e0 <- exp(te0 + eta.e0) ec50 <- exp(tec50) kin <- exp(tkin) kout <- exp(tkout) }, append=FALSE) #> ℹ promote `temax` to population parameter with initial estimate 1 #> ℹ promote `te0` to population parameter with initial estimate 1 #> ℹ promote `eta.e0` to between subject variability with initial estimate 1 #> ℹ promote `tec50` to population parameter with initial estimate 1 #> ℹ promote `tkin` to population parameter with initial estimate 1 #> ℹ promote `tkout` to population parameter with initial estimate 1"},{"path":"https://nlmixr2.github.io/rxode2/articles/Modifying-Models.html","id":"adding-model-lines","dir":"Articles","previous_headings":"Modifying model","what":"Adding model lines","title":"Modifying Models","text":"three ways insert lines rxode2/nlmixr2 model. can add lines end model, expression beginning model controlled append option. Let’s assume two different assays run compound noticed different variability. can modify model adding lines end model using append=TRUE: Perhaps instead may want add indirect response model addition concentrations, can choose add : append=lhsVar lhsVar left handed variable want insert new lines: last type insertion may wish add lines beginning model using append=FALSE:","code":"mod4 <- mod |> model({ cp2 <- cp cp2 ~ lnorm(lnorm.sd) }, append=TRUE) #> ℹ add residual parameter `lnorm.sd` and set estimate to 1 print(mod4) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd lnorm.sd #> 0.45 1.00 3.45 0.70 1.00 #> #> Omega ($omega): #> eta.cl eta.v #> eta.cl 0.3 0.0 #> eta.v 0.0 0.1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── Multiple Endpoint Model ($multipleEndpoint): ── #> variable cmt dvid* #> 1 cp ~ … cmt='cp' or cmt=3 dvid='cp' or dvid=1 #> 2 cp2 ~ … cmt='cp2' or cmt=4 dvid='cp2' 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 #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- 0.45 #> label(\"Ka\") #> tcl <- 1 #> label(\"Cl\") #> tv <- 3.45 #> label(\"V\") #> add.sd <- c(0, 0.7) #> lnorm.sd <- c(0, 1) #> eta.cl ~ 0.3 #> eta.v ~ 0.1 #> }) #> model({ #> ka <- exp(tka) #> cl <- exp(tcl + eta.cl) #> v <- exp(tv + eta.v) #> d/dt(depot) = -ka * depot #> d/dt(center) = ka * depot - cl/v * center #> cp = center/v #> cp ~ add(add.sd) #> cp2 <- cp #> cp2 ~ lnorm(lnorm.sd) #> }) #> } mod5 <- mod |> model({ PD <- 1-emax*cp/(ec50+cp) ## effect(0) <- e0 kin <- e0*kout d/dt(effect) <- kin*PD -kout*effect }, append=d/dt(center)) mod6 <- mod5 |> model({ emax <- exp(temax) e0 <- exp(te0 + eta.e0) ec50 <- exp(tec50) kin <- exp(tkin) kout <- exp(tkout) }, append=FALSE) #> ℹ promote `temax` to population parameter with initial estimate 1 #> ℹ promote `te0` to population parameter with initial estimate 1 #> ℹ promote `eta.e0` to between subject variability with initial estimate 1 #> ℹ promote `tec50` to population parameter with initial estimate 1 #> ℹ promote `tkin` to population parameter with initial estimate 1 #> ℹ promote `tkout` to population parameter with initial estimate 1 print(mod6) #> ── rxode2-based free-form 3-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd temax te0 tec50 tkin tkout #> 0.45 1.00 3.45 0.70 1.00 1.00 1.00 1.00 1.00 #> #> Omega ($omega): #> eta.cl eta.v eta.e0 #> eta.cl 0.3 0.0 0 #> eta.v 0.0 0.1 0 #> eta.e0 0.0 0.0 1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> 3 3 effect #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 te0 eta.e0 id #> 2 tcl eta.cl id #> 3 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- 0.45 #> label(\"Ka\") #> tcl <- 1 #> label(\"Cl\") #> tv <- 3.45 #> label(\"V\") #> add.sd <- c(0, 0.7) #> temax <- 1 #> te0 <- 1 #> tec50 <- 1 #> tkin <- 1 #> tkout <- 1 #> eta.cl ~ 0.3 #> eta.v ~ 0.1 #> eta.e0 ~ 1 #> }) #> model({ #> emax <- exp(temax) #> e0 <- exp(te0 + eta.e0) #> ec50 <- exp(tec50) #> kin <- exp(tkin) #> kout <- exp(tkout) #> ka <- exp(tka) #> cl <- exp(tcl + eta.cl) #> v <- exp(tv + eta.v) #> d/dt(depot) = -ka * depot #> d/dt(center) = ka * depot - cl/v * center #> PD <- 1 - emax * cp/(ec50 + cp) #> effect(0) <- e0 #> kin <- e0 * kout #> d/dt(effect) <- kin * PD - kout * effect #> cp = center/v #> cp ~ add(add.sd) #> }) #> }"},{"path":"https://nlmixr2.github.io/rxode2/articles/Modifying-Models.html","id":"remove-lines-in-the-model","dir":"Articles","previous_headings":"Modifying model","what":"Remove lines in the model","title":"Modifying Models","text":"lines model can removed one 2 ways either use -param param <- NULL model piping:","code":"mod7 <- mod6 |> model(-emax) #> ! remove population parameter `temax` print(mod7) #> ── rxode2-based free-form 3-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd te0 tec50 tkin tkout #> 0.45 1.00 3.45 0.70 1.00 1.00 1.00 1.00 #> #> Omega ($omega): #> eta.cl eta.v eta.e0 #> eta.cl 0.3 0.0 0 #> eta.v 0.0 0.1 0 #> eta.e0 0.0 0.0 1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> 3 3 effect #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 te0 eta.e0 id #> 2 tcl eta.cl id #> 3 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- 0.45 #> label(\"Ka\") #> tcl <- 1 #> label(\"Cl\") #> tv <- 3.45 #> label(\"V\") #> add.sd <- c(0, 0.7) #> te0 <- 1 #> tec50 <- 1 #> tkin <- 1 #> tkout <- 1 #> eta.cl ~ 0.3 #> eta.v ~ 0.1 #> eta.e0 ~ 1 #> }) #> model({ #> e0 <- exp(te0 + eta.e0) #> ec50 <- exp(tec50) #> kin <- exp(tkin) #> kout <- exp(tkout) #> ka <- exp(tka) #> cl <- exp(tcl + eta.cl) #> v <- exp(tv + eta.v) #> d/dt(depot) = -ka * depot #> d/dt(center) = ka * depot - cl/v * center #> PD <- 1 - emax * cp/(ec50 + cp) #> effect(0) <- e0 #> kin <- e0 * kout #> d/dt(effect) <- kin * PD - kout * effect #> cp = center/v #> cp ~ add(add.sd) #> }) #> } # Equivalently mod8 <- mod6 |> model(emax <- NULL) #> ! remove population parameter `temax` print(mod8) #> ── rxode2-based free-form 3-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd te0 tec50 tkin tkout #> 0.45 1.00 3.45 0.70 1.00 1.00 1.00 1.00 #> #> Omega ($omega): #> eta.cl eta.v eta.e0 #> eta.cl 0.3 0.0 0 #> eta.v 0.0 0.1 0 #> eta.e0 0.0 0.0 1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> 3 3 effect #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 te0 eta.e0 id #> 2 tcl eta.cl id #> 3 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- 0.45 #> label(\"Ka\") #> tcl <- 1 #> label(\"Cl\") #> tv <- 3.45 #> label(\"V\") #> add.sd <- c(0, 0.7) #> te0 <- 1 #> tec50 <- 1 #> tkin <- 1 #> tkout <- 1 #> eta.cl ~ 0.3 #> eta.v ~ 0.1 #> eta.e0 ~ 1 #> }) #> model({ #> e0 <- exp(te0 + eta.e0) #> ec50 <- exp(tec50) #> kin <- exp(tkin) #> kout <- exp(tkout) #> ka <- exp(tka) #> cl <- exp(tcl + eta.cl) #> v <- exp(tv + eta.v) #> d/dt(depot) = -ka * depot #> d/dt(center) = ka * depot - cl/v * center #> PD <- 1 - emax * cp/(ec50 + cp) #> effect(0) <- e0 #> kin <- e0 * kout #> d/dt(effect) <- kin * PD - kout * effect #> cp = center/v #> cp ~ add(add.sd) #> }) #> }"},{"path":"https://nlmixr2.github.io/rxode2/articles/Modifying-Models.html","id":"rename-parameters-in-a-model","dir":"Articles","previous_headings":"Modifying model","what":"Rename parameters in a model","title":"Modifying Models","text":"may want rename parameters model, easy rxRename(). dplyr loaded can even replace rename(). semantics similar two functions, assigning newVar=oldVar. example: can see every instance variable named model renamed inside model ini block. completeness can see dplyr verb (since S3 method):","code":"mod11 <- mod10 |> rxRename(drug1kout=kout, tv.drug1kout=tkout) print(mod11) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd temax te0 #> 0.45 1.00 3.45 0.70 1.00 1.00 #> tec50 tkin tv.drug1kout #> 1.00 1.00 1.00 #> #> Omega ($omega): #> eta.cl eta.v eta.e0 #> eta.cl 0.3 0.0 0 #> eta.v 0.0 0.1 0 #> eta.e0 0.0 0.0 1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 te0 eta.e0 id #> 2 tcl eta.cl id #> 3 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- 0.45 #> label(\"Ka\") #> tcl <- 1 #> label(\"Cl\") #> tv <- 3.45 #> label(\"V\") #> add.sd <- c(0, 0.7) #> temax <- 1 #> te0 <- 1 #> tec50 <- 1 #> tkin <- 1 #> tv.drug1kout <- 1 #> eta.cl ~ 0.3 #> eta.v ~ 0.1 #> eta.e0 ~ 1 #> }) #> model({ #> emax <- exp(temax) #> e0 <- exp(te0 + eta.e0) #> ec50 <- exp(tec50) #> kin <- exp(tkin) #> drug1kout <- exp(tv.drug1kout) #> ka <- exp(tka) #> cl <- exp(tcl + eta.cl) #> v <- exp(tv + eta.v) #> d/dt(depot) = -ka * depot #> d/dt(center) = ka * depot - cl/v * center #> cp = center/v #> cp ~ add(add.sd) #> }) #> } library(dplyr) #> #> Attaching package: 'dplyr' #> The following objects are masked from 'package:stats': #> #> filter, lag #> The following objects are masked from 'package:base': #> #> intersect, setdiff, setequal, union mod12 <- mod10 |> rename(drug1kout=kout, tv.drug1kout=tkout) print(mod12) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd temax te0 #> 0.45 1.00 3.45 0.70 1.00 1.00 #> tec50 tkin tv.drug1kout #> 1.00 1.00 1.00 #> #> Omega ($omega): #> eta.cl eta.v eta.e0 #> eta.cl 0.3 0.0 0 #> eta.v 0.0 0.1 0 #> eta.e0 0.0 0.0 1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 te0 eta.e0 id #> 2 tcl eta.cl id #> 3 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- 0.45 #> label(\"Ka\") #> tcl <- 1 #> label(\"Cl\") #> tv <- 3.45 #> label(\"V\") #> add.sd <- c(0, 0.7) #> temax <- 1 #> te0 <- 1 #> tec50 <- 1 #> tkin <- 1 #> tv.drug1kout <- 1 #> eta.cl ~ 0.3 #> eta.v ~ 0.1 #> eta.e0 ~ 1 #> }) #> model({ #> emax <- exp(temax) #> e0 <- exp(te0 + eta.e0) #> ec50 <- exp(tec50) #> kin <- exp(tkin) #> drug1kout <- exp(tv.drug1kout) #> ka <- exp(tka) #> cl <- exp(tcl + eta.cl) #> v <- exp(tv + eta.v) #> d/dt(depot) = -ka * depot #> d/dt(center) = ka * depot - cl/v * center #> cp = center/v #> cp ~ add(add.sd) #> }) #> }"},{"path":"https://nlmixr2.github.io/rxode2/articles/Modifying-Models.html","id":"combine-different-models","dir":"Articles","previous_headings":"Modifying model","what":"Combine different models","title":"Modifying Models","text":"can also combine different models rxAppendModel(). general need variables common combine. generally want models link . example pk pd model done renaming cp first model ceff second model: get error try combine models without variables common: want combine models without respecting variables common, can use common=FALSE:","code":"ocmt <- function() { ini({ tka <- exp(0.45) # Ka tcl <- exp(1) # Cl tv <- exp(3.45); # log V ## the label(\"Label name\") works with all models add.sd <- 0.7 }) model({ ka <- tka cl <- tcl v <- tv d/dt(depot) <- -ka * depot d/dt(center) <- ka * depot - cl / v * center cp <- center / v cp ~ add(add.sd) }) } idr <- function() { ini({ tkin <- log(1) tkout <- log(1) tic50 <- log(10) gamma <- fix(1) idr.sd <- 1 }) model({ kin <- exp(tkin) kout <- exp(tkout) ic50 <- exp(tic50) d/dt(eff) <- kin - kout*(1-ceff^gamma/(ic50^gamma+ceff^gamma)) eff ~ add(idr.sd) }) } rxAppendModel(ocmt %>% rxRename(ceff=cp), idr) #> ℹ parameter labels from comments will be replaced by 'label()' #> ── rxode2-based free-form 3-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd tkin tkout tic50 gamma #> 1.568312 2.718282 31.500392 0.700000 0.000000 0.000000 2.302585 1.000000 #> idr.sd #> 1.000000 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> 3 3 eff #> ── Multiple Endpoint Model ($multipleEndpoint): ── #> variable cmt dvid* #> 1 ceff ~ … cmt='ceff' or cmt=4 dvid='ceff' or dvid=1 #> 2 eff ~ … cmt='eff' or cmt=3 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 #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- 1.56831218549017 #> label(\"Ka\") #> tcl <- 2.71828182845905 #> label(\"Cl\") #> tv <- 31.5003923087479 #> label(\"log V\") #> add.sd <- c(0, 0.7) #> tkin <- 0 #> tkout <- 0 #> tic50 <- 2.30258509299405 #> gamma <- fix(1) #> idr.sd <- c(0, 1) #> }) #> model({ #> ka <- tka #> cl <- tcl #> v <- tv #> d/dt(depot) <- -ka * depot #> d/dt(center) <- ka * depot - cl/v * center #> ceff <- center/v #> ceff ~ add(add.sd) #> kin <- exp(tkin) #> kout <- exp(tkout) #> ic50 <- exp(tic50) #> d/dt(eff) <- kin - kout * (1 - ceff^gamma/(ic50^gamma + #> ceff^gamma)) #> eff ~ add(idr.sd) #> }) #> } try(rxAppendModel(ocmt, idr)) #> ℹ parameter labels from comments will be replaced by 'label()' #> Error : not all the models have variables in common (use `common=FALSE` to allow this) mod2 <- rxAppendModel(ocmt, idr, common=FALSE) |> model(ceff=cp, append=ic50) # here we add the translation after the #> ℹ parameter labels from comments will be replaced by 'label()' # ic50 line to make it reasonable print(mod2) #> ── rxode2-based free-form 3-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd tkin tkout tic50 gamma #> 1.568312 2.718282 31.500392 0.700000 0.000000 0.000000 2.302585 1.000000 #> idr.sd #> 1.000000 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> 3 3 eff #> ── Multiple Endpoint Model ($multipleEndpoint): ── #> variable cmt dvid* #> 1 cp ~ … cmt='cp' or cmt=4 dvid='cp' or dvid=1 #> 2 eff ~ … cmt='eff' or cmt=3 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 #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- 1.56831218549017 #> label(\"Ka\") #> tcl <- 2.71828182845905 #> label(\"Cl\") #> tv <- 31.5003923087479 #> label(\"log V\") #> add.sd <- c(0, 0.7) #> tkin <- 0 #> tkout <- 0 #> tic50 <- 2.30258509299405 #> gamma <- fix(1) #> idr.sd <- c(0, 1) #> }) #> model({ #> ka <- tka #> cl <- tcl #> v <- tv #> d/dt(depot) <- -ka * depot #> d/dt(center) <- ka * depot - cl/v * center #> cp <- center/v #> cp ~ add(add.sd) #> kin <- exp(tkin) #> kout <- exp(tkout) #> ic50 <- exp(tic50) #> ceff <- cp #> d/dt(eff) <- kin - kout * (1 - ceff^gamma/(ic50^gamma + #> ceff^gamma)) #> eff ~ add(idr.sd) #> }) #> }"},{"path":"https://nlmixr2.github.io/rxode2/articles/Modifying-Models.html","id":"creating-more-complex-model-modification-functions","dir":"Articles","previous_headings":"Modifying model","what":"Creating more complex model modification functions","title":"Modifying Models","text":"pretty flexible, may want even , helper functions help create functions . discuss extract model function update . Lets start model: Lets assume moment want remove eta cl. First probably want get model lines. can modelExtract(): Now want worry cl line, can subset : Now wish change line “cl <- exp(tcl+eta.cl)” Note functions modify ini({}) block. may modify ini block first make valid rxode2/nlmixr2 model. particular case, using model piping easier, simply demonstrates two different way extract model information way add information final model. methods can tricky using model parsed correctly. means make sure parameters endpoints follow correct rules","code":"f <- function() { ini({ tka <- 0.45 tcl <- 1 tv <- 3.45 eta.ka ~ 0.6 eta.v ~ 0.1 }) model({ ka <- exp(tka + eta.ka) cl <- exp(tcl) v <- exp(tv + eta.v) d/dt(depot) <- -ka * depot d/dt(center) <- ka * depot - cl/v * center cp <- center/v }) } totLines <- modelExtract(f, endpoint=NA) # endpoints should be included print(totLines) #> [1] \"ka <- exp(tka + eta.ka)\" #> [2] \"cl <- exp(tcl)\" #> [3] \"v <- exp(tv + eta.v)\" #> [4] \"d/dt(depot) <- -ka * depot\" #> [5] \"d/dt(center) <- ka * depot - cl/v * center\" #> [6] \"cp <- center/v\" clLine <- modelExtract(f, cl, lines=TRUE) line <- attr(clLine, \"lines\") totLines[line] <- \"cl <- exp(tcl+eta.cl)\" # For now lets remove the entire `ini` block (so you don't have to # worry about syncing parameters). # ini(f) <- NULL model(f) <- totLines #> ℹ parameter labels from comments are typically ignored in non-interactive mode #> ℹ Need to run with the source intact to parse comments print(f) #> function () #> { #> ini({ #> }) #> model({ #> ka <- exp(tka + eta.ka) #> cl <- exp(tcl + eta.cl) #> v <- exp(tv + eta.v) #> d/dt(depot) <- -ka * depot #> d/dt(center) <- ka * depot - cl/v * center #> cp <- center/v #> }) #> } #> "},{"path":"https://nlmixr2.github.io/rxode2/articles/Modifying-Models.html","id":"modifying-initial-estimates","dir":"Articles","previous_headings":"","what":"Modifying initial estimates","title":"Modifying Models","text":"common items want initial estimates : Fix/Unfix parameter Change initial condition values bounds Change initial condition type Change labels transformations Reorder parameters may wish create functions; discuss .","code":""},{"path":"https://nlmixr2.github.io/rxode2/articles/Modifying-Models.html","id":"fixing-or-unfixing-a-parameter","dir":"Articles","previous_headings":"Modifying initial estimates","what":"Fixing or unfixing a parameter","title":"Modifying Models","text":"can fix model estimates two ways. first fix value whatever model function, done piping model parameter name (like tka) setting equal fix (%>% ini(tka=fix)). full example: can also fix parameter different value wish; similar can specify value fix inside fix pseudo-function follows: %>% ini(tka=fix(0.1)). fully worked example :","code":"f <- function() { ini({ tka <- 0.45 tcl <- 1 tv <- 3.45 add.sd <- c(0, 0.7) eta.ka ~ 0.6 eta.v ~ 0.1 }) model({ ka <- exp(tka + eta.ka) cl <- exp(tcl) v <- exp(tv + eta.v) d/dt(depot) <- -ka * depot d/dt(center) <- ka * depot - cl/v * center cp <- center/v cp ~ add(add.sd) }) } f2 <- f |> ini(tka=fix) #> ℹ fix `tka` to `0.45` print(f2) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd #> 0.45 1.00 3.45 0.70 #> #> Omega ($omega): #> eta.ka eta.v #> eta.ka 0.6 0.0 #> eta.v 0.0 0.1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 tka eta.ka id #> 2 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- fix(0.45) #> tcl <- 1 #> tv <- 3.45 #> add.sd <- c(0, 0.7) #> eta.ka ~ 0.6 #> eta.v ~ 0.1 #> }) #> model({ #> ka <- exp(tka + eta.ka) #> cl <- exp(tcl) #> v <- exp(tv + eta.v) #> d/dt(depot) <- -ka * depot #> d/dt(center) <- ka * depot - cl/v * center #> cp <- center/v #> cp ~ add(add.sd) #> }) #> } f <- function() { ini({ tka <- 0.45 tcl <- 1 tv <- 3.45 add.sd <- c(0, 0.7) eta.ka ~ 0.6 eta.v ~ 0.1 }) model({ ka <- exp(tka + eta.ka) cl <- exp(tcl) v <- exp(tv + eta.v) d/dt(depot) <- -ka * depot d/dt(center) <- ka * depot - cl/v * center cp <- center/v cp ~ add(add.sd) }) } f2 <- f |> ini(tka=fix(0.1)) #> ℹ fix `tka` to `0.45` #> ℹ change initial estimate of `tka` to `0.1` print(f2) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd #> 0.10 1.00 3.45 0.70 #> #> Omega ($omega): #> eta.ka eta.v #> eta.ka 0.6 0.0 #> eta.v 0.0 0.1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 tka eta.ka id #> 2 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- fix(0.1) #> tcl <- 1 #> tv <- 3.45 #> add.sd <- c(0, 0.7) #> eta.ka ~ 0.6 #> eta.v ~ 0.1 #> }) #> model({ #> ka <- exp(tka + eta.ka) #> cl <- exp(tcl) #> v <- exp(tv + eta.v) #> d/dt(depot) <- -ka * depot #> d/dt(center) <- ka * depot - cl/v * center #> cp <- center/v #> cp ~ add(add.sd) #> }) #> }"},{"path":"https://nlmixr2.github.io/rxode2/articles/Modifying-Models.html","id":"unfixing-parameters","dir":"Articles","previous_headings":"Modifying initial estimates","what":"Unfixing parameters","title":"Modifying Models","text":"unfix parameters similarly fixing. Instead using fix keyword, use unfix keyword. unfix parameter (keeping value) pipe model using (|> ini(tka=unfix)). Starting fixed model fully worked example : can also unfix change initial estimate ini(parameter=unfix(newEst)):","code":"print(f2) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd #> 0.10 1.00 3.45 0.70 #> #> Omega ($omega): #> eta.ka eta.v #> eta.ka 0.6 0.0 #> eta.v 0.0 0.1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 tka eta.ka id #> 2 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- fix(0.1) #> tcl <- 1 #> tv <- 3.45 #> add.sd <- c(0, 0.7) #> eta.ka ~ 0.6 #> eta.v ~ 0.1 #> }) #> model({ #> ka <- exp(tka + eta.ka) #> cl <- exp(tcl) #> v <- exp(tv + eta.v) #> d/dt(depot) <- -ka * depot #> d/dt(center) <- ka * depot - cl/v * center #> cp <- center/v #> cp ~ add(add.sd) #> }) #> } f3 <- f2 |> ini(tka=unfix) #> ℹ unfix `tka` keeping initial estimate `0.1` print(f3) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd #> 0.10 1.00 3.45 0.70 #> #> Omega ($omega): #> eta.ka eta.v #> eta.ka 0.6 0.0 #> eta.v 0.0 0.1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 tka eta.ka id #> 2 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- 0.1 #> tcl <- 1 #> tv <- 3.45 #> add.sd <- c(0, 0.7) #> eta.ka ~ 0.6 #> eta.v ~ 0.1 #> }) #> model({ #> ka <- exp(tka + eta.ka) #> cl <- exp(tcl) #> v <- exp(tv + eta.v) #> d/dt(depot) <- -ka * depot #> d/dt(center) <- ka * depot - cl/v * center #> cp <- center/v #> cp ~ add(add.sd) #> }) #> } print(f2) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd #> 0.10 1.00 3.45 0.70 #> #> Omega ($omega): #> eta.ka eta.v #> eta.ka 0.6 0.0 #> eta.v 0.0 0.1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 tka eta.ka id #> 2 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- fix(0.1) #> tcl <- 1 #> tv <- 3.45 #> add.sd <- c(0, 0.7) #> eta.ka ~ 0.6 #> eta.v ~ 0.1 #> }) #> model({ #> ka <- exp(tka + eta.ka) #> cl <- exp(tcl) #> v <- exp(tv + eta.v) #> d/dt(depot) <- -ka * depot #> d/dt(center) <- ka * depot - cl/v * center #> cp <- center/v #> cp ~ add(add.sd) #> }) #> } f3 <- f2 |> ini(tka=unfix(10)) #> ℹ unfix `tka` keeping initial estimate `0.1` #> ℹ change initial estimate of `tka` to `10` print(f3) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd #> 10.00 1.00 3.45 0.70 #> #> Omega ($omega): #> eta.ka eta.v #> eta.ka 0.6 0.0 #> eta.v 0.0 0.1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 tka eta.ka id #> 2 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- 10 #> tcl <- 1 #> tv <- 3.45 #> add.sd <- c(0, 0.7) #> eta.ka ~ 0.6 #> eta.v ~ 0.1 #> }) #> model({ #> ka <- exp(tka + eta.ka) #> cl <- exp(tcl) #> v <- exp(tv + eta.v) #> d/dt(depot) <- -ka * depot #> d/dt(center) <- ka * depot - cl/v * center #> cp <- center/v #> cp ~ add(add.sd) #> }) #> }"},{"path":[]},{"path":"https://nlmixr2.github.io/rxode2/articles/Modifying-Models.html","id":"multiple-parameter-assignment","dir":"Articles","previous_headings":"Modifying initial estimates > Changing the parameter values and possibly bounds","what":"Multiple parameter assignment","title":"Modifying Models","text":"can also assign multiple parameters providing : vector/list multiple lines piped ini() block Using covariance matrix case vector can specify pipe model. example: can also added multiple lines commas separating estimates: also use matrix specify covariance:","code":"ini1 <- c(tka=0.1, tcl=1, tv=3) f4 <- f |> ini(ini1) #> ℹ change initial estimate of `tka` to `0.1` #> ℹ change initial estimate of `tcl` to `1` #> ℹ change initial estimate of `tv` to `3` print(f4) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd #> 0.1 1.0 3.0 0.7 #> #> Omega ($omega): #> eta.ka eta.v #> eta.ka 0.6 0.0 #> eta.v 0.0 0.1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 tka eta.ka id #> 2 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- 0.1 #> tcl <- 1 #> tv <- 3 #> add.sd <- c(0, 0.7) #> eta.ka ~ 0.6 #> eta.v ~ 0.1 #> }) #> model({ #> ka <- exp(tka + eta.ka) #> cl <- exp(tcl) #> v <- exp(tv + eta.v) #> d/dt(depot) <- -ka * depot #> d/dt(center) <- ka * depot - cl/v * center #> cp <- center/v #> cp ~ add(add.sd) #> }) #> } # or equivalently ini1 <- list(tka=0.1, tcl=1, tv=3) f4a <- f |> ini(ini1) #> ℹ change initial estimate of `tka` to `0.1` #> ℹ change initial estimate of `tcl` to `1` #> ℹ change initial estimate of `tv` to `3` print(f4) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd #> 0.1 1.0 3.0 0.7 #> #> Omega ($omega): #> eta.ka eta.v #> eta.ka 0.6 0.0 #> eta.v 0.0 0.1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 tka eta.ka id #> 2 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- 0.1 #> tcl <- 1 #> tv <- 3 #> add.sd <- c(0, 0.7) #> eta.ka ~ 0.6 #> eta.v ~ 0.1 #> }) #> model({ #> ka <- exp(tka + eta.ka) #> cl <- exp(tcl) #> v <- exp(tv + eta.v) #> d/dt(depot) <- -ka * depot #> d/dt(center) <- ka * depot - cl/v * center #> cp <- center/v #> cp ~ add(add.sd) #> }) #> } # commas separating values: f4 <- f |> ini(tka=0.1, tcl=1, tv=3) #> ℹ change initial estimate of `tka` to `0.1` #> ℹ change initial estimate of `tcl` to `1` #> ℹ change initial estimate of `tv` to `3` print(f4) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd #> 0.1 1.0 3.0 0.7 #> #> Omega ($omega): #> eta.ka eta.v #> eta.ka 0.6 0.0 #> eta.v 0.0 0.1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 tka eta.ka id #> 2 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- 0.1 #> tcl <- 1 #> tv <- 3 #> add.sd <- c(0, 0.7) #> eta.ka ~ 0.6 #> eta.v ~ 0.1 #> }) #> model({ #> ka <- exp(tka + eta.ka) #> cl <- exp(tcl) #> v <- exp(tv + eta.v) #> d/dt(depot) <- -ka * depot #> d/dt(center) <- ka * depot - cl/v * center #> cp <- center/v #> cp ~ add(add.sd) #> }) #> } # multiple lines in {} f4 <- f |> ini({ tka <- 0.2 tcl <- 2 tv <- 6 }) #> ℹ change initial estimate of `tka` to `0.2` #> ℹ change initial estimate of `tcl` to `2` #> ℹ change initial estimate of `tv` to `6` print(f4) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd #> 0.2 2.0 6.0 0.7 #> #> Omega ($omega): #> eta.ka eta.v #> eta.ka 0.6 0.0 #> eta.v 0.0 0.1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 tka eta.ka id #> 2 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- 0.2 #> tcl <- 2 #> tv <- 6 #> add.sd <- c(0, 0.7) #> eta.ka ~ 0.6 #> eta.v ~ 0.1 #> }) #> model({ #> ka <- exp(tka + eta.ka) #> cl <- exp(tcl) #> v <- exp(tv + eta.v) #> d/dt(depot) <- -ka * depot #> d/dt(center) <- ka * depot - cl/v * center #> cp <- center/v #> cp ~ add(add.sd) #> }) #> } ome <- lotri(eta.ka + eta.v ~ c(0.6, 0.01, 10.1)) f4 <- f |> ini(ome) #> ℹ change initial estimate of `eta.ka` to `0.6` #> ℹ add covariance between `eta.v` and `eta.ka` with initial estimate `0.01` #> ℹ change initial estimate of `eta.v` to `10.1` print(f4) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd #> 0.45 1.00 3.45 0.70 #> #> Omega ($omega): #> eta.ka eta.v #> eta.ka 0.60 0.01 #> eta.v 0.01 10.10 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 tka eta.ka id #> 2 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- 0.45 #> tcl <- 1 #> tv <- 3.45 #> add.sd <- c(0, 0.7) #> eta.ka + eta.v ~ c(0.6, 0.01, 10.1) #> }) #> model({ #> ka <- exp(tka + eta.ka) #> cl <- exp(tcl) #> v <- exp(tv + eta.v) #> d/dt(depot) <- -ka * depot #> d/dt(center) <- ka * depot - cl/v * center #> cp <- center/v #> cp ~ add(add.sd) #> }) #> } # or equavialtly use the lotri-type syntax for the omega: f4 <- f |> ini(eta.ka + eta.v ~ c(0.6, 0.01, 0.2)) #> ℹ change initial estimate of `eta.ka` to `0.6` #> ℹ add covariance between `eta.v` and `eta.ka` with initial estimate `0.01` #> ℹ change initial estimate of `eta.v` to `0.2` print(f4) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd #> 0.45 1.00 3.45 0.70 #> #> Omega ($omega): #> eta.ka eta.v #> eta.ka 0.60 0.01 #> eta.v 0.01 0.20 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 tka eta.ka id #> 2 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- 0.45 #> tcl <- 1 #> tv <- 3.45 #> add.sd <- c(0, 0.7) #> eta.ka + eta.v ~ c(0.6, 0.01, 0.2) #> }) #> model({ #> ka <- exp(tka + eta.ka) #> cl <- exp(tcl) #> v <- exp(tv + eta.v) #> d/dt(depot) <- -ka * depot #> d/dt(center) <- ka * depot - cl/v * center #> cp <- center/v #> cp ~ add(add.sd) #> }) #> }"},{"path":"https://nlmixr2.github.io/rxode2/articles/Modifying-Models.html","id":"single-parameter-assignment","dir":"Articles","previous_headings":"Modifying initial estimates > Changing the parameter values and possibly bounds","what":"Single parameter assignment","title":"Modifying Models","text":"simplest way change initial parameter estimates simply use ini(parameter=newValue). can also use <- ~ change value: fully worked example showing three types initial value modification : can change bounds like model specification using numeric vector c(low, estimate) c(low, estimate, hi). worked example: Note changing parameters default values might show parameter printout:","code":"f3 <- f |> ini(tka <- 0.1) #> ℹ change initial estimate of `tka` to `0.1` f4 <- f |> ini(tka=0.1) #> ℹ change initial estimate of `tka` to `0.1` f5 <- f |> ini(tka ~ 0.1) #> ℹ change initial estimate of `tka` to `0.1` print(f5) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd #> 0.10 1.00 3.45 0.70 #> #> Omega ($omega): #> eta.ka eta.v #> eta.ka 0.6 0.0 #> eta.v 0.0 0.1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 tka eta.ka id #> 2 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- 0.1 #> tcl <- 1 #> tv <- 3.45 #> add.sd <- c(0, 0.7) #> eta.ka ~ 0.6 #> eta.v ~ 0.1 #> }) #> model({ #> ka <- exp(tka + eta.ka) #> cl <- exp(tcl) #> v <- exp(tv + eta.v) #> d/dt(depot) <- -ka * depot #> d/dt(center) <- ka * depot - cl/v * center #> cp <- center/v #> cp ~ add(add.sd) #> }) #> } f3 <- f |> ini(tka <- c(0, 0.1, 0.2)) #> ℹ change initial estimate (0.1) and upper/lower bound (0 to 0.2) of `tka` print(f3) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd #> 0.10 1.00 3.45 0.70 #> #> Omega ($omega): #> eta.ka eta.v #> eta.ka 0.6 0.0 #> eta.v 0.0 0.1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 tka eta.ka id #> 2 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- c(0, 0.1, 0.2) #> tcl <- 1 #> tv <- 3.45 #> add.sd <- c(0, 0.7) #> eta.ka ~ 0.6 #> eta.v ~ 0.1 #> }) #> model({ #> ka <- exp(tka + eta.ka) #> cl <- exp(tcl) #> v <- exp(tv + eta.v) #> d/dt(depot) <- -ka * depot #> d/dt(center) <- ka * depot - cl/v * center #> cp <- center/v #> cp ~ add(add.sd) #> }) #> } f3 <- f |> ini(tka <- c(0, 0.1)) #> ℹ change initial estimate (0.1) and lower bound (0) of `tka` print(f3) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd #> 0.10 1.00 3.45 0.70 #> #> Omega ($omega): #> eta.ka eta.v #> eta.ka 0.6 0.0 #> eta.v 0.0 0.1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 tka eta.ka id #> 2 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- c(0, 0.1) #> tcl <- 1 #> tv <- 3.45 #> add.sd <- c(0, 0.7) #> eta.ka ~ 0.6 #> eta.v ~ 0.1 #> }) #> model({ #> ka <- exp(tka + eta.ka) #> cl <- exp(tcl) #> v <- exp(tv + eta.v) #> d/dt(depot) <- -ka * depot #> d/dt(center) <- ka * depot - cl/v * center #> cp <- center/v #> cp ~ add(add.sd) #> }) #> } f3 <- f |> ini(tka <- c(0, 0.1, 0.2)) #> ℹ change initial estimate (0.1) and upper/lower bound (0 to 0.2) of `tka` print(f3) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd #> 0.10 1.00 3.45 0.70 #> #> Omega ($omega): #> eta.ka eta.v #> eta.ka 0.6 0.0 #> eta.v 0.0 0.1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 tka eta.ka id #> 2 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- c(0, 0.1, 0.2) #> tcl <- 1 #> tv <- 3.45 #> add.sd <- c(0, 0.7) #> eta.ka ~ 0.6 #> eta.v ~ 0.1 #> }) #> model({ #> ka <- exp(tka + eta.ka) #> cl <- exp(tcl) #> v <- exp(tv + eta.v) #> d/dt(depot) <- -ka * depot #> d/dt(center) <- ka * depot - cl/v * center #> cp <- center/v #> cp ~ add(add.sd) #> }) #> } # Now reassign f4 <- f3 |> ini(tka <- c(-Inf, 0.1, Inf)) #> ℹ change initial estimate (0.1) and upper/lower bound (-Inf to Inf) of `tka` print(f4) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd #> 0.10 1.00 3.45 0.70 #> #> Omega ($omega): #> eta.ka eta.v #> eta.ka 0.6 0.0 #> eta.v 0.0 0.1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 tka eta.ka id #> 2 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- 0.1 #> tcl <- 1 #> tv <- 3.45 #> add.sd <- c(0, 0.7) #> eta.ka ~ 0.6 #> eta.v ~ 0.1 #> }) #> model({ #> ka <- exp(tka + eta.ka) #> cl <- exp(tcl) #> v <- exp(tv + eta.v) #> d/dt(depot) <- -ka * depot #> d/dt(center) <- ka * depot - cl/v * center #> cp <- center/v #> cp ~ add(add.sd) #> }) #> }"},{"path":"https://nlmixr2.github.io/rxode2/articles/Modifying-Models.html","id":"changing-parameter-types","dir":"Articles","previous_headings":"Modifying initial estimates > Changing the parameter values and possibly bounds","what":"Changing parameter types","title":"Modifying Models","text":"can change parameter type two operators either using -par convert parameter covariate ~par toggle population individual parameters. example 3:","code":"# Switch population parameter to between subject variability parameter: f4 <- f |> ini( ~ tcl) #> ℹ convert 'tcl' from population parameter to between subject variability print(f4) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tv add.sd #> 0.45 3.45 0.70 #> #> Omega ($omega): #> eta.ka eta.v tcl #> eta.ka 0.6 0.0 0 #> eta.v 0.0 0.1 0 #> tcl 0.0 0.0 1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 tka eta.ka id #> 2 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- 0.45 #> tv <- 3.45 #> add.sd <- c(0, 0.7) #> eta.ka ~ 0.6 #> eta.v ~ 0.1 #> tcl ~ 1 #> }) #> model({ #> ka <- exp(tka + eta.ka) #> cl <- exp(tcl) #> v <- exp(tv + eta.v) #> d/dt(depot) <- -ka * depot #> d/dt(center) <- ka * depot - cl/v * center #> cp <- center/v #> cp ~ add(add.sd) #> }) #> } # Switch back to population parameter f5 <- f4 |> ini( ~ tcl) #> ℹ convert 'tcl' from between subject variability to population parameter print(f5) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tv add.sd tcl #> 0.45 3.45 0.70 1.00 #> #> Omega ($omega): #> eta.ka eta.v #> eta.ka 0.6 0.0 #> eta.v 0.0 0.1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 tka eta.ka id #> 2 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- 0.45 #> tv <- 3.45 #> add.sd <- c(0, 0.7) #> tcl <- 1 #> eta.ka ~ 0.6 #> eta.v ~ 0.1 #> }) #> model({ #> ka <- exp(tka + eta.ka) #> cl <- exp(tcl) #> v <- exp(tv + eta.v) #> d/dt(depot) <- -ka * depot #> d/dt(center) <- ka * depot - cl/v * center #> cp <- center/v #> cp ~ add(add.sd) #> }) #> } # Change the variable to a covariate parameter (ie it doesn't have an # initial estimate so remove it with the `-` operator): f6 <- f4 |> ini(-tcl) #> ℹ changing between subject variability parameter 'tcl' to covariate parameter print(f6) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tv add.sd #> 0.45 3.45 0.70 #> #> Omega ($omega): #> eta.ka eta.v #> eta.ka 0.6 0.0 #> eta.v 0.0 0.1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 tka eta.ka id #> 2 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- 0.45 #> tv <- 3.45 #> add.sd <- c(0, 0.7) #> eta.ka ~ 0.6 #> eta.v ~ 0.1 #> }) #> model({ #> ka <- exp(tka + eta.ka) #> cl <- exp(tcl) #> v <- exp(tv + eta.v) #> d/dt(depot) <- -ka * depot #> d/dt(center) <- ka * depot - cl/v * center #> cp <- center/v #> cp ~ add(add.sd) #> }) #> } # You can change the covariate or remove the parameter estimate by # `tcl <- NULL`: f6 <- f4 |> ini(tcl <- NULL) #> ℹ changing between subject variability parameter 'tcl' to covariate parameter print(f6) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tv add.sd #> 0.45 3.45 0.70 #> #> Omega ($omega): #> eta.ka eta.v #> eta.ka 0.6 0.0 #> eta.v 0.0 0.1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 tka eta.ka id #> 2 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- 0.45 #> tv <- 3.45 #> add.sd <- c(0, 0.7) #> eta.ka ~ 0.6 #> eta.v ~ 0.1 #> }) #> model({ #> ka <- exp(tka + eta.ka) #> cl <- exp(tcl) #> v <- exp(tv + eta.v) #> d/dt(depot) <- -ka * depot #> d/dt(center) <- ka * depot - cl/v * center #> cp <- center/v #> cp ~ add(add.sd) #> }) #> } # to add it back as a between subject variability or population # parameter you can pipe it as follows: f7 <- f6 |> ini(tcl=4) #> ℹ promote `tcl` to population parameter with initial estimate 4 #> ℹ change initial estimate of `tcl` to `4` print(f7) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tv add.sd tcl #> 0.45 3.45 0.70 4.00 #> #> Omega ($omega): #> eta.ka eta.v #> eta.ka 0.6 0.0 #> eta.v 0.0 0.1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 tka eta.ka id #> 2 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- 0.45 #> tv <- 3.45 #> add.sd <- c(0, 0.7) #> tcl <- 4 #> eta.ka ~ 0.6 #> eta.v ~ 0.1 #> }) #> model({ #> ka <- exp(tka + eta.ka) #> cl <- exp(tcl) #> v <- exp(tv + eta.v) #> d/dt(depot) <- -ka * depot #> d/dt(center) <- ka * depot - cl/v * center #> cp <- center/v #> cp ~ add(add.sd) #> }) #> } f8 <- f6 |> ini(tcl ~ 0.1) #> ℹ promote `tcl` to between subject variability with initial estimate 0.1 #> ℹ change initial estimate of `tcl` to `0.1` print(f8) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tv add.sd #> 0.45 3.45 0.70 #> #> Omega ($omega): #> eta.ka eta.v tcl #> eta.ka 0.6 0.0 0.0 #> eta.v 0.0 0.1 0.0 #> tcl 0.0 0.0 0.1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 tka eta.ka id #> 2 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- 0.45 #> tv <- 3.45 #> add.sd <- c(0, 0.7) #> eta.ka ~ 0.6 #> eta.v ~ 0.1 #> tcl ~ 0.1 #> }) #> model({ #> ka <- exp(tka + eta.ka) #> cl <- exp(tcl) #> v <- exp(tv + eta.v) #> d/dt(depot) <- -ka * depot #> d/dt(center) <- ka * depot - cl/v * center #> cp <- center/v #> cp ~ add(add.sd) #> }) #> }"},{"path":"https://nlmixr2.github.io/rxode2/articles/Modifying-Models.html","id":"changing-parameter-labels","dir":"Articles","previous_headings":"Modifying initial estimates > Changing the parameter values and possibly bounds","what":"Changing parameter labels","title":"Modifying Models","text":"want change/add parameter label assign parameter label(\"label add\"). example: can also change order performing operations: want remove labels can remove ini(par=label(NULL)); example:","code":"f4 <- f |> ini(tka=label(\"Typical Ka (1/hr)\")) print(f4) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd #> 0.45 1.00 3.45 0.70 #> #> Omega ($omega): #> eta.ka eta.v #> eta.ka 0.6 0.0 #> eta.v 0.0 0.1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 tka eta.ka id #> 2 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- 0.45 #> label(\"Typical Ka (1/hr)\") #> tcl <- 1 #> tv <- 3.45 #> add.sd <- c(0, 0.7) #> eta.ka ~ 0.6 #> eta.v ~ 0.1 #> }) #> model({ #> ka <- exp(tka + eta.ka) #> cl <- exp(tcl) #> v <- exp(tv + eta.v) #> d/dt(depot) <- -ka * depot #> d/dt(center) <- ka * depot - cl/v * center #> cp <- center/v #> cp ~ add(add.sd) #> }) #> } f5 <- f |> ini(tka=label(\"Typical Ka (1/hr)\"), append=tcl) print(f5) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tcl tka tv add.sd #> 1.00 0.45 3.45 0.70 #> #> Omega ($omega): #> eta.ka eta.v #> eta.ka 0.6 0.0 #> eta.v 0.0 0.1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 tka eta.ka id #> 2 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tcl <- 1 #> tka <- 0.45 #> label(\"Typical Ka (1/hr)\") #> tv <- 3.45 #> add.sd <- c(0, 0.7) #> eta.ka ~ 0.6 #> eta.v ~ 0.1 #> }) #> model({ #> ka <- exp(tka + eta.ka) #> cl <- exp(tcl) #> v <- exp(tv + eta.v) #> d/dt(depot) <- -ka * depot #> d/dt(center) <- ka * depot - cl/v * center #> cp <- center/v #> cp ~ add(add.sd) #> }) #> } f6 <- f |> ini(tka=label(NULL)) print(f6) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd #> 0.45 1.00 3.45 0.70 #> #> Omega ($omega): #> eta.ka eta.v #> eta.ka 0.6 0.0 #> eta.v 0.0 0.1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 tka eta.ka id #> 2 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- 0.45 #> tcl <- 1 #> tv <- 3.45 #> add.sd <- c(0, 0.7) #> eta.ka ~ 0.6 #> eta.v ~ 0.1 #> }) #> model({ #> ka <- exp(tka + eta.ka) #> cl <- exp(tcl) #> v <- exp(tv + eta.v) #> d/dt(depot) <- -ka * depot #> d/dt(center) <- ka * depot - cl/v * center #> cp <- center/v #> cp ~ add(add.sd) #> }) #> }"},{"path":"https://nlmixr2.github.io/rxode2/articles/Modifying-Models.html","id":"changing-parameter-transformations","dir":"Articles","previous_headings":"Modifying initial estimates > Changing the parameter values and possibly bounds","what":"Changing parameter transformations","title":"Modifying Models","text":"Back-transformations -ride back transformations nlmixr2 models. similar modification labels. use |> ini(tka=backTransform(exp)) add exponential back-transformation data: wish remove can also |> ini(tka=backTransform(NULL)):","code":"f7 <- f |> ini(tka=backTransform(exp)) print(f7) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd #> 0.45 1.00 3.45 0.70 #> #> Omega ($omega): #> eta.ka eta.v #> eta.ka 0.6 0.0 #> eta.v 0.0 0.1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 tka eta.ka id #> 2 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- 0.45 #> backTransform(\"exp\") #> tcl <- 1 #> tv <- 3.45 #> add.sd <- c(0, 0.7) #> eta.ka ~ 0.6 #> eta.v ~ 0.1 #> }) #> model({ #> ka <- exp(tka + eta.ka) #> cl <- exp(tcl) #> v <- exp(tv + eta.v) #> d/dt(depot) <- -ka * depot #> d/dt(center) <- ka * depot - cl/v * center #> cp <- center/v #> cp ~ add(add.sd) #> }) #> } f8 <- f |> ini(tka=backTransform(NULL)) print(f8) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd #> 0.45 1.00 3.45 0.70 #> #> Omega ($omega): #> eta.ka eta.v #> eta.ka 0.6 0.0 #> eta.v 0.0 0.1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 tka eta.ka id #> 2 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- 0.45 #> tcl <- 1 #> tv <- 3.45 #> add.sd <- c(0, 0.7) #> eta.ka ~ 0.6 #> eta.v ~ 0.1 #> }) #> model({ #> ka <- exp(tka + eta.ka) #> cl <- exp(tcl) #> v <- exp(tv + eta.v) #> d/dt(depot) <- -ka * depot #> d/dt(center) <- ka * depot - cl/v * center #> cp <- center/v #> cp ~ add(add.sd) #> }) #> }"},{"path":"https://nlmixr2.github.io/rxode2/articles/Modifying-Models.html","id":"more-granular-access-of-initial-conditions","dir":"Articles","previous_headings":"Modifying initial estimates","what":"More granular access of initial conditions","title":"Modifying Models","text":"Just like model() can modify underlying data frame represents ini() block. case simply change initial estimate first parameter (tka):","code":"f <- rxode2(f) ini <- f$iniDf print(ini) #> ntheta neta1 neta2 name lower est upper fix label backTransform #> 1 1 NA NA tka -Inf 0.45 Inf FALSE #> 2 2 NA NA tcl -Inf 1.00 Inf FALSE #> 3 3 NA NA tv -Inf 3.45 Inf FALSE #> 4 4 NA NA add.sd 0 0.70 Inf FALSE #> 5 NA 1 1 eta.ka -Inf 0.60 Inf FALSE #> 6 NA 2 2 eta.v -Inf 0.10 Inf FALSE #> condition err #> 1 #> 2 #> 3 #> 4 cp add #> 5 id #> 6 id ini$est[1] <- 7 ini(f) <- ini print(f) #> ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── #> ── Initalization: ── #> Fixed Effects ($theta): #> tka tcl tv add.sd #> 7.00 1.00 3.45 0.70 #> #> Omega ($omega): #> eta.ka eta.v #> eta.ka 0.6 0.0 #> eta.v 0.0 0.1 #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> ── μ-referencing ($muRefTable): ── #> theta eta level #> 1 tka eta.ka id #> 2 tv eta.v id #> #> ── Model (Normalized Syntax): ── #> function() { #> ini({ #> tka <- 7 #> tcl <- 1 #> tv <- 3.45 #> add.sd <- c(0, 0.7) #> eta.ka ~ 0.6 #> eta.v ~ 0.1 #> }) #> model({ #> ka <- exp(tka + eta.ka) #> cl <- exp(tcl) #> v <- exp(tv + eta.v) #> d/dt(depot) <- -ka * depot #> d/dt(center) <- ka * depot - cl/v * center #> cp <- center/v #> cp ~ add(add.sd) #> }) #> }"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-cmt.html","id":"how-rxode2-assigns-compartment-numbers","dir":"Articles","previous_headings":"","what":"How rxode2 assigns compartment numbers","title":"Changing rxode2 compartment numbers","text":"rxode2 automatically assigns compartment numbers parsing. example, Mavoglurant PBPK model following model may used: look printout, can see rxode2 assigned compartment number(s) can also see classic rxode2 model. case use summary() function: case, Venous_Blood assigned compartment 15. Figuring can inconvenient also lead re-numbering compartment simulation estimation datasets. easy probably clearer specify compartment name, tools support compartment numbers. Therefore, way number compartment easily can lead less data modification multiple tools.","code":"library(rxode2) #> rxode2 2.1.1.9000 using 2 threads (see ?getRxThreads) #> no cache: create with `rxCreateCache()` pbpk <- function() { model({ KbBR = exp(lKbBR) KbMU = exp(lKbMU) KbAD = exp(lKbAD) CLint= exp(lCLint + eta.LClint) KbBO = exp(lKbBO) KbRB = exp(lKbRB) ## Regional blood flows # Cardiac output (L/h) from White et al (1968) CO = (187.00*WT^0.81)*60/1000 QHT = 4.0 *CO/100 QBR = 12.0*CO/100 QMU = 17.0*CO/100 QAD = 5.0 *CO/100 QSK = 5.0 *CO/100 QSP = 3.0 *CO/100 QPA = 1.0 *CO/100 QLI = 25.5*CO/100 QST = 1.0 *CO/100 QGU = 14.0*CO/100 # Hepatic artery blood flow QHA = QLI - (QSP + QPA + QST + QGU) QBO = 5.0 *CO/100 QKI = 19.0*CO/100 QRB = CO - (QHT + QBR + QMU + QAD + QSK + QLI + QBO + QKI) QLU = QHT + QBR + QMU + QAD + QSK + QLI + QBO + QKI + QRB ## Organs' volumes = organs' weights / organs' density VLU = (0.76 *WT/100)/1.051 VHT = (0.47 *WT/100)/1.030 VBR = (2.00 *WT/100)/1.036 VMU = (40.00*WT/100)/1.041 VAD = (21.42*WT/100)/0.916 VSK = (3.71 *WT/100)/1.116 VSP = (0.26 *WT/100)/1.054 VPA = (0.14 *WT/100)/1.045 VLI = (2.57 *WT/100)/1.040 VST = (0.21 *WT/100)/1.050 VGU = (1.44 *WT/100)/1.043 VBO = (14.29*WT/100)/1.990 VKI = (0.44 *WT/100)/1.050 VAB = (2.81 *WT/100)/1.040 VVB = (5.62 *WT/100)/1.040 VRB = (3.86 *WT/100)/1.040 ## Fixed parameters BP = 0.61 # Blood:plasma partition coefficient fup = 0.028 # Fraction unbound in plasma fub = fup/BP # Fraction unbound in blood KbLU = exp(0.8334) KbHT = exp(1.1205) KbSK = exp(-.5238) KbSP = exp(0.3224) KbPA = exp(0.3224) KbLI = exp(1.7604) KbST = exp(0.3224) KbGU = exp(1.2026) KbKI = exp(1.3171) ##----------------------------------------- S15 = VVB*BP/1000 C15 = Venous_Blood/S15 ##----------------------------------------- d/dt(Lungs) = QLU*(Venous_Blood/VVB - Lungs/KbLU/VLU) d/dt(Heart) = QHT*(Arterial_Blood/VAB - Heart/KbHT/VHT) d/dt(Brain) = QBR*(Arterial_Blood/VAB - Brain/KbBR/VBR) d/dt(Muscles) = QMU*(Arterial_Blood/VAB - Muscles/KbMU/VMU) d/dt(Adipose) = QAD*(Arterial_Blood/VAB - Adipose/KbAD/VAD) d/dt(Skin) = QSK*(Arterial_Blood/VAB - Skin/KbSK/VSK) d/dt(Spleen) = QSP*(Arterial_Blood/VAB - Spleen/KbSP/VSP) d/dt(Pancreas) = QPA*(Arterial_Blood/VAB - Pancreas/KbPA/VPA) d/dt(Liver) = QHA*Arterial_Blood/VAB + QSP*Spleen/KbSP/VSP + QPA*Pancreas/KbPA/VPA + QST*Stomach/KbST/VST + QGU*Gut/KbGU/VGU - CLint*fub*Liver/KbLI/VLI - QLI*Liver/KbLI/VLI d/dt(Stomach) = QST*(Arterial_Blood/VAB - Stomach/KbST/VST) d/dt(Gut) = QGU*(Arterial_Blood/VAB - Gut/KbGU/VGU) d/dt(Bones) = QBO*(Arterial_Blood/VAB - Bones/KbBO/VBO) d/dt(Kidneys) = QKI*(Arterial_Blood/VAB - Kidneys/KbKI/VKI) d/dt(Arterial_Blood) = QLU*(Lungs/KbLU/VLU - Arterial_Blood/VAB) d/dt(Venous_Blood) = QHT*Heart/KbHT/VHT + QBR*Brain/KbBR/VBR + QMU*Muscles/KbMU/VMU + QAD*Adipose/KbAD/VAD + QSK*Skin/KbSK/VSK + QLI*Liver/KbLI/VLI + QBO*Bones/KbBO/VBO + QKI*Kidneys/KbKI/VKI + QRB*Rest_of_Body/KbRB/VRB - QLU*Venous_Blood/VVB d/dt(Rest_of_Body) = QRB*(Arterial_Blood/VAB - Rest_of_Body/KbRB/VRB) }) } pbpk <- pbpk() print(pbpk) #> -- rxode2-based free-form 16-cmt ODE model ------------------------------------- #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 Lungs #> 2 2 Heart #> 3 3 Brain #> 4 4 Muscles #> 5 5 Adipose #> 6 6 Skin #> 7 7 Spleen #> 8 8 Pancreas #> 9 9 Liver #> 10 10 Stomach #> 11 11 Gut #> 12 12 Bones #> 13 13 Kidneys #> 14 14 Arterial_Blood #> 15 15 Venous_Blood #> 16 16 Rest_of_Body #> -- Model (Normalized Syntax): -- #> function() { #> model({ #> KbBR = exp(lKbBR) #> KbMU = exp(lKbMU) #> KbAD = exp(lKbAD) #> CLint = exp(lCLint + eta.LClint) #> KbBO = exp(lKbBO) #> KbRB = exp(lKbRB) #> CO = (187 * WT^0.81) * 60/1000 #> QHT = 4 * CO/100 #> QBR = 12 * CO/100 #> QMU = 17 * CO/100 #> QAD = 5 * CO/100 #> QSK = 5 * CO/100 #> QSP = 3 * CO/100 #> QPA = 1 * CO/100 #> QLI = 25.5 * CO/100 #> QST = 1 * CO/100 #> QGU = 14 * CO/100 #> QHA = QLI - (QSP + QPA + QST + QGU) #> QBO = 5 * CO/100 #> QKI = 19 * CO/100 #> QRB = CO - (QHT + QBR + QMU + QAD + QSK + QLI + QBO + #> QKI) #> QLU = QHT + QBR + QMU + QAD + QSK + QLI + QBO + QKI + #> QRB #> VLU = (0.76 * WT/100)/1.051 #> VHT = (0.47 * WT/100)/1.03 #> VBR = (2 * WT/100)/1.036 #> VMU = (40 * WT/100)/1.041 #> VAD = (21.42 * WT/100)/0.916 #> VSK = (3.71 * WT/100)/1.116 #> VSP = (0.26 * WT/100)/1.054 #> VPA = (0.14 * WT/100)/1.045 #> VLI = (2.57 * WT/100)/1.04 #> VST = (0.21 * WT/100)/1.05 #> VGU = (1.44 * WT/100)/1.043 #> VBO = (14.29 * WT/100)/1.99 #> VKI = (0.44 * WT/100)/1.05 #> VAB = (2.81 * WT/100)/1.04 #> VVB = (5.62 * WT/100)/1.04 #> VRB = (3.86 * WT/100)/1.04 #> BP = 0.61 #> fup = 0.028 #> fub = fup/BP #> KbLU = exp(0.8334) #> KbHT = exp(1.1205) #> KbSK = exp(-0.5238) #> KbSP = exp(0.3224) #> KbPA = exp(0.3224) #> KbLI = exp(1.7604) #> KbST = exp(0.3224) #> KbGU = exp(1.2026) #> KbKI = exp(1.3171) #> S15 = VVB * BP/1000 #> C15 = Venous_Blood/S15 #> d/dt(Lungs) = QLU * (Venous_Blood/VVB - Lungs/KbLU/VLU) #> d/dt(Heart) = QHT * (Arterial_Blood/VAB - Heart/KbHT/VHT) #> d/dt(Brain) = QBR * (Arterial_Blood/VAB - Brain/KbBR/VBR) #> d/dt(Muscles) = QMU * (Arterial_Blood/VAB - Muscles/KbMU/VMU) #> d/dt(Adipose) = QAD * (Arterial_Blood/VAB - Adipose/KbAD/VAD) #> d/dt(Skin) = QSK * (Arterial_Blood/VAB - Skin/KbSK/VSK) #> d/dt(Spleen) = QSP * (Arterial_Blood/VAB - Spleen/KbSP/VSP) #> d/dt(Pancreas) = QPA * (Arterial_Blood/VAB - Pancreas/KbPA/VPA) #> d/dt(Liver) = QHA * Arterial_Blood/VAB + QSP * Spleen/KbSP/VSP + #> QPA * Pancreas/KbPA/VPA + QST * Stomach/KbST/VST + #> QGU * Gut/KbGU/VGU - CLint * fub * Liver/KbLI/VLI - #> QLI * Liver/KbLI/VLI #> d/dt(Stomach) = QST * (Arterial_Blood/VAB - Stomach/KbST/VST) #> d/dt(Gut) = QGU * (Arterial_Blood/VAB - Gut/KbGU/VGU) #> d/dt(Bones) = QBO * (Arterial_Blood/VAB - Bones/KbBO/VBO) #> d/dt(Kidneys) = QKI * (Arterial_Blood/VAB - Kidneys/KbKI/VKI) #> d/dt(Arterial_Blood) = QLU * (Lungs/KbLU/VLU - Arterial_Blood/VAB) #> d/dt(Venous_Blood) = QHT * Heart/KbHT/VHT + QBR * Brain/KbBR/VBR + #> QMU * Muscles/KbMU/VMU + QAD * Adipose/KbAD/VAD + #> QSK * Skin/KbSK/VSK + QLI * Liver/KbLI/VLI + QBO * #> Bones/KbBO/VBO + QKI * Kidneys/KbKI/VKI + QRB * Rest_of_Body/KbRB/VRB - #> QLU * Venous_Blood/VVB #> d/dt(Rest_of_Body) = QRB * (Arterial_Blood/VAB - Rest_of_Body/KbRB/VRB) #> }) #> } pbpk <- pbpk$simulationModel #> using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’ summary(pbpk) #> rxode2 2.1.1.9000 model named rx_45cececb1f44bc6825377e86555bf32a model (ready). #> DLL: /tmp/RtmpQvsiAp/rxode2/rx_45cececb1f44bc6825377e86555bf32a__.rxd/rx_45cececb1f44bc6825377e86555bf32a_.so #> NULL #> #> Calculated Variables: #> [1] \"KbBR\" \"KbMU\" \"KbAD\" \"CLint\" \"KbBO\" \"KbRB\" \"CO\" \"QHT\" \"QBR\" #> [10] \"QMU\" \"QAD\" \"QSK\" \"QSP\" \"QPA\" \"QLI\" \"QST\" \"QGU\" \"QHA\" #> [19] \"QBO\" \"QKI\" \"QRB\" \"QLU\" \"VLU\" \"VHT\" \"VBR\" \"VMU\" \"VAD\" #> [28] \"VSK\" \"VSP\" \"VPA\" \"VLI\" \"VST\" \"VGU\" \"VBO\" \"VKI\" \"VAB\" #> [37] \"VVB\" \"VRB\" \"fub\" \"KbLU\" \"KbHT\" \"KbSK\" \"KbSP\" \"KbPA\" \"KbLI\" #> [46] \"KbST\" \"KbGU\" \"KbKI\" \"S15\" \"C15\" #> -- rxode2 Model Syntax -- #> rxode2({ #> param(lKbBR, lKbMU, lKbAD, lCLint, eta.LClint, lKbBO, lKbRB, #> WT) #> KbBR = exp(lKbBR) #> KbMU = exp(lKbMU) #> KbAD = exp(lKbAD) #> CLint = exp(lCLint + eta.LClint) #> KbBO = exp(lKbBO) #> KbRB = exp(lKbRB) #> CO = (187 * WT^0.81) * 60/1000 #> QHT = 4 * CO/100 #> QBR = 12 * CO/100 #> QMU = 17 * CO/100 #> QAD = 5 * CO/100 #> QSK = 5 * CO/100 #> QSP = 3 * CO/100 #> QPA = 1 * CO/100 #> QLI = 25.5 * CO/100 #> QST = 1 * CO/100 #> QGU = 14 * CO/100 #> QHA = QLI - (QSP + QPA + QST + QGU) #> QBO = 5 * CO/100 #> QKI = 19 * CO/100 #> QRB = CO - (QHT + QBR + QMU + QAD + QSK + QLI + QBO + QKI) #> QLU = QHT + QBR + QMU + QAD + QSK + QLI + QBO + QKI + QRB #> VLU = (0.76 * WT/100)/1.051 #> VHT = (0.47 * WT/100)/1.03 #> VBR = (2 * WT/100)/1.036 #> VMU = (40 * WT/100)/1.041 #> VAD = (21.42 * WT/100)/0.916 #> VSK = (3.71 * WT/100)/1.116 #> VSP = (0.26 * WT/100)/1.054 #> VPA = (0.14 * WT/100)/1.045 #> VLI = (2.57 * WT/100)/1.04 #> VST = (0.21 * WT/100)/1.05 #> VGU = (1.44 * WT/100)/1.043 #> VBO = (14.29 * WT/100)/1.99 #> VKI = (0.44 * WT/100)/1.05 #> VAB = (2.81 * WT/100)/1.04 #> VVB = (5.62 * WT/100)/1.04 #> VRB = (3.86 * WT/100)/1.04 #> BP = 0.61 #> fup = 0.028 #> fub = fup/BP #> KbLU = exp(0.8334) #> KbHT = exp(1.1205) #> KbSK = exp(-0.5238) #> KbSP = exp(0.3224) #> KbPA = exp(0.3224) #> KbLI = exp(1.7604) #> KbST = exp(0.3224) #> KbGU = exp(1.2026) #> KbKI = exp(1.3171) #> S15 = VVB * BP/1000 #> C15 = Venous_Blood/S15 #> d/dt(Lungs) = QLU * (Venous_Blood/VVB - Lungs/KbLU/VLU) #> d/dt(Heart) = QHT * (Arterial_Blood/VAB - Heart/KbHT/VHT) #> d/dt(Brain) = QBR * (Arterial_Blood/VAB - Brain/KbBR/VBR) #> d/dt(Muscles) = QMU * (Arterial_Blood/VAB - Muscles/KbMU/VMU) #> d/dt(Adipose) = QAD * (Arterial_Blood/VAB - Adipose/KbAD/VAD) #> d/dt(Skin) = QSK * (Arterial_Blood/VAB - Skin/KbSK/VSK) #> d/dt(Spleen) = QSP * (Arterial_Blood/VAB - Spleen/KbSP/VSP) #> d/dt(Pancreas) = QPA * (Arterial_Blood/VAB - Pancreas/KbPA/VPA) #> d/dt(Liver) = QHA * Arterial_Blood/VAB + QSP * Spleen/KbSP/VSP + #> QPA * Pancreas/KbPA/VPA + QST * Stomach/KbST/VST + QGU * #> Gut/KbGU/VGU - CLint * fub * Liver/KbLI/VLI - QLI * Liver/KbLI/VLI #> d/dt(Stomach) = QST * (Arterial_Blood/VAB - Stomach/KbST/VST) #> d/dt(Gut) = QGU * (Arterial_Blood/VAB - Gut/KbGU/VGU) #> d/dt(Bones) = QBO * (Arterial_Blood/VAB - Bones/KbBO/VBO) #> d/dt(Kidneys) = QKI * (Arterial_Blood/VAB - Kidneys/KbKI/VKI) #> d/dt(Arterial_Blood) = QLU * (Lungs/KbLU/VLU - Arterial_Blood/VAB) #> d/dt(Venous_Blood) = QHT * Heart/KbHT/VHT + QBR * Brain/KbBR/VBR + #> QMU * Muscles/KbMU/VMU + QAD * Adipose/KbAD/VAD + QSK * #> Skin/KbSK/VSK + QLI * Liver/KbLI/VLI + QBO * Bones/KbBO/VBO + #> QKI * Kidneys/KbKI/VKI + QRB * Rest_of_Body/KbRB/VRB - #> QLU * Venous_Blood/VVB #> d/dt(Rest_of_Body) = QRB * (Arterial_Blood/VAB - Rest_of_Body/KbRB/VRB) #> })"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-cmt.html","id":"changing-compartment-numbers-by-pre-declaring-the-compartments","dir":"Articles","previous_headings":"","what":"Changing compartment numbers by pre-declaring the compartments","title":"Changing rxode2 compartment numbers","text":"add compartments rxode2 model order desire simply need pre-declare compartments cmt. example specifying Venous_Blood Skin 1st 2nd compartments, respectively, simple: can see change simple printout first two compartments Venous_Blood followed Skin.","code":"pbpk2 <- function() { model({ ## Now this is the first compartment, ie cmt=1 cmt(Venous_Blood) ## Skin may be a compartment you wish to dose to as well, ## so it is now cmt=2 cmt(Skin) KbBR = exp(lKbBR) KbMU = exp(lKbMU) KbAD = exp(lKbAD) CLint= exp(lCLint + eta.LClint) KbBO = exp(lKbBO) KbRB = exp(lKbRB) ## Regional blood flows # Cardiac output (L/h) from White et al (1968)m CO = (187.00*WT^0.81)*60/1000; QHT = 4.0 *CO/100; QBR = 12.0*CO/100; QMU = 17.0*CO/100; QAD = 5.0 *CO/100; QSK = 5.0 *CO/100; QSP = 3.0 *CO/100; QPA = 1.0 *CO/100; QLI = 25.5*CO/100; QST = 1.0 *CO/100; QGU = 14.0*CO/100; QHA = QLI - (QSP + QPA + QST + QGU); # Hepatic artery blood flow QBO = 5.0 *CO/100; QKI = 19.0*CO/100; QRB = CO - (QHT + QBR + QMU + QAD + QSK + QLI + QBO + QKI); QLU = QHT + QBR + QMU + QAD + QSK + QLI + QBO + QKI + QRB; ## Organs' volumes = organs' weights / organs' density VLU = (0.76 *WT/100)/1.051; VHT = (0.47 *WT/100)/1.030; VBR = (2.00 *WT/100)/1.036; VMU = (40.00*WT/100)/1.041; VAD = (21.42*WT/100)/0.916; VSK = (3.71 *WT/100)/1.116; VSP = (0.26 *WT/100)/1.054; VPA = (0.14 *WT/100)/1.045; VLI = (2.57 *WT/100)/1.040; VST = (0.21 *WT/100)/1.050; VGU = (1.44 *WT/100)/1.043; VBO = (14.29*WT/100)/1.990; VKI = (0.44 *WT/100)/1.050; VAB = (2.81 *WT/100)/1.040; VVB = (5.62 *WT/100)/1.040; VRB = (3.86 *WT/100)/1.040; ## Fixed parameters BP = 0.61; # Blood:plasma partition coefficient fup = 0.028; # Fraction unbound in plasma fub = fup/BP; # Fraction unbound in blood KbLU = exp(0.8334); KbHT = exp(1.1205); KbSK = exp(-.5238); KbSP = exp(0.3224); KbPA = exp(0.3224); KbLI = exp(1.7604); KbST = exp(0.3224); KbGU = exp(1.2026); KbKI = exp(1.3171); ##----------------------------------------- S15 = VVB*BP/1000; C15 = Venous_Blood/S15 ##----------------------------------------- d/dt(Lungs) = QLU*(Venous_Blood/VVB - Lungs/KbLU/VLU); d/dt(Heart) = QHT*(Arterial_Blood/VAB - Heart/KbHT/VHT); d/dt(Brain) = QBR*(Arterial_Blood/VAB - Brain/KbBR/VBR); d/dt(Muscles) = QMU*(Arterial_Blood/VAB - Muscles/KbMU/VMU); d/dt(Adipose) = QAD*(Arterial_Blood/VAB - Adipose/KbAD/VAD); d/dt(Skin) = QSK*(Arterial_Blood/VAB - Skin/KbSK/VSK); d/dt(Spleen) = QSP*(Arterial_Blood/VAB - Spleen/KbSP/VSP); d/dt(Pancreas) = QPA*(Arterial_Blood/VAB - Pancreas/KbPA/VPA); d/dt(Liver) = QHA*Arterial_Blood/VAB + QSP*Spleen/KbSP/VSP + QPA*Pancreas/KbPA/VPA + QST*Stomach/KbST/VST + QGU*Gut/KbGU/VGU - CLint*fub*Liver/KbLI/VLI - QLI*Liver/KbLI/VLI; d/dt(Stomach) = QST*(Arterial_Blood/VAB - Stomach/KbST/VST); d/dt(Gut) = QGU*(Arterial_Blood/VAB - Gut/KbGU/VGU); d/dt(Bones) = QBO*(Arterial_Blood/VAB - Bones/KbBO/VBO); d/dt(Kidneys) = QKI*(Arterial_Blood/VAB - Kidneys/KbKI/VKI); d/dt(Arterial_Blood) = QLU*(Lungs/KbLU/VLU - Arterial_Blood/VAB); d/dt(Venous_Blood) = QHT*Heart/KbHT/VHT + QBR*Brain/KbBR/VBR + QMU*Muscles/KbMU/VMU + QAD*Adipose/KbAD/VAD + QSK*Skin/KbSK/VSK + QLI*Liver/KbLI/VLI + QBO*Bones/KbBO/VBO + QKI*Kidneys/KbKI/VKI + QRB*Rest_of_Body/KbRB/VRB - QLU*Venous_Blood/VVB; d/dt(Rest_of_Body) = QRB*(Arterial_Blood/VAB - Rest_of_Body/KbRB/VRB); }) } pbpk2 <- pbpk2() pbpk2 #> -- rxode2-based free-form 16-cmt ODE model ------------------------------------- #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 Venous_Blood #> 2 2 Skin #> 3 3 Lungs #> 4 4 Heart #> 5 5 Brain #> 6 6 Muscles #> 7 7 Adipose #> 8 8 Spleen #> 9 9 Pancreas #> 10 10 Liver #> 11 11 Stomach #> 12 12 Gut #> 13 13 Bones #> 14 14 Kidneys #> 15 15 Arterial_Blood #> 16 16 Rest_of_Body #> -- Model (Normalized Syntax): -- #> function() { #> model({ #> cmt(Venous_Blood) #> cmt(Skin) #> KbBR = exp(lKbBR) #> KbMU = exp(lKbMU) #> KbAD = exp(lKbAD) #> CLint = exp(lCLint + eta.LClint) #> KbBO = exp(lKbBO) #> KbRB = exp(lKbRB) #> CO = (187 * WT^0.81) * 60/1000 #> QHT = 4 * CO/100 #> QBR = 12 * CO/100 #> QMU = 17 * CO/100 #> QAD = 5 * CO/100 #> QSK = 5 * CO/100 #> QSP = 3 * CO/100 #> QPA = 1 * CO/100 #> QLI = 25.5 * CO/100 #> QST = 1 * CO/100 #> QGU = 14 * CO/100 #> QHA = QLI - (QSP + QPA + QST + QGU) #> QBO = 5 * CO/100 #> QKI = 19 * CO/100 #> QRB = CO - (QHT + QBR + QMU + QAD + QSK + QLI + QBO + #> QKI) #> QLU = QHT + QBR + QMU + QAD + QSK + QLI + QBO + QKI + #> QRB #> VLU = (0.76 * WT/100)/1.051 #> VHT = (0.47 * WT/100)/1.03 #> VBR = (2 * WT/100)/1.036 #> VMU = (40 * WT/100)/1.041 #> VAD = (21.42 * WT/100)/0.916 #> VSK = (3.71 * WT/100)/1.116 #> VSP = (0.26 * WT/100)/1.054 #> VPA = (0.14 * WT/100)/1.045 #> VLI = (2.57 * WT/100)/1.04 #> VST = (0.21 * WT/100)/1.05 #> VGU = (1.44 * WT/100)/1.043 #> VBO = (14.29 * WT/100)/1.99 #> VKI = (0.44 * WT/100)/1.05 #> VAB = (2.81 * WT/100)/1.04 #> VVB = (5.62 * WT/100)/1.04 #> VRB = (3.86 * WT/100)/1.04 #> BP = 0.61 #> fup = 0.028 #> fub = fup/BP #> KbLU = exp(0.8334) #> KbHT = exp(1.1205) #> KbSK = exp(-0.5238) #> KbSP = exp(0.3224) #> KbPA = exp(0.3224) #> KbLI = exp(1.7604) #> KbST = exp(0.3224) #> KbGU = exp(1.2026) #> KbKI = exp(1.3171) #> S15 = VVB * BP/1000 #> C15 = Venous_Blood/S15 #> d/dt(Lungs) = QLU * (Venous_Blood/VVB - Lungs/KbLU/VLU) #> d/dt(Heart) = QHT * (Arterial_Blood/VAB - Heart/KbHT/VHT) #> d/dt(Brain) = QBR * (Arterial_Blood/VAB - Brain/KbBR/VBR) #> d/dt(Muscles) = QMU * (Arterial_Blood/VAB - Muscles/KbMU/VMU) #> d/dt(Adipose) = QAD * (Arterial_Blood/VAB - Adipose/KbAD/VAD) #> d/dt(Skin) = QSK * (Arterial_Blood/VAB - Skin/KbSK/VSK) #> d/dt(Spleen) = QSP * (Arterial_Blood/VAB - Spleen/KbSP/VSP) #> d/dt(Pancreas) = QPA * (Arterial_Blood/VAB - Pancreas/KbPA/VPA) #> d/dt(Liver) = QHA * Arterial_Blood/VAB + QSP * Spleen/KbSP/VSP + #> QPA * Pancreas/KbPA/VPA + QST * Stomach/KbST/VST + #> QGU * Gut/KbGU/VGU - CLint * fub * Liver/KbLI/VLI - #> QLI * Liver/KbLI/VLI #> d/dt(Stomach) = QST * (Arterial_Blood/VAB - Stomach/KbST/VST) #> d/dt(Gut) = QGU * (Arterial_Blood/VAB - Gut/KbGU/VGU) #> d/dt(Bones) = QBO * (Arterial_Blood/VAB - Bones/KbBO/VBO) #> d/dt(Kidneys) = QKI * (Arterial_Blood/VAB - Kidneys/KbKI/VKI) #> d/dt(Arterial_Blood) = QLU * (Lungs/KbLU/VLU - Arterial_Blood/VAB) #> d/dt(Venous_Blood) = QHT * Heart/KbHT/VHT + QBR * Brain/KbBR/VBR + #> QMU * Muscles/KbMU/VMU + QAD * Adipose/KbAD/VAD + #> QSK * Skin/KbSK/VSK + QLI * Liver/KbLI/VLI + QBO * #> Bones/KbBO/VBO + QKI * Kidneys/KbKI/VKI + QRB * Rest_of_Body/KbRB/VRB - #> QLU * Venous_Blood/VVB #> d/dt(Rest_of_Body) = QRB * (Arterial_Blood/VAB - Rest_of_Body/KbRB/VRB) #> }) #> }"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-cmt.html","id":"appending-compartments-to-the-model","dir":"Articles","previous_headings":"","what":"Appending compartments to the model","title":"Changing rxode2 compartment numbers","text":"can also append “compartments” model. ODE solving internals, add fake compartments model differential equations defined. example legal: can see clearly underlying classic rxode2 model: compartments defined differential equations supported; model : give error:","code":"ode.1c.ka <- function(){ model({ C2 = center/V d / dt(depot) = -KA * depot d/dt(center) = KA * depot - CL*C2 cmt(eff) }) } ode.1c.ka <- ode.1c.ka() print(ode.1c.ka) #> -- rxode2-based free-form 2-cmt ODE model -------------------------------------- #> #> States ($state or $stateDf): #> Compartment Number Compartment Name #> 1 1 depot #> 2 2 center #> -- Model (Normalized Syntax): -- #> function() { #> model({ #> C2 = center/V #> d/dt(depot) = -KA * depot #> d/dt(center) = KA * depot - CL * C2 #> cmt(eff) #> }) #> } ode.1c.ka$simulationModel #> using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’ #> rxode2 2.1.1.9000 model named rx_3c2c707bde58bb58ac7dd2fb5996f24e model (ready). #> x$state: depot, center #> x$stateExtra: eff #> x$params: V, KA, CL #> x$lhs: C2 ode.1c.ka <- rxode2({ cmt(eff) C2 = center/V; d / dt(depot) = -KA * depot d/dt(center) = KA * depot - CL*C2 }) Error in rxModelVars_(obj) : Evaluation error: Compartment 'eff' needs differential equations defined."},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-covariates.html","id":"individual-covariates","dir":"Articles","previous_headings":"","what":"Individual Covariates","title":"rxode2 Covariates","text":"individual covariate wish solve may specify iCov dataset:","code":"library(rxode2) ## rxode2 2.1.1.9000 using 2 threads (see ?getRxThreads) ## no cache: create with `rxCreateCache()` library(units) ## udunits database from /usr/share/xml/udunits/udunits2.xml library(xgxr) mod3 <- function() { ini({ TKA <- 2.94E-01 ## Clearance with individuals TCL <- 1.86E+01 TV2 <-4.02E+01 TQ <-1.05E+01 TV3 <-2.97E+02 TKin <- 1 TKout <- 1 TEC50 <-200 }) model({ KA <- TKA CL <- TCL * (WT / 70) ^ 0.75 V2 <- TV2 Q <- TQ V3 <- TV3 Kin <- TKin Kout <- TKout EC50 <- TEC50 Tz <- 8 amp <- 0.1 C2 <- central/V2 C3 <- peri/V3 d/dt(depot) <- -KA*depot d/dt(central) <- KA*depot - CL*C2 - Q*C2 + Q*C3 d/dt(peri) <- Q*C2 - Q*C3 d/dt(eff) <- Kin - Kout*(1-C2/(EC50+C2))*eff eff(0) <- 1 ## This specifies that the effect compartment starts at 1. }) } ev <- et(amount.units=\"mg\", time.units=\"hours\") %>% et(amt=10000, cmt=1) %>% et(0,48,length.out=100) %>% et(id=1:4) set.seed(10) rxSetSeed(10) ## Now use iCov to simulate a 4-id sample r1 <- solve(mod3, ev, # Create individual covariate data-frame iCov=data.frame(id=1:4, WT=rnorm(4, 70, 10))) ## using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’ print(r1) ## ── Solved rxode2 object ── ## ── Parameters ($params): ── ## TKA TCL TV2 TQ TV3 TKin TKout TEC50 Tz amp ## 0.294 18.600 40.200 10.500 297.000 1.000 1.000 200.000 8.000 0.100 ## ── Initial Conditions ($inits): ── ## depot central peri eff ## 0 0 0 1 ## ── First part of data (object): ── ## # A tibble: 400 × 17 ## id time KA CL V2 Q V3 Kin Kout EC50 C2 C3 depot ## [h] ## 1 1 0 0.294 18.6 40.2 10.5 297 1 1 200 0 0 10000 ## 2 1 0.485 0.294 18.6 40.2 10.5 297 1 1 200 27.8 0.257 8671. ## 3 1 0.970 0.294 18.6 40.2 10.5 297 1 1 200 43.7 0.873 7519. ## 4 1 1.45 0.294 18.6 40.2 10.5 297 1 1 200 51.7 1.68 6520. ## 5 1 1.94 0.294 18.6 40.2 10.5 297 1 1 200 54.7 2.56 5654. ## 6 1 2.42 0.294 18.6 40.2 10.5 297 1 1 200 54.5 3.45 4903. ## # ℹ 394 more rows ## # ℹ 4 more variables: central , peri , eff , WT plot(r1, C2, log=\"y\") ## Warning: Transformation introduced infinite values in continuous y-axis"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-covariates.html","id":"time-varying-covariates","dir":"Articles","previous_headings":"","what":"Time Varying Covariates","title":"rxode2 Covariates","text":"Covariates easy specify rxode2, can specify variable. Time-varying covariates, like clock time circadian rhythm model, can also used. Extending indirect response model already discussed, : Now covariate present event dataset, system can solved combining dataset model: solving ODE equations, solver may sample times outside data. happens, ODE solver can use linear interpolation covariate values. equivalent R’s approxfun method=\"linear\". Note linear approximation case leads kinks solved system 24-hours covariate linear interpolation near 24 near 0. linear seems reasonable, cases like clock time make interpolation methods attractive. rxode2 default covariate interpolation last observation carried forward (locf), constant approximation. equivalent R’s approxfun method=\"constant\". gives following plots: case, plots seem smoother. can also use NONMEM’s preferred interpolation style next observation carried backward (NOCB): gives following plots:","code":"library(rxode2) library(units) mod4 <- mod3 %>% model(d/dt(eff) <- Kin - Kout*(1-C2/(EC50+C2))*eff) %>% model(-Kin) %>% model(Kin <- TKin + amp *cos(2*pi*(ctime-Tz)/24), append=C2, cov=\"ctime\") ev <- et(amountUnits=\"mg\", timeUnits=\"hours\") %>% et(amt=10000, cmt=1) %>% et(0,48,length.out=100) ## Create data frame of 8 am dosing for the first dose This is done ## with base R but it can be done with dplyr or data.table ev$ctime <- (ev$time+set_units(8,hr)) %% 24 ev$WT <- 70 r1 <- solve(mod4, ev, covsInterpolation=\"linear\") print(r1) #> ── Solved rxode2 object ── #> ── Parameters ($params): ── #> TKA TCL TV2 TQ TV3 TKout TEC50 #> 0.294000 18.600000 40.200000 10.500000 297.000000 1.000000 200.000000 #> TKin Tz amp pi #> 1.000000 8.000000 0.100000 3.141593 #> ── Initial Conditions ($inits): ── #> depot central peri eff #> 0 0 0 1 #> ── First part of data (object): ── #> # A tibble: 100 × 17 #> time KA CL V2 Q V3 Kout EC50 C2 Kin C3 depot #> [h] #> 1 0 0.294 18.6 40.2 10.5 297 1 200 0 1.1 0 10000 #> 2 0.485 0.294 18.6 40.2 10.5 297 1 200 27.8 1.10 0.257 8671. #> 3 0.970 0.294 18.6 40.2 10.5 297 1 200 43.7 1.10 0.874 7519. #> 4 1.45 0.294 18.6 40.2 10.5 297 1 200 51.8 1.09 1.68 6520. #> 5 1.94 0.294 18.6 40.2 10.5 297 1 200 54.8 1.09 2.56 5654. #> 6 2.42 0.294 18.6 40.2 10.5 297 1 200 54.6 1.08 3.45 4903. #> # ℹ 94 more rows #> # ℹ 5 more variables: central , peri , eff , ctime [h], WT plot(r1,C2, ylab=\"Central Concentration\") plot(r1,eff) + ylab(\"Effect\") + xlab(\"Time\") r1 <- solve(mod4, ev,covsInterpolation=\"locf\") print(r1) #> ── Solved rxode2 object ── #> ── Parameters ($params): ── #> TKA TCL TV2 TQ TV3 TKout TEC50 #> 0.294000 18.600000 40.200000 10.500000 297.000000 1.000000 200.000000 #> TKin Tz amp pi #> 1.000000 8.000000 0.100000 3.141593 #> ── Initial Conditions ($inits): ── #> depot central peri eff #> 0 0 0 1 #> ── First part of data (object): ── #> # A tibble: 100 × 17 #> time KA CL V2 Q V3 Kout EC50 C2 Kin C3 depot #> [h] #> 1 0 0.294 18.6 40.2 10.5 297 1 200 0 1.1 0 10000 #> 2 0.485 0.294 18.6 40.2 10.5 297 1 200 27.8 1.10 0.257 8671. #> 3 0.970 0.294 18.6 40.2 10.5 297 1 200 43.7 1.10 0.874 7519. #> 4 1.45 0.294 18.6 40.2 10.5 297 1 200 51.8 1.09 1.68 6520. #> 5 1.94 0.294 18.6 40.2 10.5 297 1 200 54.8 1.09 2.56 5654. #> 6 2.42 0.294 18.6 40.2 10.5 297 1 200 54.6 1.08 3.45 4903. #> # ℹ 94 more rows #> # ℹ 5 more variables: central , peri , eff , ctime [h], WT plot(r1,C2, ylab=\"Central Concentration\", xlab=\"Time\") plot(r1,eff, ylab=\"Effect\", xlab=\"Time\") r1 <- solve(mod4, ev,covsInterpolation=\"nocb\") print(r1) #> ── Solved rxode2 object ── #> ── Parameters ($params): ── #> TKA TCL TV2 TQ TV3 TKout TEC50 #> 0.294000 18.600000 40.200000 10.500000 297.000000 1.000000 200.000000 #> TKin Tz amp pi #> 1.000000 8.000000 0.100000 3.141593 #> ── Initial Conditions ($inits): ── #> depot central peri eff #> 0 0 0 1 #> ── First part of data (object): ── #> # A tibble: 100 × 17 #> time KA CL V2 Q V3 Kout EC50 C2 Kin C3 depot #> [h] #> 1 0 0.294 18.6 40.2 10.5 297 1 200 0 1.1 0 10000 #> 2 0.485 0.294 18.6 40.2 10.5 297 1 200 27.8 1.10 0.257 8671. #> 3 0.970 0.294 18.6 40.2 10.5 297 1 200 43.7 1.10 0.874 7519. #> 4 1.45 0.294 18.6 40.2 10.5 297 1 200 51.8 1.09 1.68 6520. #> 5 1.94 0.294 18.6 40.2 10.5 297 1 200 54.8 1.09 2.56 5654. #> 6 2.42 0.294 18.6 40.2 10.5 297 1 200 54.6 1.08 3.45 4903. #> # ℹ 94 more rows #> # ℹ 5 more variables: central , peri , eff , ctime [h], WT plot(r1,C2, ylab=\"Central Concentration\", xlab=\"Time\") plot(r1,eff, ylab=\"Effect\", xlab=\"Time\")"},{"path":[]},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-data-frame.html","id":"creating-an-interactive-data-frame","dir":"Articles","previous_headings":"Using rxode2 data frames","what":"Creating an interactive data frame","title":"rxode2 Data Frames","text":"rxode2 supports returning solved object modified data-frame. done predict(), solve(), rxSolve() methods.","code":"library(rxode2) library(units) ## Setup example model mod1 <- function() { ini({ # central KA <- 2.94E-01 CL <- 1.86E+01 # peripheral V2 <- 4.02E+01 Q <- 1.05E+01 V3 <- 2.97E+02 # effects Kin <- 1 Kout <- 1 EC50 <- 200 }) model({ C2 <- centr/V2 C3 <- peri/V3 d/dt(depot) <- -KA*depot d/dt(centr) <- KA*depot - CL*C2 - Q*C2 + Q*C3 d/dt(peri) <- Q*C2 - Q*C3 d/dt(eff) <- Kin - Kout*(1-C2/(EC50+C2))*eff eff(0) <- 1 }) } ## Seup parameters and initial conditions ## Setup dosing event information ev <- et(amountUnits=\"mg\", timeUnits = \"hours\") %>% et(amt=10000, addl=9, ii=12) %>% et(amt=20000, addl=4, time=120, ii=24) %>% et(0:240) ## Now solve x <- predict(mod1, ev) x #> -- Solved rxode2 object -- #> -- Parameters (x$params): -- #> KA CL V2 Q V3 Kin Kout EC50 #> 0.294 18.600 40.200 10.500 297.000 1.000 1.000 200.000 #> -- Initial Conditions (x$inits): -- #> depot centr peri eff #> 0 0 0 1 #> -- First part of data (object): -- #> # A tibble: 241 x 7 #> time C2 C3 depot centr peri eff #> [h] #> 1 0 0 0 10000 0 0 1 #> 2 1 44.4 0.920 7453. 1784. 273. 1.08 #> 3 2 54.9 2.67 5554. 2206. 794. 1.18 #> 4 3 51.9 4.46 4140. 2087. 1324. 1.23 #> 5 4 44.5 5.98 3085. 1789. 1776. 1.23 #> 6 5 36.5 7.18 2299. 1467. 2132. 1.21 #> # i 235 more rows"},{"path":[]},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-data-frame.html","id":"using-the-solved-object-as-a-simple-data-frame","dir":"Articles","previous_headings":"Using rxode2 data frames","what":"Using the solved object as a simple data frame","title":"rxode2 Data Frames","text":"solved object acts data.frame tbl can filtered dpylr. example filter easily.","code":"library(dplyr) ## You can drop units for comparisons and filtering x <- mod1 %>% solve(ev) %>% drop_units() %>% filter(time <= 3) %>% as_tibble() ## or keep them and compare with the proper units. x <- mod1 %>% solve(ev) %>% filter(time <= set_units(3, hr)) %>% as_tibble() x #> # A tibble: 4 x 7 #> time C2 C3 depot centr peri eff #> [h] #> 1 0 0 0 10000 0 0 1 #> 2 1 44.4 0.920 7453. 1784. 273. 1.08 #> 3 2 54.9 2.67 5554. 2206. 794. 1.18 #> 4 3 51.9 4.46 4140. 2087. 1324. 1.23"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-data-frame.html","id":"updating-the-data-set-interactively","dir":"Articles","previous_headings":"","what":"Updating the data-set interactively","title":"rxode2 Data Frames","text":"However isn’t just simple data object. can use solved object update parameters fly, even change sampling time. First need recreate original solved system:","code":"x <- mod1 %>% solve(ev) print(x) #> -- Solved rxode2 object -- #> -- Parameters ($params): -- #> KA CL V2 Q V3 Kin Kout EC50 #> 0.294 18.600 40.200 10.500 297.000 1.000 1.000 200.000 #> -- Initial Conditions ($inits): -- #> depot centr peri eff #> 0 0 0 1 #> -- First part of data (object): -- #> # A tibble: 241 x 7 #> time C2 C3 depot centr peri eff #> [h] #> 1 0 0 0 10000 0 0 1 #> 2 1 44.4 0.920 7453. 1784. 273. 1.08 #> 3 2 54.9 2.67 5554. 2206. 794. 1.18 #> 4 3 51.9 4.46 4140. 2087. 1324. 1.23 #> 5 4 44.5 5.98 3085. 1789. 1776. 1.23 #> 6 5 36.5 7.18 2299. 1467. 2132. 1.21 #> # i 235 more rows"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-data-frame.html","id":"modifying-observation-times-for-rxode2","dir":"Articles","previous_headings":"Updating the data-set interactively","what":"Modifying observation times for rxode2","title":"rxode2 Data Frames","text":"Notice initial effect now 2. can also change sampling times easily method changing t time. example:","code":"x$t <- seq(0,5,length.out=20) print(x) #> -- Solved rxode2 object -- #> -- Parameters ($params): -- #> KA CL V2 Q V3 Kin Kout EC50 #> 0.294 18.600 40.200 10.500 297.000 1.000 1.000 200.000 #> -- Initial Conditions ($inits): -- #> depot centr peri eff #> 0 0 0 1 #> -- First part of data (object): -- #> # A tibble: 20 x 7 #> time C2 C3 depot centr peri eff #> [h] #> 1 0 0 0 10000 0 0 1 #> 2 0.263 16.8 0.0817 9255. 677. 24.3 1.01 #> 3 0.526 29.5 0.299 8566. 1187. 88.7 1.03 #> 4 0.789 38.9 0.615 7929. 1562. 183. 1.06 #> 5 1.05 45.5 1.00 7338. 1830. 298. 1.09 #> 6 1.32 50.1 1.44 6792. 2013. 427. 1.12 #> # i 14 more rows plot(x)"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-data-frame.html","id":"modifying-simulation-parameters","dir":"Articles","previous_headings":"Updating the data-set interactively","what":"Modifying simulation parameters","title":"rxode2 Data Frames","text":"can also access change parameters $ operator. example, accessing KA can done : may change assigning new value. can access/change parameters, initialization(s) events $params, $inits, $events accessor syntax, similar used . syntax makes easy update explore effect various parameters solved object.","code":"x$KA #> [1] 0.294 x$KA <- 1 print(x) #> -- Solved rxode2 object -- #> -- Parameters ($params): -- #> KA CL V2 Q V3 Kin Kout EC50 #> 1.0 18.6 40.2 10.5 297.0 1.0 1.0 200.0 #> -- Initial Conditions ($inits): -- #> depot centr peri eff #> 0 0 0 1 #> -- First part of data (object): -- #> # A tibble: 20 x 7 #> time C2 C3 depot centr peri eff #> [h] #> 1 0 0 0 10000 0 0 1 #> 2 0.263 52.2 0.261 7686. 2098. 77.6 1.03 #> 3 0.526 83.3 0.900 5908. 3348. 267. 1.09 #> 4 0.789 99.8 1.75 4541. 4010. 519. 1.15 #> 5 1.05 106. 2.69 3490. 4273. 800. 1.21 #> 6 1.32 106. 3.66 2683. 4272. 1086. 1.26 #> # i 14 more rows plot(x)"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-datasets.html","id":"datasets-for-rxode2-nlmixr","dir":"Articles","previous_headings":"","what":"Datasets for rxode2 & nlmixr","title":"rxode2 Event Types","text":"Data input nlmixr type data input rxode2, similar data NONMEM (NONMEM-ready datasets can used directly nlmixr).","code":""},{"path":[]},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-datasets.html","id":"subject-identification-columns","dir":"Articles","previous_headings":"Columns Described by Type of Use","what":"Subject Identification Columns","title":"rxode2 Event Types","text":"subject identification column separates subjects identification random effects. ID: subject identifier may integer, character, factor.","code":""},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-datasets.html","id":"observation-columns","dir":"Articles","previous_headings":"Columns Described by Type of Use","what":"Observation Columns","title":"rxode2 Event Types","text":"Observation columns used indicate dependent variable use measure . DV: numeric column measurement CENS: numeric column indication censoring, limit quantification assay. LIMIT: numeric column helping indicate type censoring, limit quantification assay. MDV: indicator missing DV values CMT: name number compartment DVID: dependent variable identifier EVID event identifier","code":""},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-datasets.html","id":"dosing-columns","dir":"Articles","previous_headings":"Columns Described by Type of Use","what":"Dosing Columns","title":"rxode2 Event Types","text":"AMT: amount dose CMT: name number compartment EVID: event identifier ADDL: number additional doses RATE DUR: rate duration dose","code":""},{"path":[]},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-datasets.html","id":"details-for-specific-dataset-columns","dir":"Articles","previous_headings":"","what":"Details for Specific Dataset Columns","title":"rxode2 Event Types","text":"details sorted alphabetically column name. grouping use, see documentation .","code":""},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-datasets.html","id":"amt-column","dir":"Articles","previous_headings":"Details for Specific Dataset Columns","what":"AMT Column","title":"rxode2 Event Types","text":"AMT column defines amount dose. observation rows, 0 NA. dosing rows, amount dose administered CMT. dose zero-order rate (constant infusion), infusion may setup using RATE DUR column.","code":""},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-datasets.html","id":"censlimit-columns","dir":"Articles","previous_headings":"Details for Specific Dataset Columns","what":"CENS/LIMIT Columns","title":"rxode2 Event Types","text":"CENS column indicator column indicating censoring occurred. pharmacokinetic modeling, censoring typically sample limit quantification. Internally rxode2 saves values nlmixr can use likelihood calculations. CENS = 0 indicates value DV measured without censoring. CENS = 1 indicates value left censored (limit quantitation) value DV censoring/quantitation limit. CENS = -1 indicates value right censored (limit quantitation) value DV censoring/quantitation limit. LIMIT additional information censoring handled nlmixr stored rxode2’s data structure well. value left censored, like limit 1 may also believe value certain threshold, like zero. case, limit 0 indicates censored value 0 1. short : CENS = 0 LIMIT ignored observation censored CENS = 1 value censored (LIMIT, DV) CENS = -1 value censored (DV, LIMIT)","code":""},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-datasets.html","id":"cmt-column","dir":"Articles","previous_headings":"Details for Specific Dataset Columns","what":"CMT Column","title":"rxode2 Event Types","text":"CMT column indicates compartment event occurs. given character string factor (preferred method), matched name model. given integer, matched order compartments appear model.","code":""},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-datasets.html","id":"dur-column","dir":"Articles","previous_headings":"Details for Specific Dataset Columns","what":"DUR Column","title":"rxode2 Event Types","text":"DUR column defines duration infusion. used set duration zero-order rate infusion.","code":""},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-datasets.html","id":"dv-column","dir":"Articles","previous_headings":"Details for Specific Dataset Columns","what":"DV Column","title":"rxode2 Event Types","text":"DV column indicates current measurement current compartment (see CMT) current measurement identifier (see DVID) may missing (see MDV) censored (see CENS).","code":""},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-datasets.html","id":"dvid-column","dir":"Articles","previous_headings":"Details for Specific Dataset Columns","what":"DVID Column","title":"rxode2 Event Types","text":"TODO","code":""},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-datasets.html","id":"evid-column","dir":"Articles","previous_headings":"Details for Specific Dataset Columns","what":"EVID Column","title":"rxode2 Event Types","text":"EVID column event identifier row data. observation records, 0. normal dosing records, 1. Many EVID values detailed rxode2 Event Types Classic rxode2 Events vignettes.","code":""},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-datasets.html","id":"id-column","dir":"Articles","previous_headings":"Details for Specific Dataset Columns","what":"ID Column","title":"rxode2 Event Types","text":"ID column subject identifier. column used separate one individual (usually single person animal) another. model, ID column used separate individuals. numerical integrator re-initializes new individual, new values random effects selected.","code":""},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-datasets.html","id":"rate-column","dir":"Articles","previous_headings":"Details for Specific Dataset Columns","what":"RATE Column","title":"rxode2 Event Types","text":"TODO","code":""},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-event-table.html","id":"creating-rxode2s-event-tables","dir":"Articles","previous_headings":"","what":"Creating rxode2’s event tables","title":"Easy rxode2 Event Tables","text":"event table rxode2 specialized data frame acts container rxode2’s events observation times. create rxode2 event table may use code eventTable(), et(), even create data frame right event information contained . closely related types events rxode2 supports. event table can add sampling/observations doses piping direct access. short table two main functions create dosing Sampling times can added add.sampling( sampling times ) et( sampling times ). Dosing intervals sampling windows also supported. documentation using et() syntax, though supported. models, can illustrate using model shared rxode2 tutorial:","code":"library(rxode2) #> rxode2 2.1.1.9000 using 2 threads (see ?getRxThreads) #> no cache: create with `rxCreateCache()` library(units) #> udunits database from /usr/share/xml/udunits/udunits2.xml (ev <- et()) #> -- EventTable with 0 records -- #> 0 dosing records (see x$get.dosing(); add with add.dosing or et) #> 0 observation times (see x$get.sampling(); add with add.sampling or et) (ev <- et()) #> -- EventTable with 0 records -- #> 0 dosing records (see x$get.dosing(); add with add.dosing or et) #> 0 observation times (see x$get.sampling(); add with add.sampling or et) ## Model from rxode2 tutorial m1 <-function() { ini({ KA <- 2.94E-01 CL <- 1.86E+01 V2 <- 4.02E+01 Q <- 1.05E+01 V3 <- 2.97E+02 Kin <- 1 Kout <- 1 EC50 <- 200 ## Added modeled bioavaiblity, duration and rate fdepot <- 1 durDepot <- 8 rateDepot <- 1250 }) model({ C2 <- centr/V2 C3 <- peri/V3 d/dt(depot) <- -KA*depot f(depot) <- fdepot dur(depot) <- durDepot rate(depot) <- rateDepot d/dt(centr) <- KA*depot - CL*C2 - Q*C2 + Q*C3 d/dt(peri) <- Q*C2 - Q*C3 d/dt(eff) <- Kin - Kout*(1-C2/(EC50+C2))*eff; eff(0) <- 1 }) }"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-event-table.html","id":"adding-doses-to-the-event-table","dir":"Articles","previous_headings":"Creating rxode2’s event tables","what":"Adding doses to the event table","title":"Easy rxode2 Event Tables","text":"created can add dosing event table add.dosing(), et() functions. Using add.dosing() function : Notice units specified table. specified, units use units package keep track units convert needed. Additionally, ggforce uses label ggplot axes. set_units drop_units useful set drop rxode2 event table units. example, can see time axes labeled: familiar NONMEM/rxode2 event records, can also specify dosing using et dose elements directly: gives: shows easy creating event tables can .","code":"ev <- eventTable(amount.units=\"mg\", time.units=\"hr\") ## The methods ar attached to the event table, so you can use ## them directly ev$add.dosing(dose=10000, nbr.doses = 3)# loading doses ## Starts at time 0; Default dosing interval is 24 ## You can also pipe the event tables to these methods. ev <- ev %>% add.dosing(dose=5000, nbr.doses=14, dosing.interval=12)# maintenance ev #> -- EventTable with 2 records -- #> 2 dosing records (see x$get.dosing(); add with add.dosing or et) #> 0 observation times (see x$get.sampling(); add with add.sampling or et) #> multiple doses in `addl` columns, expand with x$expand(); or etExpand(x) #> -- First part of x: -- #> # A tibble: 2 x 5 #> time amt ii addl evid #> [h] [mg] [h] #> 1 0 10000 24 2 1:Dose (Add) #> 2 0 5000 12 13 1:Dose (Add) rxSolve(m1, ev) %>% plot(C2) #> using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’ ev <- et(timeUnits=\"hr\") %>% et(amt=10000, until = set_units(3, days), ii=12) # loading doses ev #> -- EventTable with 1 records -- #> 1 dosing records (see x$get.dosing(); add with add.dosing or et) #> 0 observation times (see x$get.sampling(); add with add.sampling or et) #> multiple doses in `addl` columns, expand with x$expand(); or etExpand(x) #> -- First part of x: -- #> # A tibble: 1 x 5 #> time amt ii addl evid #> [h] [h] #> 1 0 10000 12 6 1:Dose (Add) rxSolve(m1, ev) %>% plot(C2) #> using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-event-table.html","id":"adding-sampling-to-an-event-table","dir":"Articles","previous_headings":"Creating rxode2’s event tables","what":"Adding sampling to an event table","title":"Easy rxode2 Event Tables","text":"notice examples, rxode2 generated default sampling times since sampling times. wish control sampling time, add samples rxode2 event table add.sampling et gives: use et can simply add similar way add.sampling: gives following rxode2 solve: Note jagged nature plots since sample times.","code":"ev <- eventTable(amount.units=\"mg\", time.units=\"hr\") ## The methods ar attached to the event table, so you can use them ## directly ev$add.dosing(dose=10000, nbr.doses = 3)# loading doses ev$add.sampling(seq(0,24,by=4)) ev #> -- EventTable with 8 records -- #> 1 dosing records (see x$get.dosing(); add with add.dosing or et) #> 7 observation times (see x$get.sampling(); add with add.sampling or et) #> multiple doses in `addl` columns, expand with x$expand(); or etExpand(x) #> -- First part of x: -- #> # A tibble: 8 x 5 #> time amt ii addl evid #> [h] [mg] [h] #> 1 0 NA NA NA 0:Observation #> 2 0 10000 24 2 1:Dose (Add) #> 3 4 NA NA NA 0:Observation #> 4 8 NA NA NA 0:Observation #> 5 12 NA NA NA 0:Observation #> 6 16 NA NA NA 0:Observation #> 7 20 NA NA NA 0:Observation #> 8 24 NA NA NA 0:Observation solve(m1, ev) %>% plot(C2) ev <- et(timeUnits=\"hr\") %>% et(amt=10000, until = set_units(3, days), ii=12) %>% # loading doses et(seq(0,24,by=4)) ev #> -- EventTable with 8 records -- #> 1 dosing records (see x$get.dosing(); add with add.dosing or et) #> 7 observation times (see x$get.sampling(); add with add.sampling or et) #> multiple doses in `addl` columns, expand with x$expand(); or etExpand(x) #> -- First part of x: -- #> # A tibble: 8 x 5 #> time amt ii addl evid #> [h] [h] #> 1 0 NA NA NA 0:Observation #> 2 0 10000 12 6 1:Dose (Add) #> 3 4 NA NA NA 0:Observation #> 4 8 NA NA NA 0:Observation #> 5 12 NA NA NA 0:Observation #> 6 16 NA NA NA 0:Observation #> 7 20 NA NA NA 0:Observation #> 8 24 NA NA NA 0:Observation solve(m1, ev) %>% plot(C2)"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-event-table.html","id":"expand-the-event-table-to-a-multi-subject-event-table-","dir":"Articles","previous_headings":"Creating rxode2’s event tables","what":"Expand the event table to a multi-subject event table.","title":"Easy rxode2 Event Tables","text":"thing needed expand event table list IDs want expand; can see following simulation 4 individuals solved :","code":"ev <- et(timeUnits=\"hr\") %>% et(amt=10000, until = set_units(3, days), ii=12) %>% # loading doses et(seq(0,48,length.out=200)) %>% et(id=1:4) ev #> -- EventTable with 804 records -- #> 4 dosing records (see x$get.dosing(); add with add.dosing or et) #> 800 observation times (see x$get.sampling(); add with add.sampling or et) #> multiple doses in `addl` columns, expand with x$expand(); or etExpand(x) #> -- First part of x: -- #> # A tibble: 804 x 6 #> id time amt ii addl evid #> [h] [h] #> 1 1 0 NA NA NA 0:Observation #> 2 1 0 10000 12 6 1:Dose (Add) #> 3 1 0.241 NA NA NA 0:Observation #> 4 1 0.482 NA NA NA 0:Observation #> 5 1 0.724 NA NA NA 0:Observation #> 6 1 0.965 NA NA NA 0:Observation #> 7 1 1.21 NA NA NA 0:Observation #> 8 1 1.45 NA NA NA 0:Observation #> 9 1 1.69 NA NA NA 0:Observation #> 10 1 1.93 NA NA NA 0:Observation #> # i 794 more rows set.seed(42) rxSetSeed(42) solve(m1, ev, params=data.frame(KA=0.294*exp(rnorm(4)), CL=18.6*exp(rnorm(4)))) %>% plot(C2)"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-event-table.html","id":"add-doses-and-samples-within-a-sampling-window","dir":"Articles","previous_headings":"Creating rxode2’s event tables","what":"Add doses and samples within a sampling window","title":"Easy rxode2 Event Tables","text":"addition adding fixed doses fixed sampling times, can windows sample draw doses . dosing windows specify time ordered numerical vector lowest dosing time highest dosing time inside list. example, start dosing time 6 hour dosing window: can clearly see different dosing times following simulation: course reality dosing interval may 2 hours: sort thing can specified sampling times. specify sampling times terms sampling window, can create list sampling times. sampling time two element ordered numeric vector. shows flexibility dosing sampling rxode2 event tables allow.","code":"set.seed(42) rxSetSeed(42) ev <- et(timeUnits=\"hr\") %>% et(time=list(c(0,6)), amt=10000, until = set_units(2, days), ii=12) %>% # loading doses et(id=1:4) ev #> -- EventTable with 16 records -- #> 16 dosing records (see x$get.dosing(); add with add.dosing or et) #> 0 observation times (see x$get.sampling(); add with add.sampling or et) #> -- First part of x: -- #> # A tibble: 16 x 6 #> id low time high amt evid #> [h] [h] [h] #> 1 1 0 5.49 6 10000 1:Dose (Add) #> 2 1 12 17.0 18 10000 1:Dose (Add) #> 3 1 24 25.7 30 10000 1:Dose (Add) #> 4 1 36 41.6 42 10000 1:Dose (Add) #> 5 2 0 4.31 6 10000 1:Dose (Add) #> 6 2 12 14.7 18 10000 1:Dose (Add) #> 7 2 24 28.2 30 10000 1:Dose (Add) #> 8 2 36 39.9 42 10000 1:Dose (Add) #> 9 3 0 0.808 6 10000 1:Dose (Add) #> 10 3 12 16.4 18 10000 1:Dose (Add) #> 11 3 24 27.1 30 10000 1:Dose (Add) #> 12 3 36 39.9 42 10000 1:Dose (Add) #> 13 4 0 4.98 6 10000 1:Dose (Add) #> 14 4 12 13.7 18 10000 1:Dose (Add) #> 15 4 24 29.6 30 10000 1:Dose (Add) #> 16 4 36 41.5 42 10000 1:Dose (Add) ev <- ev %>% et(seq(0,48,length.out=200)) solve(m1, ev, params=data.frame(KA=0.294*exp(rnorm(4)), CL=18.6*exp(rnorm(4)))) %>% plot(C2) set.seed(42) rxSetSeed(42) ev <- et(timeUnits=\"hr\") %>% et(time=list(c(0,2)), amt=10000, until = set_units(2, days), ii=12) %>% # loading doses et(id=1:4) %>% et(seq(0,48,length.out=200)) solve(m1, ev, params=data.frame(KA=0.294*exp(rnorm(4)), CL=18.6*exp(rnorm(4)))) %>% plot(C2) rxSetSeed(42) set.seed(42) ev <- et(timeUnits=\"hr\") %>% et(time=list(c(0,2)), amt=10000, until = set_units(2, days), ii=12) %>% # loading doses et(id=1:4) ## Create 20 samples in the first 24 hours and 20 samples in the ## second 24 hours samples <- c(lapply(1:20, function(...){c(0,24)}), lapply(1:20, function(...){c(20,48)})) ## Add the random collection to the event table ev <- ev %>% et(samples) library(ggplot2) solve(m1, ev, params=data.frame(KA=0.294*exp(rnorm(4)), CL=18.6*exp(rnorm(4)))) %>% plot(C2) + geom_point()"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-event-table.html","id":"combining-event-tables","dir":"Articles","previous_headings":"Creating rxode2’s event tables","what":"Combining event tables","title":"Easy rxode2 Event Tables","text":"Since can create dosing records sampling records, can create complex dosing regimen wish. addition, rxode2 allows combine event tables c, seq, rep, rbind.","code":""},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-event-table.html","id":"sequencing-event-tables","dir":"Articles","previous_headings":"Creating rxode2’s event tables","what":"Sequencing event tables","title":"Easy rxode2 Event Tables","text":"One way combine event table sequence c, seq etSeq. takes two dosing groups adds least one inter-dose interval : sequencing events, can also separate sequence period time; example wanted separate week, easily following sequence event tables: Note example time bid qd event tables exactly one week, 1 week plus 24 hours inter-dose interval. want behavior, can sequence using wait=\"+ii\". Also note, rxode2 assumes dosing want space event tables , clears sampling records combine event tables. true, can also use option samples=\"use\"","code":"## bid for 5 days bid <- et(timeUnits=\"hr\") %>% et(amt=10000,ii=12,until=set_units(5, \"days\")) ## qd for 5 days qd <- et(timeUnits=\"hr\") %>% et(amt=20000,ii=24,until=set_units(5, \"days\")) ## bid for 5 days followed by qd for 5 days et <- seq(bid,qd) %>% et(seq(0,11*24,length.out=100)); rxSolve(m1, et) %>% plot(C2) ## bid for 5 days followed by qd for 5 days et <- seq(bid,set_units(1, \"week\"), qd) %>% et(seq(0,18*24,length.out=100)); rxSolve(m1, et) %>% plot(C2) ## bid for 5 days followed by qd for 5 days et <- seq(bid,set_units(1, \"week\"), qd,wait=\"+ii\") %>% et(seq(0,18*24,length.out=100)); rxSolve(m1, et) %>% plot(C2)"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-event-table.html","id":"repeating-event-tables","dir":"Articles","previous_headings":"Creating rxode2’s event tables","what":"Repeating event tables","title":"Easy rxode2 Event Tables","text":"can event table can repeat etRep rep. example 4 rounds 2 weeks QD therapy 1 week therapy can simply specified: simplified way use sequence event tables. Therefore, many options still apply; samples cleared unless use samples=\"use\", time event tables least inter-dose interval. can adjust timing wait option.","code":"qd <-et(timeUnits = \"hr\") %>% et(amt=10000, ii=24, until=set_units(2, \"weeks\"), cmt=\"depot\") et <- rep(qd, times=4, wait=set_units(1,\"weeks\")) %>% add.sampling(set_units(seq(0, 12.5,by=0.005),weeks)) rxSolve(m1, et) %>% plot(C2)"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-event-table.html","id":"combining-event-tables-with-rbind","dir":"Articles","previous_headings":"Creating rxode2’s event tables","what":"Combining event tables with rbind","title":"Easy rxode2 Event Tables","text":"may combine event tables rbind. consider event times combining event tables, keeps times. space event tables waiting period, also consider inter-dose interval. Using previous seq can clearly see difference. sequence: bind together rbind Still waiting period applies (consider inter-dose interval) can also bind tables together make ID event table unique; can good combine cohorts different expected dosing sampling times. requires id=\"unique\" option; Using first example shows different case:","code":"## bid for 5 days bid <- et(timeUnits=\"hr\") %>% et(amt=10000,ii=12,until=set_units(5, \"days\")) ## qd for 5 days qd <- et(timeUnits=\"hr\") %>% et(amt=20000,ii=24,until=set_units(5, \"days\")) et <- seq(bid,qd) %>% et(seq(0,18*24,length.out=500)); rxSolve(m1, et) %>% plot(C2) ## bid for 5 days et <- rbind(bid,qd) %>% et(seq(0,18*24,length.out=500)); rxSolve(m1, et) %>% plot(C2) et <- rbind(bid,wait=set_units(10,days),qd) %>% et(seq(0,18*24,length.out=500)); rxSolve(m1, et) %>% plot(C2) ## bid for 5 days et <- etRbind(bid,qd, id=\"unique\") %>% et(seq(0,150,length.out=500)); library(ggplot2) rxSolve(m1, et) %>% plot(C2) + facet_wrap( ~ id)"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-event-table.html","id":"event-tables-in-rstudio-notebooks","dir":"Articles","previous_headings":"Creating rxode2’s event tables","what":"Event tables in Rstudio Notebooks","title":"Easy rxode2 Event Tables","text":"addition output console shown examples, Rstudio notebook output different can seen following screenshots; first screenshot shows event table looks evaluating Rstduio notebook simple dataframe allows page contents. click first box Rstudio notebook output, notes event table: ## Expanding events Event tables can expanded contain addl data item, like following example: can expand events addl items $expand() etExpand(ev): first, etExpand(ev) expands event table without modifying original data frame: can see addl events expanded, however original data frame remained intact: use ev$expand() modify ev object. similar object-oriented method:","code":"ev <- et() %>% et(dose=50, ii=8, until=48) ev #> -- EventTable with 1 records -- #> 1 dosing records (see x$get.dosing(); add with add.dosing or et) #> 0 observation times (see x$get.sampling(); add with add.sampling or et) #> multiple doses in `addl` columns, expand with x$expand(); or etExpand(x) #> -- First part of x: -- #> # A tibble: 1 x 5 #> time amt ii addl evid #> #> 1 0 50 8 6 1:Dose (Add) etExpand(ev) #> -- EventTable with 7 records -- #> 7 dosing records (see x$get.dosing(); add with add.dosing or et) #> 0 observation times (see x$get.sampling(); add with add.sampling or et) #> -- First part of x: -- #> # A tibble: 7 x 4 #> time amt ii evid #> #> 1 0 50 0 1:Dose (Add) #> 2 8 50 0 1:Dose (Add) #> 3 16 50 0 1:Dose (Add) #> 4 24 50 0 1:Dose (Add) #> 5 32 50 0 1:Dose (Add) #> 6 40 50 0 1:Dose (Add) #> 7 48 50 0 1:Dose (Add) print(ev) #> -- EventTable with 1 records -- #> 1 dosing records (see $get.dosing(); add with add.dosing or et) #> 0 observation times (see $get.sampling(); add with add.sampling or et) #> multiple doses in `addl` columns, expand with $expand(); or etExpand() #> -- First part of : -- #> # A tibble: 1 x 5 #> time amt ii addl evid #> #> 1 0 50 8 6 1:Dose (Add) ev$expand() ev #> -- EventTable with 7 records -- #> 7 dosing records (see x$get.dosing(); add with add.dosing or et) #> 0 observation times (see x$get.sampling(); add with add.sampling or et) #> -- First part of x: -- #> # A tibble: 7 x 4 #> time amt ii evid #> #> 1 0 50 0 1:Dose (Add) #> 2 8 50 0 1:Dose (Add) #> 3 16 50 0 1:Dose (Add) #> 4 24 50 0 1:Dose (Add) #> 5 32 50 0 1:Dose (Add) #> 6 40 50 0 1:Dose (Add) #> 7 48 50 0 1:Dose (Add)"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-event-types.html","id":"rxode2-event-tables","dir":"Articles","previous_headings":"","what":"rxode2 event tables","title":"rxode2 Event Types","text":"general, rxode2 event tables follow NONMEM dataset convention exceptions: may turn compartment negative compartment number “-cmt” cmt compartment name. compartment data item (cmt) can still number, number compartment defined appearance compartment name model. can tedious count, can specify compartment numbers easier using cmt(cmtName) beginning model. Bioavailability changes change rate infusion since dur/amt fixed input data. Similarly, specifying rate/amt infusion, bioavailability change infusion duration since rate/amt fixed input data. infrequent NONMEM columns supported: pcmt, call. evid=5 replace event; replaces value compartment value specified amt column. equivalent deSolve=replace. evid=6 multiply event; multiplies value compartment value specified amt column. equivalent deSolve=multiply. evid=7 transit compartment model/phantom event. puts dose dose() function calculates time since last dose tad() doesn’t actually put dose compartment. allows transit() function easily apply compartment. legal entries data table: notes: evid can classic RxODE (described ) NONMEM-style evid described . NONMEM’s DV required; rxode2 ODE solving framework. NONMEM’s MDV required, since captured EVID. Instead NONMEM-compatible data, can accept deSolve compatible data-frames. returning rxode2 solved data-set additional event ids (EVID) may see depending solving options: EVID = -1 modeled rate ends (corresponds rate = -1) EVID = -2 modeled duration ends (corresponds rate=-2) EVID = -10 rate specified zero-order infusion ends (corresponds rate > 0) EVID = -20 duration specified zero-order infusion ends (corresponds dur > 0) EVID = 101, 102, 103,... correspond 1, 2, 3, … modeled time (mtime). can accessed solving option combination addDosing=TRUE subsetNonmem=FALSE. want see classic EVID equivalents can use addDosing=NA. illustrate event types use model original rxode2 tutorial.","code":"library(rxode2) #> rxode2 2.1.1.9000 using 2 threads (see ?getRxThreads) #> no cache: create with `rxCreateCache()` ## Model from rxode2 tutorial m1 <- function() { ini({ KA <- 2.94E-01 CL <- 1.86E+01 V2 <- 4.02E+01 Q <- 1.05E+01 V3 <- 2.97E+02 Kin <- 1 Kout <- 1 EC50 <- 200 ## Added modeled bioavaiblity, duration and rate fdepot <- 1 durDepot <- 8 rateDepot <- 1250 }) model({ C2 <- centr/V2 C3 <- peri/V3 d/dt(depot) <- -KA*depot f(depot) <- fdepot dur(depot) <- durDepot rate(depot) <- rateDepot d/dt(centr) <- KA*depot - CL*C2 - Q*C2 + Q*C3 d/dt(peri) <- Q*C2 - Q*C3 d/dt(eff) <- Kin - Kout*(1-C2/(EC50+C2))*eff eff(0) <- 1 }) }"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-event-types.html","id":"bolusadditive-doses","dir":"Articles","previous_headings":"","what":"Bolus/Additive Doses","title":"rxode2 Event Types","text":"bolus dose default type dose rxode2 requires amt/dose. Note uses convenience function et() described rxode2 event tables","code":"ev <- et(timeUnits=\"hr\") %>% et(amt=10000, ii=12,until=24) %>% et(seq(0, 24, length.out=100)) ev #> -- EventTable with 101 records -- #> 1 dosing records (see x$get.dosing(); add with add.dosing or et) #> 100 observation times (see x$get.sampling(); add with add.sampling or et) #> multiple doses in `addl` columns, expand with x$expand(); or etExpand(x) #> -- First part of x: -- #> # A tibble: 101 x 5 #> time amt ii addl evid #> [h] [h] #> 1 0 NA NA NA 0:Observation #> 2 0 10000 12 2 1:Dose (Add) #> 3 0.242 NA NA NA 0:Observation #> 4 0.485 NA NA NA 0:Observation #> 5 0.727 NA NA NA 0:Observation #> 6 0.970 NA NA NA 0:Observation #> 7 1.21 NA NA NA 0:Observation #> 8 1.45 NA NA NA 0:Observation #> 9 1.70 NA NA NA 0:Observation #> 10 1.94 NA NA NA 0:Observation #> # i 91 more rows rxSolve(m1, ev) %>% plot(C2) + xlab(\"Time\")"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-event-types.html","id":"infusion-doses","dir":"Articles","previous_headings":"","what":"Infusion Doses","title":"rxode2 Event Types","text":"different type infusions rxode2 supports: Constant Rate Infusion (rate) Constant Duration Infusion (dur) Estimated Rate Infusion Estimated Duration Infusion","code":""},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-event-types.html","id":"constant-infusion-in-terms-of-duration-and-rate","dir":"Articles","previous_headings":"Infusion Doses","what":"Constant Infusion (in terms of duration and rate)","title":"rxode2 Event Types","text":"next type event infusion; two ways specify infusion; first dur keyword. example : can also specified rate component: exception bioavailability changes infusion. case modeling rate, bioavailability decrease, decreases infusion duration, NONMEM. example: Similarly increasing bioavailability increases infusion duration. rationale behavior rate amt specified event table, thing can change bioavailability increase duration infusion. specify amt dur components event table, bioavailability changes affect rate infusion. can see side--side comparison bioavailability changes affecting rate instead duration records following plots:","code":"ev <- et(timeUnits=\"hr\") %>% et(amt=10000, ii=12,until=24, dur=8) %>% et(seq(0, 24, length.out=100)) ev #> -- EventTable with 101 records -- #> 1 dosing records (see x$get.dosing(); add with add.dosing or et) #> 100 observation times (see x$get.sampling(); add with add.sampling or et) #> multiple doses in `addl` columns, expand with x$expand(); or etExpand(x) #> -- First part of x: -- #> # A tibble: 101 x 6 #> time amt ii addl evid dur #> [h] [h] [h] #> 1 0 NA NA NA 0:Observation NA #> 2 0 10000 12 2 1:Dose (Add) 8 #> 3 0.242 NA NA NA 0:Observation NA #> 4 0.485 NA NA NA 0:Observation NA #> 5 0.727 NA NA NA 0:Observation NA #> 6 0.970 NA NA NA 0:Observation NA #> 7 1.21 NA NA NA 0:Observation NA #> 8 1.45 NA NA NA 0:Observation NA #> 9 1.70 NA NA NA 0:Observation NA #> 10 1.94 NA NA NA 0:Observation NA #> # i 91 more rows rxSolve(m1, ev) %>% plot(depot, C2) + xlab(\"Time\") ev <- et(timeUnits=\"hr\") %>% et(amt=10000, ii=12,until=24, rate=10000/8) %>% et(seq(0, 24, length.out=100)) ev #> -- EventTable with 101 records -- #> 1 dosing records (see x$get.dosing(); add with add.dosing or et) #> 100 observation times (see x$get.sampling(); add with add.sampling or et) #> multiple doses in `addl` columns, expand with x$expand(); or etExpand(x) #> -- First part of x: -- #> # A tibble: 101 x 6 #> time amt rate ii addl evid #> [h] [h] #> 1 0 NA NA NA NA 0:Observation #> 2 0 10000 1250 12 2 1:Dose (Add) #> 3 0.242 NA NA NA NA 0:Observation #> 4 0.485 NA NA NA NA 0:Observation #> 5 0.727 NA NA NA NA 0:Observation #> 6 0.970 NA NA NA NA 0:Observation #> 7 1.21 NA NA NA NA 0:Observation #> 8 1.45 NA NA NA NA 0:Observation #> 9 1.70 NA NA NA NA 0:Observation #> 10 1.94 NA NA NA NA 0:Observation #> # i 91 more rows rxSolve(m1, ev) %>% plot(depot, C2) + xlab(\"Time\") rxSolve(m1, ev, c(fdepot=0.25)) %>% plot(depot, C2) + xlab(\"Time\") rxSolve(m1, ev, c(fdepot=1.25)) %>% plot(depot, C2) + xlab(\"Time\") ev <- et(timeUnits=\"hr\") %>% et(amt=10000, ii=12,until=24, dur=8) %>% et(seq(0, 24, length.out=100)) library(ggplot2) library(patchwork) p1 <- rxSolve(m1, ev, c(fdepot=1.25)) %>% plot(depot) + xlab(\"Time\") + ylim(0,5000) p2 <- rxSolve(m1, ev, c(fdepot=0.25)) %>% plot(depot) + xlab(\"Time\")+ ylim(0,5000) ## Use patchwork syntax to combine plots p1 * p2"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-event-types.html","id":"modeled-rate-and-duration-of-infusion","dir":"Articles","previous_headings":"Infusion Doses","what":"Modeled Rate and Duration of Infusion","title":"rxode2 Event Types","text":"can model duration, equivalent NONMEM’s rate=-2. Similarly, may also model rate. equivalent NONMEM’s rate=-1 rxode2’s event table specifies data item well.","code":"ev <- et(timeUnits=\"hr\") %>% et(amt=10000, ii=12,until=24, rate=-2) %>% et(seq(0, 24, length.out=100)) ev #> -- EventTable with 101 records -- #> 1 dosing records (see x$get.dosing(); add with add.dosing or et) #> 100 observation times (see x$get.sampling(); add with add.sampling or et) #> multiple doses in `addl` columns, expand with x$expand(); or etExpand(x) #> -- First part of x: -- #> # A tibble: 101 x 6 #> time amt rate ii addl evid #> [h] [h] #> 1 0 NA NA NA NA 0:Observation #> 2 0 10000 -2:dur 12 2 1:Dose (Add) #> 3 0.242 NA NA NA NA 0:Observation #> 4 0.485 NA NA NA NA 0:Observation #> 5 0.727 NA NA NA NA 0:Observation #> 6 0.970 NA NA NA NA 0:Observation #> 7 1.21 NA NA NA NA 0:Observation #> 8 1.45 NA NA NA NA 0:Observation #> 9 1.70 NA NA NA NA 0:Observation #> 10 1.94 NA NA NA NA 0:Observation #> # i 91 more rows rxSolve(m1, ev, c(durDepot=7)) %>% plot(depot, C2) + xlab(\"Time\") ev <- et(timeUnits=\"hr\") %>% et(amt=10000, ii=12,until=24, rate=-1) %>% et(seq(0, 24, length.out=100)) ev #> -- EventTable with 101 records -- #> 1 dosing records (see x$get.dosing(); add with add.dosing or et) #> 100 observation times (see x$get.sampling(); add with add.sampling or et) #> multiple doses in `addl` columns, expand with x$expand(); or etExpand(x) #> -- First part of x: -- #> # A tibble: 101 x 6 #> time amt rate ii addl evid #> [h] [h] #> 1 0 NA NA NA NA 0:Observation #> 2 0 10000 -1:rate 12 2 1:Dose (Add) #> 3 0.242 NA NA NA NA 0:Observation #> 4 0.485 NA NA NA NA 0:Observation #> 5 0.727 NA NA NA NA 0:Observation #> 6 0.970 NA NA NA NA 0:Observation #> 7 1.21 NA NA NA NA 0:Observation #> 8 1.45 NA NA NA NA 0:Observation #> 9 1.70 NA NA NA NA 0:Observation #> 10 1.94 NA NA NA NA 0:Observation #> # i 91 more rows rxSolve(m1, ev, c(rateDepot=10000/3)) %>% plot(depot, C2) + xlab(\"Time\")"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-event-types.html","id":"steady-state","dir":"Articles","previous_headings":"","what":"Steady State","title":"rxode2 Event Types","text":"doses solved steady state reached constant inter-dose interval.","code":"ev <- et(timeUnits=\"hr\") %>% et(amt=10000, ii=12, ss=1) %>% et(seq(0, 24, length.out=100)) ev #> -- EventTable with 101 records -- #> 1 dosing records (see x$get.dosing(); add with add.dosing or et) #> 100 observation times (see x$get.sampling(); add with add.sampling or et) #> -- First part of x: -- #> # A tibble: 101 x 5 #> time amt ii evid ss #> [h] [h] #> 1 0 NA NA 0:Observation NA #> 2 0 10000 12 1:Dose (Add) 1 #> 3 0.242 NA NA 0:Observation NA #> 4 0.485 NA NA 0:Observation NA #> 5 0.727 NA NA 0:Observation NA #> 6 0.970 NA NA 0:Observation NA #> 7 1.21 NA NA 0:Observation NA #> 8 1.45 NA NA 0:Observation NA #> 9 1.70 NA NA 0:Observation NA #> 10 1.94 NA NA 0:Observation NA #> # i 91 more rows rxSolve(m1, ev) %>% plot(C2)"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-event-types.html","id":"steady-state-for-complex-dosing","dir":"Articles","previous_headings":"Steady State","what":"Steady state for complex dosing","title":"rxode2 Event Types","text":"using ss=2 flag, can use super-positioning principle linear kinetics get steady state nonstandard dosing (.e. morning 100 mg vs evening 150 mg). done : Saving state values Resetting states solving system steady state Adding back prior state values can see takes full dose cycle reach true complex steady state dosing.","code":"ev <- et(timeUnits=\"hr\") %>% et(amt=10000, ii=24, ss=1) %>% et(time=12, amt=15000, ii=24, ss=2) %>% et(time=24, amt=10000, ii=24, addl=3) %>% et(time=36, amt=15000, ii=24, addl=3) %>% et(seq(0, 64, length.out=500)) library(ggplot2) rxSolve(m1, ev,maxsteps=10000) %>% plot(C2) + annotate(\"rect\", xmin=0, xmax=24, ymin=-Inf, ymax=Inf, alpha=0.2) + annotate(\"text\", x=12.5, y=7, label=\"Initial Steady State Period\") + annotate(\"text\", x=44, y=7, label=\"Steady State AM/PM dosing\")"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-event-types.html","id":"steady-state-for-constant-infusion-or-zero-order-processes","dir":"Articles","previous_headings":"Steady State","what":"Steady state for constant infusion or zero order processes","title":"rxode2 Event Types","text":"last type steady state rxode2 supports steady-state constant infusion rate. can specified way NONMEM, : inter-dose interval ii=0 steady state dose, ie ss=1 Either positive rate (rate>0) estimated rate rate=-1. zero dose, ie amt=0 steady-state constant infusion achieved, infusion turned using record, just like NONMEM. Note rate=-2 model duration infusion doesn’t make much sense since solving infusion steady state. duration specified steady state solution. Also note bioavailability changes steady state infusion also make sense neither change rate duration steady state infusion. Hence modeled bioavailability type dosing event ignored. example: can used PK, can used steady-state disease processes.","code":"ev <- et(timeUnits=\"hr\") %>% et(amt=0, ss=1,rate=10000/8) p1 <- rxSolve(m1, ev) %>% plot(C2, eff) ev <- et(timeUnits=\"hr\") %>% et(amt=200000, rate=10000/8) %>% et(0, 250, length.out=1000) p2 <- rxSolve(m1, ev) %>% plot(C2, eff) library(patchwork) p1 / p2"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-event-types.html","id":"reset-events","dir":"Articles","previous_headings":"","what":"Reset Events","title":"rxode2 Event Types","text":"Reset events implemented evid=3 evid=reset, reset evid=4 reset dose. solving show happens system system reset 6 hours post-dose. can see compartments reset initial values. next dose start dosing cycle . case, whole system reset dose given","code":"ev <- et(timeUnits=\"hr\") %>% et(amt=10000, ii=12, addl=3) %>% et(time=6, evid=reset) %>% et(seq(0, 24, length.out=100)) ev #> -- EventTable with 102 records -- #> 2 dosing records (see x$get.dosing(); add with add.dosing or et) #> 100 observation times (see x$get.sampling(); add with add.sampling or et) #> multiple doses in `addl` columns, expand with x$expand(); or etExpand(x) #> -- First part of x: -- #> # A tibble: 102 x 5 #> time amt ii addl evid #> [h] [h] #> 1 0 NA NA NA 0:Observation #> 2 0 10000 12 3 1:Dose (Add) #> 3 0.242 NA NA NA 0:Observation #> 4 0.485 NA NA NA 0:Observation #> 5 0.727 NA NA NA 0:Observation #> 6 0.970 NA NA NA 0:Observation #> 7 1.21 NA NA NA 0:Observation #> 8 1.45 NA NA NA 0:Observation #> 9 1.70 NA NA NA 0:Observation #> 10 1.94 NA NA NA 0:Observation #> # i 92 more rows rxSolve(m1, ev) %>% plot(depot,C2, eff) ev <- et(timeUnits=\"hr\") %>% et(amt=10000, ii=12, addl=3) %>% et(time=6, amt=10000, evid=4) %>% et(seq(0, 24, length.out=100)) ev #> -- EventTable with 102 records -- #> 2 dosing records (see x$get.dosing(); add with add.dosing or et) #> 100 observation times (see x$get.sampling(); add with add.sampling or et) #> multiple doses in `addl` columns, expand with x$expand(); or etExpand(x) #> -- First part of x: -- #> # A tibble: 102 x 5 #> time amt ii addl evid #> [h] [h] #> 1 0 NA NA NA 0:Observation #> 2 0 10000 12 3 1:Dose (Add) #> 3 0.242 NA NA NA 0:Observation #> 4 0.485 NA NA NA 0:Observation #> 5 0.727 NA NA NA 0:Observation #> 6 0.970 NA NA NA 0:Observation #> 7 1.21 NA NA NA 0:Observation #> 8 1.45 NA NA NA 0:Observation #> 9 1.70 NA NA NA 0:Observation #> 10 1.94 NA NA NA 0:Observation #> # i 92 more rows rxSolve(m1, ev) %>% plot(depot,C2, eff)"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-event-types.html","id":"turning-off-compartments","dir":"Articles","previous_headings":"","what":"Turning off compartments","title":"rxode2 Event Types","text":"may also turn compartment, similar reset event. Solving shows system: case, depot turned , depot compartment concentrations set initial values compartment concentrations/levels reset. another dose depot administered depot compartment turned back . Note dose compartment turns back compartment dosed. Hence turn effect compartment, continues another dose depot. turn back compartment, zero-dose compartment evid=2 compartment needed.","code":"ev <- et(timeUnits=\"hr\") %>% et(amt=10000, ii=12, addl=3) %>% et(time=6, cmt=\"-depot\", evid=2) %>% et(seq(0, 24, length.out=100)) ev #> -- EventTable with 102 records -- #> 2 dosing records (see x$get.dosing(); add with add.dosing or et) #> 100 observation times (see x$get.sampling(); add with add.sampling or et) #> multiple doses in `addl` columns, expand with x$expand(); or etExpand(x) #> -- First part of x: -- #> # A tibble: 102 x 6 #> time cmt amt ii addl evid #> [h] [h] #> 1 0 (obs) NA NA NA 0:Observation #> 2 0 (default) 10000 12 3 1:Dose (Add) #> 3 0.242 (obs) NA NA NA 0:Observation #> 4 0.485 (obs) NA NA NA 0:Observation #> 5 0.727 (obs) NA NA NA 0:Observation #> 6 0.970 (obs) NA NA NA 0:Observation #> 7 1.21 (obs) NA NA NA 0:Observation #> 8 1.45 (obs) NA NA NA 0:Observation #> 9 1.70 (obs) NA NA NA 0:Observation #> 10 1.94 (obs) NA NA NA 0:Observation #> # i 92 more rows rxSolve(m1, ev) %>% plot(depot,C2, eff) ev <- et(timeUnits=\"hr\") %>% et(amt=10000, ii=12, addl=3) %>% et(time=6, cmt=\"-eff\", evid=2) %>% et(seq(0, 24, length.out=100)) rxSolve(m1, ev) %>% plot(depot,C2, eff) ev <- et(timeUnits=\"hr\") %>% et(amt=10000, ii=12, addl=3) %>% et(time=6, cmt=\"-eff\", evid=2) %>% et(time=12,cmt=\"eff\",evid=2) %>% et(seq(0, 24, length.out=100)) rxSolve(m1, ev) %>% plot(depot,C2, eff)"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-events-classic.html","id":"classic-rxode-evid-values","dir":"Articles","previous_headings":"","what":"Classic RxODE evid values","title":"Classic rxode2 Events","text":"Originally RxODE supported compound event IDs; rxode2 still supports parameters, often useful use normal NONMEM dataset standard used many modeling tools like NONMEM, Monolix nlmixr, described rxode2 types article. Classically, RxODE supported event coding single event id evid described following table. classic EVID concatenate numbers table, infusion compartment 1 10101 infusion compartment 199 119901. EVID = 0 (observations), EVID=2 (type event) EVID=3 supported. Internally EVID=9 non-observation event makes sure system initialized zero; EVID=9 manually set. EVID 10-99 represents modeled time interventions, similar NONMEM’s MTIME. along amount (amt) time columns specify events ODE system. infusions specified EVIDs > 100 amt column represents rate value. Infusion flags 1 2 +amt turn infusion specific compartment -amt turn infusion specific compartment. specify dose/duration place dosing records time duration starts stops. modeled rate/duration infusion flags infusion flag must followed infusion record. number concatenated together form full RxODE event ID, shown following examples:","code":""},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-events-classic.html","id":"bolus-dose-examples","dir":"Articles","previous_headings":"Classic RxODE evid values","what":"Bolus Dose Examples","title":"Classic rxode2 Events","text":"100 bolus dose compartment #1 time 0 100 bolus dose compartment #99 time 0 100 bolus dose compartment #199 time 0","code":""},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-events-classic.html","id":"infusion-event-examples","dir":"Articles","previous_headings":"Classic RxODE evid values","what":"Infusion Event Examples","title":"Classic rxode2 Events","text":"Bolus infusion rate 50 compartment 1 1.5 hr, (modeled bioavailability changes duration infusion) Bolus infusion rate 50 compartment 1 1.5 hr (modeled bioavailability changes rate infusion) Modeled rate amount 50 Modeled duration amount 50","code":""},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-events-classic.html","id":"steady-state-for-classic-rxode-evid-example","dir":"Articles","previous_headings":"Classic RxODE evid values","what":"Steady State for classic RxODE EVID example","title":"Classic rxode2 Events","text":"Steady state dose cmt 1 Steady State super-positioning principle 50 pm 100 dose","code":""},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-events-classic.html","id":"steady-state-with-lagged-dose-for-classic-rxode-evid","dir":"Articles","previous_headings":"Classic RxODE evid values","what":"Steady state with lagged dose for classic RxODE evid","title":"Classic rxode2 Events","text":"Steady state lagged dose bolus dose: time | evid | amt | ii | 0 | 109 | 100 | 24 | 0 | 101 | 100 | 0 | event 109 calculates trough amount steady state passed (ii-lag_time) event 101 applies next steady state dose. Steady state (=2) lagged bolus dose Steady state infusion lag time time | evid | amt | ii | 0 | 10109 | 5 | 24 | 0 | 10108 | -5 | 24 | 0 | 10101 | 5 | | 20 | 10101 | -5 | | case bolus, 10109 event calculates trough concentration ii=24, may (may ) still infusion running. infusion running 10108 event turn infusion appropriate time. infusion completed, 10108 event ignored. next 2 events 10101 represent event times (assuming bioavailability applied).","code":""},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-events-classic.html","id":"turning-off-a-compartment-with-classic-rxode-evid","dir":"Articles","previous_headings":"Classic RxODE evid values","what":"Turning off a compartment with classic RxODE EVID","title":"Classic rxode2 Events","text":"Turn first compartment time 12 Event coding rxode2 encoded single event number evid. compartments 100, coded : event 0 observation events. 100*(Compartment Number) + 1 dose captured amt 10000 + 100*(Compartment Number) + 1 infusion rate captured amt column infusion turned subtracting amt evid stop infusion. compartments greater equal 100, 100s place digits transferred 100,000th place digit. doses 99th compartment evid bolus dose 9901 evid infusion 19901. bolus dose 199th compartment evid bolus dose 109901. infusion dosing record 199th compartment 119901.","code":""},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-intro.html","id":"introduction","dir":"Articles","previous_headings":"","what":"Introduction","title":"Introduction to rxode2","text":"rxode2 R package facilitates simulation ODE models R. designed pharmacometrics models mind, can applied generally ODE model.","code":""},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-intro.html","id":"description-of-rxode2-illustrated-through-an-example","dir":"Articles","previous_headings":"","what":"Description of rxode2 illustrated through an example","title":"Introduction to rxode2","text":"model equations can specified text string, model file R expression. differential algebraic equations permitted. Differential equations specified d/dt(var_name) =. equation can separated semicolon. load rxode2 package compile model: Model parameters may specified ini({}) model block, initial conditions can specified within model cmt(0)= X, like model eff(0) <- 1. may also specify subject variability initial conditions residual error components just like nlmixr2. allows single interface nlmixr2/rxode2 models. Also note, classic rxode2 interface still works just like past (don’t worry breaking code time). fact, can get classic rxode2 model $simulationModel ui object:","code":"library(rxode2) #> rxode2 2.1.1.9000 using 2 threads (see ?getRxThreads) #> no cache: create with `rxCreateCache()` mod1 <- function() { ini({ # central KA=2.94E-01 CL=1.86E+01 V2=4.02E+01 # peripheral Q=1.05E+01 V3=2.97E+02 # effects Kin=1 Kout=1 EC50=200 }) model({ C2 <- centr/V2 C3 <- peri/V3 d/dt(depot) <- -KA*depot d/dt(centr) <- KA*depot - CL*C2 - Q*C2 + Q*C3 d/dt(peri) <- Q*C2 - Q*C3 eff(0) <- 1 d/dt(eff) <- Kin - Kout*(1-C2/(EC50+C2))*eff }) } mod1 <- mod1() # create the ui object (can also use `rxode2(mod1)`) mod1 summary(mod1$simulationModel)"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-intro.html","id":"specify-dosing-and-sampling-in-rxode2","dir":"Articles","previous_headings":"Description of rxode2 illustrated through an example","what":"Specify Dosing and sampling in rxode2","title":"Introduction to rxode2","text":"rxode2 provides simple flexible way specify dosing sampling functions generate event table. First, empty event table generated “et()” function. interface similar NONMEM event tables: can see code, can dose compartment named rxode2 model. slight deviation NONMEM can reduce need compartment renumbering. events can also combined expanded (multi-subject events complex regimens) rbind, c, seq, rep. information creating complex dosing regimens using rxode2 see rxode2 events vignette.","code":"ev <- et(amountUnits=\"mg\", timeUnits=\"hours\") %>% et(amt=10000, addl=9,ii=12,cmt=\"depot\") %>% et(time=120, amt=2000, addl=4, ii=14, cmt=\"depot\") %>% et(0:240) # Add sampling"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-intro.html","id":"solving-odes","dir":"Articles","previous_headings":"Description of rxode2 illustrated through an example","what":"Solving ODEs","title":"Introduction to rxode2","text":"ODE can now solved using rxSolve: returns modified data frame. can see compartment values plot : , Note labels automatically labeled units initial event table. rxode2 extracts units label plot (present).","code":"x <- mod1 %>% rxSolve(ev) #> using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’ x #> ── Solved rxode2 object ── #> ── Parameters (x$params): ── #> KA CL V2 Q V3 Kin Kout EC50 #> 0.294 18.600 40.200 10.500 297.000 1.000 1.000 200.000 #> ── Initial Conditions (x$inits): ── #> depot centr peri eff #> 0 0 0 1 #> ── First part of data (object): ── #> # A tibble: 241 × 7 #> time C2 C3 depot centr peri eff #> [h] #> 1 0 0 0 10000 0 0 1 #> 2 1 44.4 0.920 7453. 1784. 273. 1.08 #> 3 2 54.9 2.67 5554. 2206. 794. 1.18 #> 4 3 51.9 4.46 4140. 2087. 1324. 1.23 #> 5 4 44.5 5.98 3085. 1789. 1776. 1.23 #> 6 5 36.5 7.18 2299. 1467. 2132. 1.21 #> # ℹ 235 more rows library(ggplot2) plot(x,C2) + ylab(\"Central Concentration\") plot(x,eff) + ylab(\"Effect\")"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-model-types.html","id":"prediction-only-models","dir":"Articles","previous_headings":"","what":"Prediction only models","title":"rxode2 additional model types","text":"Prediction models simple create. use rxode2 syntax without ODE systems . simple example one-compartment model. Solving rxode2 models saving simple ODE system, faster course.","code":"library(rxode2) ## rxode2 2.1.1.9000 using 2 threads (see ?getRxThreads) ## no cache: create with `rxCreateCache()` mod <- function(){ model({ ipre <- 10 * exp(-ke * t) }) } et <- et(seq(0,24,length.out=50)) cmt1 <- rxSolve(mod,et,params=c(ke=0.5)) ## using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’ cmt1 ## -- Solved rxode2 object -- ## -- Parameters (x$params): -- ## ke ## 0.5 ## -- Initial Conditions (x$inits): -- ## named numeric(0) ## -- First part of data (object): -- ## # A tibble: 50 x 2 ## time ipre ## ## 1 0 10 ## 2 0.490 7.83 ## 3 0.980 6.13 ## 4 1.47 4.80 ## 5 1.96 3.75 ## 6 2.45 2.94 ## # i 44 more rows"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-model-types.html","id":"solved-compartment-models","dir":"Articles","previous_headings":"","what":"Solved compartment models","title":"rxode2 additional model types","text":"Solved models also simple create. simply place linCmt() psuedo-function code. linCmt() function figures type model use based parameter names specified. often, pharmacometric models parameterized terms volume clearances. Clearances specified NONMEM-style names CL, Q, Q1, Q2, etc. distributional clearances CLD, CLD2. Volumes specified Central (VC V), Peripheral/Tissue (VP, VT). translations available, example translations : Another popular parameterization terms micro-constants. rxode2 assumes compartment 1 central compartment. elimination constant specified K, Ke Kel. example translations : last parameterization possible using alpha V //B/C. example translations : linCmt() sleuthing complete, 1, 2 3 compartment model solution used value linCmt(). compartments can dose linear solved system depot central linear absorption constant model ka. Without additional ODEs, compartments numbered depot=1 central=2. absorption constant ka missing, may dose central compartment. Without additional ODEs compartment number central=1. compartments take sort events ODE model can take, discussed rxode2 events vignette. acts ODE model; specify dose depot compartment solve system:","code":"mod <- function() { ini({ kel <- 0.5 V <- 1 }) model({ ipre <- linCmt(V, kel) }) } et <- et(amt=10,time=0,cmt=depot) %>% et(seq(0,24,length.out=50)) cmt1 <- rxSolve(mod,et) ## using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’ cmt1 ## -- Solved rxode2 object -- ## -- Parameters (x$params): -- ## kel V ## 0.5 1.0 ## -- Initial Conditions (x$inits): -- ## named numeric(0) ## -- First part of data (object): -- ## # A tibble: 50 x 2 ## time ipre ## ## 1 0 10 ## 2 0.490 7.83 ## 3 0.980 6.13 ## 4 1.47 4.80 ## 5 1.96 3.75 ## 6 2.45 2.94 ## # i 44 more rows"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-model-types.html","id":"mixing-solved-systems-and-odes","dir":"Articles","previous_headings":"","what":"Mixing Solved Systems and ODEs","title":"rxode2 additional model types","text":"addition pure ODEs, may mix solved systems ODEs. prior 2-compartment indirect response model can simplified linCmt() function: allows indirect response model assign 2-compartment model C2 variable used indirect response model. mixing solved systems ODEs, solved system’s compartment always last compartment. solved system technically isn’t compartment solved. Adding dosing compartment end interfere actual ODE solved. Therefore,two-compartment indirect response model, effect compartment compartment #1 PK dosing compartment depot compartment #2. compartment model requires new event table since compartment number changed: can solved following command: Note solving require specifying effect compartment initial condition 1. Rather, already pre-specified eff(0)=1. can solved different initial conditions easily: rxode2 detective also require specify variables linCmt() function already defined block. Therefore, following function also work solve system. Note specify parameters solving system since built model, can override parameters:","code":"library(rxode2) ## Setup example model mod1 <-function() { model({ C2 = centr/V2 C3 = peri/V3 d/dt(depot) =-KA*depot d/dt(centr) = KA*depot - CL*C2 - Q*C2 + Q*C3 d/dt(peri) = Q*C2 - Q*C3 d/dt(eff) = Kin - Kout*(1-C2/(EC50+C2))*eff }) } ## Seup parameters and initial conditions theta <- c(KA=2.94E-01, CL=1.86E+01, V2=4.02E+01, # central Q=1.05E+01, V3=2.97E+02, # peripheral Kin=1, Kout=1, EC50=200) # effects inits <- c(eff=1) ## Setup dosing event information ev <- et(amountUnits=\"mg\", timeUnits=\"hours\") %>% et(amt=10000, addl=9, ii=12) %>% et(amt=20000, addl=4, time=120, ii=24) %>% add.sampling(0:240) ## Setup a mixed solved/ode system: mod2 <- function() { model({ ## the order of variables do not matter, the type of compartmental ## model is determined by the parameters specified. C2 = linCmt(KA, CL, V2, Q, V3); eff(0) = 1 ## This specifies that the effect compartment starts at 1. d/dt(eff) = Kin - Kout*(1-C2/(EC50+C2))*eff; }) } ev <- et(amountUnits='mg', timeUnits='hours') %>% et(amt=10000, addl=9, ii=12, cmt=2) %>% et(amt=20000, addl=4, time=120, ii=24, cmt=2) %>% et(0:240) x <- mod2 %>% solve(theta, ev) ## using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’ print(x) ## -- Solved rxode2 object -- ## -- Parameters ($params): -- ## KA CL V2 Q V3 Kin Kout EC50 ## 0.294 18.600 40.200 10.500 297.000 1.000 1.000 200.000 ## -- Initial Conditions ($inits): -- ## eff ## 1 ## -- First part of data (object): -- ## # A tibble: 241 x 3 ## time C2 eff ## [h] ## 1 0 249. 1 ## 2 1 121. 1.35 ## 3 2 60.3 1.38 ## 4 3 31.0 1.28 ## 5 4 17.0 1.18 ## 6 5 10.2 1.11 ## # i 235 more rows x <- mod2 %>% solve(theta, ev,c(eff=2)) print(x) ## -- Solved rxode2 object -- ## -- Parameters ($params): -- ## KA CL V2 Q V3 Kin Kout EC50 ## 0.294 18.600 40.200 10.500 297.000 1.000 1.000 200.000 ## -- Initial Conditions ($inits): -- ## eff ## 2 ## -- First part of data (object): -- ## # A tibble: 241 x 3 ## time C2 eff ## [h] ## 1 0 249. 2 ## 2 1 121. 1.93 ## 3 2 60.3 1.67 ## 4 3 31.0 1.41 ## 5 4 17.0 1.23 ## 6 5 10.2 1.13 ## # i 235 more rows mod3 <- function() { ini({ KA <- 2.94E-01 CL <- 1.86E+01 V2 <- 4.02E+01 Q <- 1.05E+01 V3 <- 2.97E+02 Kin <- 1 Kout <- 1 EC50 <- 200 }) model({ # Since the parameters are in the ini block, put them in linCmt so # that the model is detected correctly C2 <- linCmt(KA, CL, V2, Q, V3) eff(0) <- 1 ## This specifies that the effect compartment starts at 1. d/dt(eff) <- Kin - Kout*(1-C2/(EC50+C2))*eff; }) } x <- mod3 %>% solve(ev) print(x) ## -- Solved rxode2 object -- ## -- Parameters ($params): -- ## KA CL V2 Q V3 Kin Kout EC50 ## 0.294 18.600 40.200 10.500 297.000 1.000 1.000 200.000 ## -- Initial Conditions ($inits): -- ## eff ## 1 ## -- First part of data (object): -- ## # A tibble: 241 x 3 ## time C2 eff ## [h] ## 1 0 249. 1 ## 2 1 121. 1.35 ## 3 2 60.3 1.38 ## 4 3 31.0 1.28 ## 5 4 17.0 1.18 ## 6 5 10.2 1.11 ## # i 235 more rows x <- mod3 %>% solve(c(KA=10),ev) print(x) ## -- Solved rxode2 object -- ## -- Parameters ($params): -- ## KA CL V2 Q V3 Kin Kout EC50 ## 10.0 18.6 40.2 10.5 297.0 1.0 1.0 200.0 ## -- Initial Conditions ($inits): -- ## eff ## 1 ## -- First part of data (object): -- ## # A tibble: 241 x 3 ## time C2 eff ## [h] ## 1 0 249. 1 ## 2 1 121. 1.35 ## 3 2 60.3 1.38 ## 4 3 31.0 1.28 ## 5 4 17.0 1.18 ## 6 5 10.2 1.11 ## # i 235 more rows"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-nesting.html","id":"nesting-in-rxode2","dir":"Articles","previous_headings":"","what":"Nesting in rxode2","title":"Nesting levels in rxode2","text":"one level nesting possible rxode2; example using following uncertainties sources variability:","code":""},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-nesting.html","id":"event-table","dir":"Articles","previous_headings":"Nesting in rxode2","what":"Event table","title":"Nesting levels in rxode2","text":"event table contains nesting variables: inv: investigator id id: subject id eye: eye id (left right) occ: occasion","code":"library(rxode2) #> rxode2 2.1.1.9000 using 2 threads (see ?getRxThreads) #> no cache: create with `rxCreateCache()` library(dplyr) #> #> Attaching package: 'dplyr' #> The following objects are masked from 'package:stats': #> #> filter, lag #> The following objects are masked from 'package:base': #> #> intersect, setdiff, setequal, union et(amountUnits=\"mg\", timeUnits=\"hours\") %>% et(amt=10000, addl=9,ii=12,cmt=\"depot\") %>% et(time=120, amt=2000, addl=4, ii=14, cmt=\"depot\") %>% et(seq(0, 240, by=4)) %>% # Assumes sampling when there is no dosing information et(seq(0, 240, by=4) + 0.1) %>% ## adds 0.1 for separate eye et(id=1:20) %>% ## Add an occasion per dose mutate(occ=cumsum(!is.na(amt))) %>% mutate(occ=ifelse(occ == 0, 1, occ)) %>% mutate(occ=2- occ %% 2) %>% mutate(eye=ifelse(round(time) == time, 1, 2)) %>% mutate(inv=ifelse(id < 10, 1, 2)) %>% as_tibble -> ev"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-nesting.html","id":"rxode2-model","dir":"Articles","previous_headings":"Nesting in rxode2","what":"rxode2 model","title":"Nesting levels in rxode2","text":"creates rxode2 model multi-level nesting. Note variables inv.Cl, inv.Ka, eta.Cl etc; need one variable level nesting.","code":"mod <- rxode2({ ## Clearance with individuals eff(0) = 1 C2 = centr/V2*(1+prop.sd) C3 = peri/V3 CL = TCl*exp(eta.Cl + eye.Cl + iov.Cl + inv.Cl) KA = TKA * exp(eta.Ka + eye.Ka + iov.Cl + inv.Ka) d/dt(depot) =-KA*depot d/dt(centr) = KA*depot - CL*C2 - Q*C2 + Q*C3 d/dt(peri) = Q*C2 - Q*C3 d/dt(eff) = Kin - Kout*(1-C2/(EC50+C2))*eff ef0 = eff + add.sd }) #> using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-nesting.html","id":"uncertainty-in-model-parameters","dir":"Articles","previous_headings":"Nesting in rxode2","what":"Uncertainty in Model parameters","title":"Nesting levels in rxode2","text":"","code":"theta <- c(\"TKA\"=0.294, \"TCl\"=18.6, \"V2\"=40.2, \"Q\"=10.5, \"V3\"=297, \"Kin\"=1, \"Kout\"=1, \"EC50\"=200) ## Creating covariance matrix tmp <- matrix(rnorm(8^2), 8, 8) tMat <- tcrossprod(tmp, tmp) / (8 ^ 2) dimnames(tMat) <- list(names(theta), names(theta)) tMat #> TKA TCl V2 Q V3 Kin #> TKA 0.097505124 -0.062632381 0.002185946 -0.05914820 -0.03199291 0.05191104 #> TCl -0.062632381 0.143171198 -0.008142099 0.05343880 -0.05722191 0.02899693 #> V2 0.002185946 -0.008142099 0.154042336 -0.02971687 0.05260648 -0.01051195 #> Q -0.059148203 0.053438800 -0.029716875 0.22633127 -0.03319782 -0.02766129 #> V3 -0.031992913 -0.057221913 0.052606476 -0.03319782 0.13971052 -0.05199069 #> Kin 0.051911038 0.028996932 -0.010511954 -0.02766129 -0.05199069 0.07440267 #> Kout 0.002767053 -0.029273941 0.027177995 0.05301177 -0.01928564 -0.01900449 #> EC50 0.042999966 0.029589661 0.025228785 -0.02581527 -0.06561574 0.05785742 #> Kout EC50 #> TKA 0.002767053 0.04299997 #> TCl -0.029273941 0.02958966 #> V2 0.027177995 0.02522879 #> Q 0.053011769 -0.02581527 #> V3 -0.019285641 -0.06561574 #> Kin -0.019004494 0.05785742 #> Kout 0.084064882 0.01531464 #> EC50 0.015314645 0.07068059"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-nesting.html","id":"nesting-variability","dir":"Articles","previous_headings":"Nesting in rxode2","what":"Nesting Variability","title":"Nesting levels in rxode2","text":"specify multiple levels nesting, can specify nested lotri matrix; using approach use condition operator | specify variable nesting occurs ; Bayesian simulation need specify much information parameter; rxode2 nu parameter. case: - id, nu=100 model came 100 subjects - eye, nu=200 model came 200 eyes - occ, nu=200 model came 200 occasions - inv, nu=10 model came 10 investigators specify lotri can use | var(nu=X), :","code":"omega <- lotri(lotri(eta.Cl ~ 0.1, eta.Ka ~ 0.1) | id(nu=100), lotri(eye.Cl ~ 0.05, eye.Ka ~ 0.05) | eye(nu=200), lotri(iov.Cl ~ 0.01, iov.Ka ~ 0.01) | occ(nu=200), lotri(inv.Cl ~ 0.02, inv.Ka ~ 0.02) | inv(nu=10)) omega #> $id #> eta.Cl eta.Ka #> eta.Cl 0.1 0.0 #> eta.Ka 0.0 0.1 #> #> $eye #> eye.Cl eye.Ka #> eye.Cl 0.05 0.00 #> eye.Ka 0.00 0.05 #> #> $occ #> iov.Cl iov.Ka #> iov.Cl 0.01 0.00 #> iov.Ka 0.00 0.01 #> #> $inv #> inv.Cl inv.Ka #> inv.Cl 0.02 0.00 #> inv.Ka 0.00 0.02 #> #> Properties: nu"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-nesting.html","id":"unexplained-variability","dir":"Articles","previous_headings":"Nesting in rxode2","what":"Unexplained variability","title":"Nesting levels in rxode2","text":"last piece variability specify unexplained variability","code":"sigma <- lotri(prop.sd ~ .25, add.sd~ 0.125)"},{"path":"https://nlmixr2.github.io/rxode2/articles/rxode2-nesting.html","id":"solving-the-problem","dir":"Articles","previous_headings":"Nesting in rxode2","what":"Solving the problem","title":"Nesting levels in rxode2","text":"multiple investigators study; investigator number individuals enrolled site. rxode2 automatically determines number investigators simulate effect investigator. output, inv.Cl(inv==1) inv.Cl investigator 1, inv.Cl(inv==2) inv.Cl investigator 2, etc. inv.Cl(inv==1), inv.Cl(inv==2), etc simulated study combined form investigator variability. equation form represent following: look simulated parameters can see inv.Cl(inv==1) inv.Cl(inv==2) s$params; study: eye variability occasion variability individual simulates number variables become eye occasion variability; case eye: look simulation variables (ie eye.Cl(eye==1), eye.Cl(eye==2), etc) change individual combined make eye variability occasion variability can seen pharamcometric models.","code":"s <- rxSolve(mod, theta, ev, thetaMat=tMat, omega=omega, sigma=sigma, sigmaDf=400, nStud=400) #> using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’ #> unhandled error message: EE:[lsoda] 70000 steps taken before reaching tout #> @(lsoda.c:751 #> Warning: some ID(s) could not solve the ODEs correctly; These values are #> replaced with 'NA' print(s) #> -- Solved rxode2 object -- #> -- Parameters ($params): -- #> # A tibble: 8,000 x 24 #> sim.id id `inv.Cl(inv==1)` `inv.Cl(inv==2)` `inv.Ka(inv==1)` #> #> 1 1 1 0.0561 0.00268 0.0989 #> 2 1 2 0.0561 0.00268 0.0989 #> 3 1 3 0.0561 0.00268 0.0989 #> 4 1 4 0.0561 0.00268 0.0989 #> 5 1 5 0.0561 0.00268 0.0989 #> 6 1 6 0.0561 0.00268 0.0989 #> 7 1 7 0.0561 0.00268 0.0989 #> 8 1 8 0.0561 0.00268 0.0989 #> 9 1 9 0.0561 0.00268 0.0989 #> 10 1 10 0.0561 0.00268 0.0989 #> # i 7,990 more rows #> # i 19 more variables: `inv.Ka(inv==2)` , `eye.Cl(eye==1)` , #> # `eye.Cl(eye==2)` , `eye.Ka(eye==1)` , `eye.Ka(eye==2)` , #> # `iov.Cl(occ==1)` , `iov.Cl(occ==2)` , `iov.Ka(occ==1)` , #> # `iov.Ka(occ==2)` , V2 , V3 , TCl , eta.Cl , #> # TKA , eta.Ka , Q , Kin , Kout , EC50 #> -- Initial Conditions ($inits): -- #> depot centr peri eff #> 0 0 0 1 #> #> Simulation with uncertainty in: #> * parameters ($thetaMat for changes) #> * omega matrix ($omegaList) #> #> -- First part of data (object): -- #> # A tibble: 976,000 x 21 #> sim.id id time inv.Cl inv.Ka eye.Cl eye.Ka iov.Cl iov.Ka C2 C3 #> [h]