Include condition based on simulation time

99 views
Skip to first unread message

kri...@gmail.com

unread,
Jun 2, 2017, 11:04:49 AM6/2/17
to mrgsolve
Hi Kyle and all,

I am testing a combination of two routes for a drug where the first dose is IV and the rest are oral. I have two different models read in and am trying to use conditional statement based on time of simulation to pick the model. However, it seems like mrgsolve assesses model at time 0 and then uses the same model for all sim times. Is there anyway to simulate time first and then give conditional statement based on sim time? I am currently using the following, but it is only taking the first model for all simulation times.

Thanks so much for help,
Krina

> ######################## Run Simulations ################################################
> dat1 <- data.frame(masterdat)
> head(dat1)
ID WTBL time amt rate ii addl evid cmt
1 1 70 0 500 166.66667 0 0 1 1
2 1 70 48 100 33.33333 24 25 1 1
3 2 70 0 500 166.66667 0 0 1 1
4 2 70 48 100 33.33333 24 25 1 1
5 3 70 0 500 166.66667 0 0 1 1
6 3 70 48 100 33.33333 24 25 1 1
>
> #Change to scenario if different dosing scenarios and multiple patient per scenario
> ID <- unique(unlist(dat1$ID))
>
> PickMod <- function() {if (time<48) {modIV} else {modO}}
> dosim = function(sel_name) {
+ dum <- dat1[dat1$ID == sel_name,]
+ sims <- PickMod() %>%
+ data_set(dum) %>%
+ param(WTBL=dum$WTBL[dum$time==0]) %>%
+ Req(DVPK) %>%
+ mrgsim(end=26*7*24) %>%
+ mutate(WTBL=dum$WTBL[dum$time==0]) %>%
+ as.tbl %>%
+ as.data.frame()
+ return(sims)
+ }
>
> #Number of replicates for each patient
> nRep <- 1
> out <-list()
> for(i in 1:nRep) {
+ set.seed(seed=102235, kind = "L'Ecuyer-CMRG", normal.kind=NULL)
+ result <- lapply(ID, dosim)
+ out[[i]]<-do.call(rbind,result)
+ }
There were 50 or more warnings (use warnings() to see the first 50)
>
> SimTable <- do.call(rbind,out)

Devin Pastoor

unread,
Jun 2, 2017, 11:19:52 AM6/2/17
to kri...@gmail.com, mrgsolve
Krina,

Could you post this on the github site as an issue so others can benefit when looking in the future.

The short answer to your question is simulations are tied to one model.

If the only difference between 'models' is the dosing route, you just need to change the cmt, so cmt1 is the oral depot, and cmt2 is the gut. For IV admin dose into cmt2 directly, and for oral dose to cmt1. You can, and should, just use a single model.

--
MetrumRG Website: http://www.metrumrg.com/opensourcetools.html
---
You received this message because you are subscribed to the Google Groups "mrgsolve" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mrgsolve+u...@metrumrg.com.
To post to this group, send email to mrgs...@metrumrg.com.
Visit this group at https://groups.google.com/a/metrumrg.com/group/mrgsolve/.

kri...@gmail.com

unread,
Jun 2, 2017, 11:28:54 AM6/2/17
to mrgsolve, kri...@gmail.com
thanks, Devin.

I was thinking of changing cmt as an option, but am first trying to see if it is possible to use different models. The other difference between two models is between subject variability, and I would like to incorporate that if possible. Otherwise, I will just have to use the model with higher variability for all sims.

thanks,
Krina 

Kyle Baron

unread,
Jun 2, 2017, 11:36:23 AM6/2/17
to Krina Mehta, mrgsolve
I don't know if it's a great idea or not, but you could (in a single model) make IIV dependent on the most recent dose as well ... and it should be easy if it's just first dose IV (one set of ETAs) and the rest PO (the other set of ETAs).  

But as Devin indicated, you should use one model (object) to do the simulation.  

If you would like help with making a single model, could you take it to github?


Thanks,
Kyle


To unsubscribe from this group and stop receiving emails from it, send an email to mrgsolve+unsubscribe@metrumrg.com.

To post to this group, send email to mrgs...@metrumrg.com.
Visit this group at https://groups.google.com/a/metrumrg.com/group/mrgsolve/.



--
Kyle Baron, PharmD, PhD
Senior Scientist
Metrum Research Group

Krina Mehta

unread,
Jun 2, 2017, 11:40:57 AM6/2/17
to Kyle Baron, mrgsolve
thanks, Kyle and Devin for helpful comments. I think these addressed my question and am good for now. Should I just make a copy of this email thread and post on github?

Kyle Baron

unread,
Jun 2, 2017, 11:48:41 AM6/2/17
to Krina Mehta, mrgsolve
Ok.  No need to copy into github.  Just wanted to keep going there if we were going to start sharing code etc.  

Let me us know if any other questions come up.

Kyle

Devin Pastoor

unread,
Jun 2, 2017, 12:58:00 PM6/2/17
to Kyle Baron, Krina Mehta, mrgsolve
Krina,

Also - one drug, one model. Differences in routes of dosing should not impact the model structure. If, for example, you are trying to put different IIV on CL based on oral vs IV, this is physiologically "impossible", once the drug is in systemic circulation, it should be the eliminated the same regardless of route.

Hence, your tweak should be on the parameters associated physiologically with those differences, in this case changes in bioavailability will impact relative CL/V that you are seemingly trying to implement.

Likewise, if you have formulation specific differences in IIV, these can still be encoded as covariates.

F = TVF*exp(nF*FORM_SF)

where form_SF is some scaling factor based on some reference value of 1 - eg tablet type 1 --> 1.1 tablet type 2 --> FORM_SF = 0.95

but again, the model structure remains the same




--
Kyle Baron, PharmD, PhD
Senior Scientist
Metrum Research Group




--
Kyle Baron, PharmD, PhD
Senior Scientist
Metrum Research Group

Reply all
Reply to author
Forward
0 new messages