generate_snapshots: Generates case data with snapshots of reported cases at each...

View source: R/simulated-data.R

generate_snapshotsR Documentation

Generates case data with snapshots of reported cases at each onset day

Description

Generates case data with snapshots of reported cases at each onset day

Usage

generate_snapshots(
  days_total,
  Rt_function,
  serial_parameters,
  reporting_parameters,
  thinned = FALSE,
  kappa = 1000,
  days_max_follow_up = 30,
  initial_parameters = list(mean = 30, length = 20),
  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

serial_parameters

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

reporting_parameters

either a named list of 'mean' and 'sd' of gamma distribution indicating a single reporting delay distribution for the whole period or a tibble with columns: 'time_onset', 'mean', 'sd' indicating the reporting delay distribution for each time period

thinned

a Boolean indicating whether to thin cases to only informative time points

kappa

over-dispersion parameter of negative binomial

days_max_follow_up

max days at which to simulate reporting case trajectory

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

a tibble with observed case trajectories for each time of onset

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 over-dispersion parameter
kappa <- 2

# reporting delays
r_params <- list(mean=10, sd=5)
reported_cases <- generate_snapshots(
    days_total, Rt_function,
    s_params, r_params)

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