View source: R/simulated-data.R
true_cases | R Documentation |
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).
true_cases(
days_total,
Rt_function,
kappa,
serial_parameters,
initial_parameters = list(mean = 3, length = 5),
serial_max = 40
)
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 |
vector of true cases of length days_total
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.