simulate_stem: Simulations from a stochastic epidemic model.

View source: R/simulate_stem.R

simulate_stemR Documentation

Simulations from a stochastic epidemic model.

Description

Simulations from a stochastic epidemic model.

Usage

simulate_stem(
  stem_object,
  nsim = 1,
  simulation_parameters = NULL,
  lna_draws = NULL,
  tparam_draws = NULL,
  tparam_values = NULL,
  paths = FALSE,
  full_paths = FALSE,
  observations = FALSE,
  method = "gillespie",
  tmax = NULL,
  census_times = NULL,
  max_attempts = 500,
  lna_method = "exact",
  lna_bracket_width = 2 * pi,
  ess_warmup = 100,
  messages = TRUE
)

Arguments

stem_object

stem object list

nsim

number of realizations to simulate

simulation_parameters

optional list of vectors of simulation parameters. If NULL, paths are simulated using the parameters specified in the stem object.

lna_draws

optional list of matrices of lna draws

tparam_draws

optional list of lists of time-varying parameter draws

paths

Should population-level paths at census times be returned?

full_paths

Should complete population level paths be returned (only for Gillespie), defaults to FALSE

observations

Should simulated observations be returned? Requires that a measurement process be defined in the stem object.

method

either "gillespie" if simulating via Gillespie's direct method, "lna" if simulating paths via the linear noise approximation, or "ode" if simulating paths of the deterministic limit of the underlying Markov jump process.

tmax

the time at which simulation of the system is terminated. Defaults to the last observation time if not supplied.

census_times

vector of times at which compartment counts should be recorded.

max_attempts

maximum number of times to attempt simulating an LNA path before aborting due to the moments of the path being degenerate at some point

lna_method

defaults to "exact". If "approx", an initial path is proposed by resampling perturbations that lead to negative increments or volumes. The initial path is then updated via elliptical slice sampling

lna_bracket_width

initial elliptical slice sampling bracket width to be used if lna_method == "approx"

ess_warmup

number of elliptical slice sampling updates before the lna sample is saved

messages

should a message be printed when parsing the rates?

Value

Returns a list with the simulated paths, subject-level paths, and/or datasets. If paths = FALSE and observations = FALSE, or if paths = TRUE and observations = TRUE, a list nsim stem paths and datasets, each returned either as a list or array, is returned.

If paths = TRUE and observations = FALSE, a list or array of simulated population-level paths is returned.

If paths = FALSE and observations = TRUE, a list or array of simulated datasets is returned.


fintzij/stemr documentation built on March 25, 2022, 12:25 p.m.