Replies: 2 comments
-
HI @Ravua1992 - Changes:
library(mrgsolve)
#>
#> Attaching package: 'mrgsolve'
#> The following object is masked from 'package:stats':
#>
#> filter
library(tidyverse)
code <- '
$PARAM TVCL = 1, WT = 70, AUC50 = 20, DOSE = 100, E0 = 35, EMAX = 2.4
$OMEGA 1
$SIGMA 100
$PRED
double CL = TVCL*pow(WT/70,0.75)*exp(ETA(1));
capture AUC = DOSE/CL;
capture Y = E0*(1+EMAX*AUC/(AUC50+AUC))+EPS(1);
capture newdose= DOSE*100;
capture FLAG= 1;
capture test_dose = DOSE;
while(Y<=50) {
test_dose = test_dose*10;
AUC = test_dose / CL;
Y = E0*(1+EMAX*AUC/(AUC50+AUC))+EPS(1);
FLAG= 2;
}
'
mod <- mcode_cache("pkpd", code)
#> Building pkpd ...
#> done.
data <-
expand.grid(DOSE = c(1,50,80,110,200),ID = 1:50) %>%
mutate(WT = exp(rnorm(n(),log(80),0.01)))
data <- arrange(data, ID)
out <- mrgsim_d(mod,data,carry.out="WT,DOSE") %>% as.data.frame
summary(out$Y)
#> Min. 1st Qu. Median Mean 3rd Qu. Max.
#> 50.74 73.90 93.14 90.81 106.48 132.95
distinct(out, DOSE, test_dose)
#> DOSE test_dose
#> 1 1 100
#> 2 50 500
#> 3 80 800
#> 4 110 110
#> 5 200 200
#> 6 1 1
#> 7 50 50
#> 8 80 80
#> 9 1 10 Created on 2020-12-11 by the reprex package (v0.3.0) |
Beta Was this translation helpful? Give feedback.
0 replies
-
@Ravua1992 I converted your question to a "Discussion" ... we can interact over this in the "discussions" area of github. See: https://github.com/metrumresearchgroup/mrgsolve/discussions |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
I would like to run a simulation and optimize the dose within the simulation using pre-specified condition. I am using the example code shown below which does not run as expected. I am specifying that, if Y>50 then the dose is working, however, if Y<=50, then dose needs to be adjusted by ~100 fold and re-run the simulation to check if the new dose is able to achieve the desired response. Finally, I want to output the optimized dose for subject . I am using the code shown below however, the simulation never ends.
Any suggestions how to implement this in mrgsolve?
Thanks for considering my request
Beta Was this translation helpful? Give feedback.
All reactions