init_epimodel: Initialize epimodel bookkeeping object.

Description Usage Arguments Value Examples

View source: R/init_epimodel.R

Description

Initializes a bookkeeping list containing the population level and subject level bookkeeping objects, measurement, and epidemic process settings. At a minimum, the epimodel object must be initialized with the states, params, rates, flow, and either the vector of observation times or a matrix with data.

Usage

1
2
3
4
5
init_epimodel(states, params, rates, flow, dat = NULL, time_var = NULL,
  obstimes = NULL, popsize = NULL, pop_mat = NULL, obs_mat = NULL,
  initdist_prior = NULL, meas_vars = NULL, r_meas_process = NULL,
  d_meas_process = NULL, covar = NULL, tcovar = NULL,
  sim_settings = NULL)

Arguments

states

character vector with names of compartments corresponding exactly to the names of compartments used in the *_rates arguments.

params

numeric vector of process parameters with element names corresponding exactly to names of parameters used in the rates arguments. The params vector must contain a number of parameters equal to the number of states for the categorical distribution for the state of a subject at t0. The names of these parameters must end in 0 - e.g. for the SIR model: S0, I0, R0. A value of zero for one of the initial distribution parameters will be interpretted as a model assumption that subjects cannot occupy that state at time t0.

rates

character vector with strings specifying the flow rates between compartments. Each variable in a rate must correspond to the name of one of the states, params, or covars (covariates not yet implemented).

flow

numeric matrix of dimension number of transitions x number of compartments. Each row corresponds to a possible transition, and each column in a row has element 1 to indicate an entry to that compartment, -1 to indicate an exit, and 0 for no change in the size of the compartment on the subject level.

dat

matrix of dimension number of observation times x number of measured compartments. dat must have one column with observation times (numeric and strictly increasing), whose the name of which is given by the times variable. The matrix must be sorted in ascending time order.

time_var

string indicating the name of the variable coding observation times in dat.

popsize

size of the population.

obs_mat

population-level bookkeeping matrix for compartment counts at observation times.

initdist_prior

vector of parameters for dirichlet prior for default categorical distribution over initial distribution at t0. Defaults to flat prior unless otherwise specified.

meas_vars

character vector specifying which compartments are measured.

r_meas_process

function to simulate from the measurement process, with named arguments state, meas_vars, and params, which are the current state of the process (given as a named character vector with element names corresponding exactly to the names of compartments), a vector with the names of the states to be measured, and a named vector of process parameters. The function should return noisy measurements of the process in a vector with named elements corresponding to each of the measured compartments specified in meas_vars. The function must index into the state vector and parameter vector using element names.

d_meas_process

function to evaluate the density of the measurement process with arguments and output specified as in r_meas_process.

covar

optional numeric matrix of time varying covariates (currently not working).

tcovar

numeric vector of times for time-varying covariates (currently not working).

sim_settings

bookkeeping list for simulation settings.

config_mat

population-level bookkeeping matrix for compartment counts and the configuration of individuals at times of state transition.

Value

list containing bookkeeping objects and model configuration objects.

Examples

1
2
3
4
epimodel <- init_epimodel(states = c("S", "I", "R"),
params = c(beta = 0.02, mu = 1, gamma = 0.5, rho = 0.5, p0 = 0.05),
rates = c("beta * I", "mu", "gamma"),
flow = matrix(c(-1, 1, 0, 0, -1, 1, 1, 0, -1), ncol = 3, byrow = T))

fintzij/BDAepimodel documentation built on Sept. 20, 2020, 1:44 p.m.