I'm trying to generate the dataset for a reprex for a different issue, and for that, I'm trying to simulate a dataset. When trying to simulate the dataset, I thought that I would try using nlmixrSim(), but that doesn't seem to work. I think that the right answer is: "Bill, you're supposed to use RxODE for simulations like that." But, it would be handy if I could just use nlmixrSim() since I think it has most of the machinery built-in.
Here is the reprex of what I want to do. Ideally, either of the paths to get to simulation at the bottom would work:
library(nlmixr)
linear_twocmt_iiv_growth <- function() {
ini({
tcl <- fixed(log(0.01)) ; label("Clearance (L/kg/hr)")
tq <- fixed(log(0.05)) ; label("Intercompartmental clearance (L/kg/hr)")
tv <- fixed(log(1.5)) ; label("Volume central (L/kg)")
tv1 <- fixed(log(2)) ; label("Volume peripheral (L/kg)")
tktr <- log(c(0.00001, 0.03, 3)) ; label("Transit compartment rate (1/hr)")
slope <- c(-2, -0.02, 2) ; label("Slope on growth rate ((ng/mL)/hr)")
ltumorgrowth <- log(c(0.0001, 0.01, 1)) ; label("Baseline tumor exponential growth rate (1/hr)")
iiv_tumorgrowth ~ 0.1 ; label("Inter-individual variability in baseline tumor exponential growth rate")
prop_sd <- 0.2 ; label("Proportional error for tumor volume (fraction)")
add_sd <- 100 ; label("Additive error for tumor volume (mm^3)")
})
drake::no_deps(model({
cl <- exp(tcl)
q <- exp(tq)
v <- exp(tv)
v1 <- exp(tv1)
kcp <- q/v
kpc <- q/v1
ktr <- exp(tktr)
TUMOR(0) <- TUMORBL
d/dt(CENTRAL) = -cl/v * CENTRAL - kcp*CENTRAL + kpc*PERIPH1
d/dt(PERIPH1) = kcp*CENTRAL - kpc*PERIPH1
# unit conversion
cp <- CENTRAL/v*1000
d/dt(TRANSIT) = ktr*(cp - TRANSIT)
tumorgrowth <- exp(ltumorgrowth + iiv_tumorgrowth)
ktumor <- tumorgrowth + slope*TRANSIT
d/dt(TUMOR) = ktumor*TUMOR
TUMOR ~ add(add_sd) + prop(prop_sd)
}))
}
sim_dose <-
data.frame(
ID=1:50,
time=0,
amt=rep(seq(0, 20, by=5), each=10),
evid=1,
cmt="CENTRAL",
mdv=1,
TUMORBL=100
)
sim_obs <-
expand.grid(
ID=1:50,
time=(0:60)*24,
amt=0,
evid=0,
cmt="TUMOR",
mdv=0,
TUMORBL=100
)
sim_data <- rbind(sim_dose, sim_obs)
sim_data <- sim_data[order(sim_data$ID, sim_data$time), ]
simulation <- nlmixrSim(linear_twocmt_iiv_growth, events=sim_data)
#> Error: object of type 'closure' is not subsettable
model <- nlmixr(linear_twocmt_iiv_growth)
simulation <- nlmixrSim(model, events=sim_data)
#> Error: object of type 'closure' is not subsettable
Created on 2021-07-26 by the reprex package (v2.0.0)
I'm trying to generate the dataset for a reprex for a different issue, and for that, I'm trying to simulate a dataset. When trying to simulate the dataset, I thought that I would try using
nlmixrSim(), but that doesn't seem to work. I think that the right answer is: "Bill, you're supposed to use RxODE for simulations like that." But, it would be handy if I could just usenlmixrSim()since I think it has most of the machinery built-in.Here is the reprex of what I want to do. Ideally, either of the paths to get to
simulationat the bottom would work:Created on 2021-07-26 by the reprex package (v2.0.0)