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)
--
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/.
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, PhDSenior Scientist
Metrum Research Group
--Kyle Baron, PharmD, PhDSenior Scientist
Metrum Research Group