Compute "Rt" for a set of simulated trajectories (e.g., the result
of the $iterate()
method of lancelot, mcstate::pmcmc()
or
mcstate::pmcmc_predict()
. The trajectories may or may not share
parameters.
lancelot_Rt_trajectories(
time,
S,
pars,
prob_strain = NULL,
initial_time_from_parameters = TRUE,
shared_parameters = NULL,
type = NULL,
interpolate_every = NULL,
interpolate_critical_dates = NULL,
interpolate_min = NULL,
eigen_method = "power_iteration",
R = NULL,
weight_Rt = FALSE,
keep_strains_Rt = FALSE
)
A vector of time steps
A 3d ((n groups x n vaccine classes) x n trajectories x n time steps) array of "S" compartment counts
Either a single lancelot_parameters()
object
(shared parameters) or an unnamed list of
lancelot_parameters()
objects, the same length as ncol(S)
.
A 3d ((n groups x n strains) x n trajectories x n time
steps) array of "prob_strain" model outputs. Default is NULL
, but it
must be specified if there is more than one strain.
If TRUE
, then time[[1]]
is
replaced by the value of initial_time
from the parameters.
This is usually what you want. (From sircovid 0.12.13 this
parameter means "initial time is zero" and will probably be
updated in a future version).
Should pars
be treated as a single
shared list? Leave as NULL
to detect automatically, set to
TRUE
or FALSE
to force it to be interpreted one way or the
other which may give more easily interpretable error messages.
A character vector of possible Rt types to
compute. Can be any or all of eff_Rt_all
, eff_Rt_general
,
Rt_all
and Rt_general
Spacing (in days) to use between interpolated points
Optional vector of critical sircovid
dates to use when interpolating. Interpolation will be done in
blocks between the first time step of these dates, with each block
starting on the first time step of the date given.
So if you give a interpolate_critical_dates
of c(20, 50)
then blocks start on first time step of days 20 and 50,
i.e.: [1, 20)
, [20, 50)
, [50, end]
.
The minimum number of steps to include
within a block. If there are fewer points than this then all
points are used (i.e., no interpolation is done) or
interpolate_every
is reduced until at least this many points
were used. This can be used to specify a lower bound on the
error of small regions. If Rt is small it won't matter that
much. You do need to specify something though or interpolation
will not happen, and do not use less than 3 as we use spline
interpolation and that will not work with fewer than 3 points.
The eigenvalue method to use (passed to
eigen1::eigen1 as method
)
A 3d ((n groups x n strains x n vaccine classes) x n trajectories x n time steps) array of "R" compartment counts, required for multi-strain models.
If TRUE
then computes the weighted average
of the Rt for all strains, otherwise all calculations are returned with
an additional dimension to index each strain.
Additional argument for when weight_Rt
is TRUE
(has no impact otherwise). If TRUE
, then the Rt for each strain is
returned along with the weighted average, otherwise just the weighted
average is returned. When TRUE
, the dimension indexing these lists
strains first, and then the weighted average.
As for lancelot_Rt()
, except that every element is a
matrix, not a vector.