OdeModel | R Documentation |
An ODE model (R6 class). Users are not meant to instantiate
objects of this class directly, instead use the ode_model()
function
to create models.
has_likelihood
Is there a likelihood function?
stanmodel
An object of class StanModelWithCode
.
odemodeling_version
of the package used to create the model
sig_figs
Number of significant figures to use everywhere.
t_dim
A StanDimension
of the time points array.
ode_dim
A StanDimension
of the ODE system.
new()
Create an OdeModel
object.
OdeModel$new(has_likelihood, stanmodel, sig_figs, t_dim, ode_dim)
has_likelihood
Is there a likelihood function?
stanmodel
An object of class StanModelWithCode
(will be deepcopied)..
sig_figs
Number of significant figures to use in all Stan i/o.
t_dim
Time points vector dimension variable (will be deepcopied).
ode_dim
ODE system dimension variable (will be deepcopied).
compile
Should the models be compiled.
assert_stanfile_exists()
Check that the Stan model has been initialized correctly
OdeModel$assert_stanfile_exists()
reinit()
(Re)initialize the Stan model
OdeModel$reinit()
print()
Print information about the model
OdeModel$print()
code()
Get the Stan code of the model.
OdeModel$code()
make_params()
Format a vector into a draws array that can be passed to $gqs()
.
Currently works only for models with only scalar parameters.
OdeModel$make_params(x)
x
A a vector with length equal to total number of model parameters.
A posterior::draws_array object with only one chain and iteration.
gqs()
Run standalone generated quantities.
OdeModel$gqs(t0, t, data = list(), solver = rk45(), params = NULL, ...)
t0
Initial time.
t
Vector of time points.
data
Additional data.
solver
ODE solver.
params
Equal to the fitted_params
argument of the
$generate_quantities()
method of the underlying
cmdstanr::CmdStanModel object.
...
Arguments passed to the $generate_quantities()
method of the
underlying cmdstanr::CmdStanModel object.
An object of class OdeModelGQ.
sample()
Sample parameters of the model
OdeModel$sample(t0, t, data = list(), solver = rk45(), ...)
t0
Initial time point.
t
Vector of time points.
data
Other needed data as a list.
solver
An object of class OdeSolver.
...
Arguments passed to the $sample()
method of the
underlying cmdstanr::CmdStanModel object.
An object of class OdeModelMCMC.
diagnose()
Run a gradient diagnosis
OdeModel$diagnose( t0, t, data = list(), solver = rk45(), error = Inf, epsilon = 1e-06, ... )
t0
Initial time point.
t
Vector of time points.
data
Other needed data as a list.
solver
An object of class OdeSolver.
error
Error threshold.
epsilon
Perturbation size.
...
Arguments passed to the $diagnose()
method of the
underlying cmdstanr::CmdStanModel object.
Raw 'Stan' output.
sample_manyconf()
Sample parameters of the ODE model using many different ODE solver configurations
OdeModel$sample_manyconf( solvers, t0, t, data = list(), savedir = "results", basename = "odemodelfit", chains = 4, ... )
solvers
List of ODE solvers (possibly the same solver with
different configurations). See odesolvers_lists
for
creating this.
t0
Initial time point.
t
Vector of time points.
data
Other needed data as a list.
savedir
Directory where results are saved.
basename
Base name for saved files.
chains
Number of MCMC chains.
...
Additional arguments passed to the $sample()
method of the
underlying cmdstanr::CmdStanModel object.
A named list.
clone()
The objects of this class are cloneable with this method.
OdeModel$clone(deep = FALSE)
deep
Whether to make a deep clone.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.