Skip to contents

Simulates the spread of an infectious disease using the Susceptible-Infectious-Recovered (SIR) compartment model. The simulator takes a vector of specified \(R_t\) values and uses them to calculate the transmissibility of the disease at each time point. The model is then used to simulate the number of susceptible, infectious, and recovered individuals over time with disease transmission at each time point matching the pre-specified \(R_t\). The function also simulates the number of true and observed incident cases, convolving simulated incidence through a specified delay distribution and simulating from a negative binomial distribution.

Usage

simulate_sir(
  Rt = 0.5 * sin(seq_len(100)/10 * pi) + 1,
  S0 = 99000,
  I0 = 1000,
  R0 = 0,
  gamma = 0.5,
  delay_pmf = c(0.1, 0.2, 0.3, 0.4),
  k = 10,
  seed = 12345,
  date0 = as.Date("2023-01-01"),
  day_of_week = FALSE
)

Arguments

Rt

A vector of time-varying reproduction number values. Default is a modified sine curve, oscillating between 0.50 and 1.50 with a period of 20 days.

S0

Initial number of susceptible individuals

I0

Initial number of infected individuals

R0

Initial number of recovered individuals

gamma

Recovery rate, the inverse of the average infectious period

delay_pmf

Probability mass function for delay distribution. Default is a vector with mean 3.

k

Dispersion parameter for negative binomial distribution

seed

Random seed for reproducibility

date0

Start date for the simulation. Only used to add dates to outputs for use with RtGam() and friends.

day_of_week

Values to use for the day of week effect. Defaults to NULL for no effect.

Value

A list containing the time series of S, I, R, beta, true cases, true Rt, observed cases, and reference dates