Runs model over the event table events with the parameters
params, and returns the compartments and the model's outputs at every
observation record. Nothing is drawn at random: this is the
deterministic core that the population simulation builds on.
Usage
pmx_ode_solve(model, events, params = double())Arguments
- model
A model from
pmx_ode_model().- events
An event table: from
pmx_ode_events(), or a NONMEM-style data frame with columnsID,TIME,EVID,AMT,CMT,RATE,DUR,II,ADDLandSS(any case; all butTIMEoptional). With noEVID, a record with anAMTabove 0 is a dose, one withMDV1 marks a time (EVID2), and the rest are observations; givenEVID,MDVis not read.CMTis a compartment's name or number. Columns named like a model parameter are covariates, each record carrying its value; other columns, such asDV, are ignored.- params
The model's parameters, a named numeric vector. A covariate column of
eventstakes the place of its parameter.
Value
A data frame with id, time, one column per compartment and
one per model output, one row per observation record.
Errors
pmx_ode_error_events for a record that breaks a rule of the event
table, naming the row; pmx_ode_error_argument for a parameter with no
value; pmx_ode_error_solver for a closed-form model whose rate
constants are not positive.
Warnings
pmx_ode_warning_solver when the solver fails for a subject: that
subject's outputs are NA from where it failed, and the others are
solved (design §8). pmx_ode_warning_steady_state when a steady state
of a model with no closed form does not converge.
Examples
m <- pmx_ode_model({
cl <- exp(tcl); v <- exp(tv); ka <- exp(tka)
cp <- linCmt()
})
ev <- pmx_ode_events(amt = 100, ii = 24, addl = 6, cmt = "depot",
time = seq(0, 168, by = 12))
head(pmx_ode_solve(m, ev, params = c(tcl = 0, tv = 3, tka = -0.7)))
#> id time depot central cl v ka cp
#> 1 1 0 100.0000000 0.00000 1 20.08554 0.4965853 0.000000
#> 2 1 12 0.2582432 60.86565 1 20.08554 0.4965853 3.030322
#> 3 1 24 100.0006669 33.64642 1 20.08554 0.4965853 1.675157
#> 4 1 36 0.2582449 79.37885 1 20.08554 0.4965853 3.952040
#> 5 1 48 100.0006669 43.83267 1 20.08554 0.4965853 2.182300
#> 6 1 60 0.2582449 84.98348 1 20.08554 0.4965853 4.231079