Simulates a typical subject (no variability), as on the app's Simulation page, or a population with between-subject and residual variability, as on the Variability page.
Usage
mvp_simulate(
model,
dose = NULL,
times = mvp_times(),
params = NULL,
population = NULL,
omega = NULL,
sigma = NULL,
dose_options = NULL,
seed = 1000,
time_unit = "hours"
)Arguments
- model
A model from
mvp_model()(or an mrgsolve model, or a template id).- dose
Dosing from
mvp_dose()(several combined withc()), or an mrgsolve event object.NULLsimulates without a dose.- times
Sampling times from
mvp_times()(default: hourly to 24 h).- params
Named list of parameter values to change, e.g.
list(CL = 3).- population
NULL(default) for a typical subject without variability. A number of subjects, or a data frame frommvp_population(), for a population simulation with variability; the population's covariates (e.g.WT) replace the model parameters of the same name.- omega, sigma
Optional changes to the variability: named variances (diagonal elements), e.g.
c(ECL = 0.1), or a full matrix.- dose_options
Options for all doses from
mvp_dose_options(): weight-based dosing, conversion by molecular weight, infusion settings in the model code.NULL(default): doses as given.- seed
Random seed for the variability. The random number state of the R session is left unchanged.
- time_unit
Unit of the
TIMEADJcolumn and of plot x-axes:"hours"(default),"days","weeks"or"months"(4 weeks, as in the app), or a number to divide the model time by. The model itself runs in its own time units.
Value
An object of class mvp_sim: a list with data (the simulated
data frame: USUBJID, ID, TIME, outputs, covariates and TIMEADJ),
type ("typical" or "population"), model, events, times,
settings and population. Use mvp_plot(), mvp_exposures(),
mvp_bundle() or as.data.frame().
Details
As in the app, the output has observation records only, and
TIME is in model time units. Population simulations use mrgsolve with
5 significant digits.
Examples
# \donttest{
if (interactive()) {
mod <- mvp_model("2cmt", params = list(CL = 3, VC = 10))
sim <- mvp_simulate(mod,
dose = c(mvp_dose(100), mvp_dose(50, ii = 168, n = 12, start = 168)),
times = mvp_times(end = 13 * 168, every = 1),
population = mvp_population(100, db = "NHANES", age = c(6, 12), seed = 1000),
time_unit = "weeks")
sim
mvp_plot(sim, "CP")
}
# }