Skip to content

Instantly share code, notes, and snippets.

@kylebaron
Created March 19, 2018 21:57
Show Gist options
  • Save kylebaron/49ae8f663dd2664a0889a7a2b962f75e to your computer and use it in GitHub Desktop.
Save kylebaron/49ae8f663dd2664a0889a7a2b962f75e to your computer and use it in GitHub Desktop.
Bioavability

fcmt.R

kyleb Mon Mar 19 16:56:57 2018

library(mrgsolve)

code <- '
$PARAM CL = 1, V = 30, KA = 1, F1 = 0.5, F2 = 1

$PKMODEL cmt = "DEPOT CENT", depot = TRUE

$MAIN
F_DEPOT  = F1;
F_CENT  = F2;
'

mod <- mcode_cache("fcmt", code) %>% obsonly()
## Compiling fcmt ... done.

Dose to depo with F_DEPOT = 0.5, F_CENT = 1

mod %>% 
  ev(amt = 100, cmt = "DEPOT") %>%
  mrgsim(recsort = 3)
## Model:  fcmt 
## Dim:    25 x 4 
## Time:   0 to 24 
## ID:     1 
##      ID time    DEPOT  CENT
## [1,]  1    0 50.00000  0.00
## [2,]  1    1 18.39397 31.00
## [3,]  1    2  6.76676 41.39
## [4,]  1    3  2.48935 44.23
## [5,]  1    4  0.91578 44.32
## [6,]  1    5  0.33690 43.44
## [7,]  1    6  0.12394 42.22
## [8,]  1    7  0.04559 40.91

Dose to central with F_DEPOT = 0.5, F_CENT = 1

mod %>% 
  ev(amt = 100, cmt = "CENT") %>%
  mrgsim(recsort = 3)
## Model:  fcmt 
## Dim:    25 x 4 
## Time:   0 to 24 
## ID:     1 
##      ID time DEPOT   CENT
## [1,]  1    0     0 100.00
## [2,]  1    1     0  96.72
## [3,]  1    2     0  93.55
## [4,]  1    3     0  90.48
## [5,]  1    4     0  87.52
## [6,]  1    5     0  84.65
## [7,]  1    6     0  81.87
## [8,]  1    7     0  79.19

Dose to depot with F_DEPOT = 1, F_CENT = 0.5

mod %>% 
  param(F1  = 1, F2 = 0.5) %>%
  ev(amt = 100, cmt = "DEPOT") %>%
  mrgsim(recsort = 3)
## Model:  fcmt 
## Dim:    25 x 4 
## Time:   0 to 24 
## ID:     1 
##      ID time     DEPOT  CENT
## [1,]  1    0 100.00000  0.00
## [2,]  1    1  36.78794 62.00
## [3,]  1    2  13.53353 82.78
## [4,]  1    3   4.97871 88.45
## [5,]  1    4   1.83156 88.64
## [6,]  1    5   0.67379 86.87
## [7,]  1    6   0.24788 84.44
## [8,]  1    7   0.09119 81.83

Dose to cent with F_DEPOT = 1, F_CENT = 0.5

mod %>% 
  param(F1  = 1, F2 = 0.5) %>%
  ev(amt = 100, cmt = "CENT") %>%
  mrgsim(recsort = 3)
## Model:  fcmt 
## Dim:    25 x 4 
## Time:   0 to 24 
## ID:     1 
##      ID time DEPOT  CENT
## [1,]  1    0     0 50.00
## [2,]  1    1     0 48.36
## [3,]  1    2     0 46.78
## [4,]  1    3     0 45.24
## [5,]  1    4     0 43.76
## [6,]  1    5     0 42.32
## [7,]  1    6     0 40.94
## [8,]  1    7     0 39.59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment