OdeModelFit | R Documentation |
The fields cmdstanr_time
, cmdstanr_summary
,
and cmdstanr_draws
store the output of cmdstanr_fit
's
methods $time()
, $summary()
, and $draws()
methods, respectively,
in memory in case cmdstanr_fit
gets corrupted (for example
if the CSV files that it reads the data from are destroyed).
model
An object of class OdeModel.
t0
Used initial time.
t
Used time points.
solver
Used solver.
data
Given additional data.
cmdstanr_fit
A cmdstanr::CmdStanMCMC or cmdstanr::CmdStanGQ object.
cmdstanr_time
A list containing output of the $time()
method
of cmdstanr_fit
.
cmdstanr_summary
A tibble containing output of the $summary()
method of cmdstanr_fit
.
cmdstanr_draws
A posterior::draws_array object containing the
output of the $draws()
method of cmdstanr_fit
.
cmdstanr_metadata
A list containing output of the $metadata()
method of cmdstanr_fit
.
cmdstanr_output
A list containing output of the $output()
method of cmdstanr_fit
.
setup_time
Time it took to call $initialize()
when the
OdeModelFit object was created (in seconds).
new()
Create an OdeModelFit object.
OdeModelFit$new(model, t0, t, solver, data, cmdstanr_fit)
model
An object of class OdeModel (will be deepcopied).
t0
Used initial time.
t
Used time points.
solver
Used solver. An object of class OdeSolver.
data
Given additional data.
cmdstanr_fit
A cmdstanr::CmdStanMCMC or cmdstanr::CmdStanGQ object (will be deepcopied).
time()
Get time information.
OdeModelFit$time()
A list.
info()
Get various information.
OdeModelFit$info()
A string.
draws()
Get draws (parameters and generated quantities).
OdeModelFit$draws(variable = NULL, iteration = NULL)
variable
Name of variable.
iteration
Index of iteration.
A posterior::draws_array object.
summary()
Get summary
OdeModelFit$summary()
A tibble
.
niterations()
Get number of post-warmup iterations per MCMC chain.
OdeModelFit$niterations()
nchains()
Get number of MCMC chains.
OdeModelFit$nchains()
ndraws()
Get total number of post-warmup draws.
OdeModelFit$ndraws()
cmdstan_seed()
Get used 'CmdStan' rng seed.
OdeModelFit$cmdstan_seed()
cmdstan_version()
Get used 'CmdStan' version.
OdeModelFit$cmdstan_version()
A string.
get_t()
Get time points where the model was fitted.
OdeModelFit$get_t(include_t0 = FALSE)
include_t0
Should the initial time point be included?
A numeric vector of length N
. If include_t0
is TRUE
, length
will be N+1
.
get_t0()
Get used initial time point t0.
OdeModelFit$get_t0()
A numeric value.
dim()
Get dimensions of a variable.
OdeModelFit$dim(variable)
variable
Name of variable.
A numeric vector, which is the 'Stan' variable dimension,
obtained as metadata$stan_variable_dims[[variable]]
, where
metadata
is the metadata of the cmdstanr::CmdStanMCMC or
cmdstanr::CmdStanGQ object.
dim_odesol()
Extract the dimensions of the ODE solution variable.
OdeModelFit$dim_odesol()
A numeric vector of length 2, where first element is the number of time points and second element is the ODE system dimension.
extract_unflattened()
Extract array variable draws so that the array is unflattened.
OdeModelFit$extract_unflattened(variable)
variable
Name of variable.
A base R array of dimension c(num_draws, ...)
where num_draws
is the total number of draws and ...
is the 'Stan' variable dimension,
obtained as self$dim(variable)
.
extract_odesol()
Extract the ODE solutions using each parameter draw, in an unflattened base R array format.
OdeModelFit$extract_odesol(include_y0 = FALSE)
include_y0
Should the initial state be included?
A base R array of dimension c(num_draws, N, D)
where
num_draws
is the total number of draws and N
is the number of
time points and D
is the number of ODE system dimensions. If
include_y0
is TRUE
, then the N
dimension grows to N+1
.
extract_y0()
Extract the ODE initial states using each parameter draw, in a base R array format.
OdeModelFit$extract_y0()
A base R array of dimension c(num_draws, D)
where
num_draws
is the total number of draws and D
is the number of ODE
system dimensions.
extract_odesol_quantile()
Extract quantiles of the ODE solutions in a base R array format.
OdeModelFit$extract_odesol_quantile(p, include_y0 = FALSE)
p
Percentile. A number between 0 and 1. For example p=0.5
corresponds to median.
include_y0
Should the initial state be included?
A base R array of dimension c(N, D)
where N
is the number of
time points and D
is the number of ODE system dimensions. If
include_y0
is TRUE
, then the N
dimension grows to N+1
.
loglik()
Extract the log likelihood using each parameter draw.
OdeModelFit$loglik()
A posterior::draws_array.
extract_odesol_df()
Extract the ODE solutions using each parameter draw, in a
flattened data frame format that is easy to pass as data
to for example ggplot2::ggplot()
.
OdeModelFit$extract_odesol_df( draw_inds = NULL, include_y0 = FALSE, ydim_names = NULL )
draw_inds
If this is not NULL
, returns ode solutions
corresponding only to given draws.
include_y0
Should the initial state be included?
ydim_names
Names of the ODE dimensioins. If NULL
, these
are automatically set as "y1"
, "y2"
, etc.
A data.frame
.
extract_odesol_df_dist()
Extract (quantiles of) the marginal distribution of ODE solutions in a
data frame format that is easy to pass as data
to for example ggplot2::ggplot()
.
OdeModelFit$extract_odesol_df_dist( probs = c(0.1, 0.5, 0.9), include_y0 = FALSE, ydim_names = NULL )
probs
The percentile values. A numeric vector where all values are between 0 and 1.
include_y0
Should the initial state be included?
ydim_names
Names of the ODE dimensions. If NULL
, these
are automatically set as "y1"
, "y2"
, etc.
A data.frame
.
plot_odesol()
A quick way to plot the ODE solutions.
OdeModelFit$plot_odesol( draw_inds = NULL, alpha = 0.75, color = "firebrick", ... )
draw_inds
If this numeric and positive, plots ODE solutions
corresponding only to given draws. If this is 0
, all draws are plotted.
If this is NULL
, a random subset of at most 100 draws are plotted.
alpha
line alpha
color
line color
...
other arguments passed to extract_odesol_df
A ggplot
object.
plot_odesol_dist()
A quick way to plot the marginal distribution of ODE solutions at each time point.
OdeModelFit$plot_odesol_dist( p = 0.8, alpha = 0.75, color = "firebrick", fill_color = "firebrick", ... )
p
Which percentage central interval to plot?
alpha
fill alpha
color
line color
fill_color
fill color
...
other arguments passed to extract_odesol_df_dist
A ggplot
object.
clone()
The objects of this class are cloneable with this method.
OdeModelFit$clone(deep = FALSE)
deep
Whether to make a deep clone.
Other model fit classes:
OdeModelGQ
,
OdeModelMCMC
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.