# NOT RUN {
# }
# NOT RUN {
# dynmodel example --------------------------------------------------------
ode <- "
kel = CL/V;
d/dt(X) = -kel*X;
C=X/V;
PRED = C
"
ode_system <- RxODE(model = ode)
model_error_structure <- cp ~ C + add(0.01) + prop(0.01)
inits <- c(CL = 1, V = 10)
control <- dynmodelControl(method = "Nelder-Mead")
fit <-
try(dynmodel(
system = ode_system,
model = model_error_structure,
data = Bolus_1CPT,
inits = inits,
control = control
))
# nlmixr model example ----------------------------------------------------------
model_onecmt_bolus <- function() {
ini({
CL <- c(0, 5, 10) # Clearance (L/hr)
V <- c(0, 50, 100) # Volume of Distribution
prop.err <- c(0, 0.01, 1)
})
model({
kel <- CL / V
d / dt(X) <- -kel * X
cp <- X / V
cp ~ prop(prop.err)
})
}
# note on some platforms this fit is not successful
fit <- try(nlmixr(object = model_onecmt_bolus, data = Bolus_1CPT, est = "dynmodel"))
if (inherits(fit, "nlmixrDynmodel")) {
as.dynmodel(fit)
}
# method = "focei" is slightly more flexible and well tested
fit <- try(nlmixr(object = model_onecmt_bolus, data = Bolus_1CPT, est = "focei"))
# }
Run the code above in your browser using DataLab