-
Hello, How do I get time since first dose in the model ? Thank you! |
Beta Was this translation helpful? Give feedback.
Answered by
kylebaron
Oct 26, 2023
Replies: 1 comment 1 reply
-
Hi @Ravua1992 - There isn't anything baked into mrgsolve to do time since first dose; but here's some code if you did want to derived it inside the model. This might be more easily done after you simulate but you can do it in the model too. Kyle library(mrgsolve)
#>
#> Attaching package: 'mrgsolve'
#> The following object is masked from 'package:stats':
#>
#> filter
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
code <- '
$PKMODEL cmt = "CENT"
$PARAM CL = 1, V = 20
$PK
if(NEWIND <=1) double tofd = -1;
if(EVID == 1 && tofd < 0) tofd = TIME;
$ERROR
capture TAFD = tofd >= 0 ? TIME - tofd : 0;
'
mod <- mcode("tafd", code)
#> Building tafd ...
#> done.
mod %>%
ev(amt = 100, time = 12, ii = 24, addl = 2) %>%
mrgsim(end = 144) %>%
plot() Created on 2023-10-26 with reprex v2.0.2 |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
Ravua1992
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @Ravua1992 -
There isn't anything baked into mrgsolve to do time since first dose; but here's some code if you did want to derived it inside the model. This might be more easily done after you simulate but you can do it in the model too.
Kyle