true_cases: Generate true case series

View source: R/simulated-data.R

true_casesR Documentation

Generate true case series

Description

Cases are assumed to be generated by a negative-binomial renewal process:

cases_t \sim neg-binomial(Rt \sum_s=1^\infty w(s) cases_t-s, kappa)

where kappa is the over-dispersion parameter. Here, we truncate this sum at a user specified lag (determined by the length of the weight vector).

Usage

true_cases(
  days_total,
  Rt_function,
  kappa,
  serial_parameters,
  initial_parameters = list(mean = 3, length = 5),
  serial_max = 40
)

Arguments

days_total

number of days to simulate process for (post-initial period)

Rt_function

takes day as an input and outputs an Rt value

kappa

over-dispersion parameter of negative binomial

serial_parameters

named list of 'mean' and 'sd' of gamma distribution characterising the serial interval distribution

initial_parameters

a named list of 'mean' and 'length' which is used to generate seed cases by sampling from a negative binomial distribution

serial_max

maximum point at which to truncate sum in renewal process

Value

vector of true cases of length days_total

Examples

library(incidenceinflation)
# generate case series for 100 days with time-varying Rt
days_total <- 100

# make Rt interpolation function
v_Rt <- c(rep(1.3, 25), rep(1, 25), rep(2, 50))
Rt_function <- stats::approxfun(1:days_total, v_Rt)

# serial interval parameters
s_params <- list(mean=5, sd=1)

# renewal parameter
kappa <- 2
cases <- true_cases(days_total, Rt_function, kappa, s_params)

ben18785/incidenceinflation documentation built on Feb. 8, 2024, 2:36 a.m.