Compute "Rt" for a single simulated trajectory and parameter set.

lancelot_Rt(
  time,
  S,
  p,
  prob_strain = 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
)

Arguments

time

A vector of time steps that the model was run over

S

A (n groups x n vaccine classes) x steps matrix of "S" compartment counts

p

A lancelot_parameters() object

prob_strain

A (n groups x n strains) x n time steps matrix of "prob_strain" outputs from the model. For a 2 strain model for example, prob_strain[1, j] and prob_strain[n_groups + 1, j] should give, for the j^th time step, the probabilities that new infections in group 1 are of strains 1 and 2 respectively. The default is NULL, but it must be specified if there is more than one strain

type

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

interpolate_every

Spacing (in days) to use between interpolated points

interpolate_critical_dates

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].

interpolate_min

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.

eigen_method

The eigenvalue method to use (passed to eigen1::eigen1 as method)

R

A (n groups x n strains x n vaccine classes) x time steps matrix of "R" compartment counts, required for multi-strain models.

weight_Rt

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.

keep_strains_Rt

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.

Value

A list with elements time, beta, and any of the type

values specified above.