Estimate time-varying reproduction number using Wallinga-Lipsitch method with bootstrap confidence intervals
Source:R/wallinga_lipsitch.R
wallinga_lipsitch.Rd
This function implements the Wallinga-Lipsitch method (2007) for estimating the time-varying case reproduction number (R_c) from incidence data. The case reproduction number represents the average number of secondary infections generated by cases with symptom onset at time t.
Usage
wallinga_lipsitch(
incidence,
dates,
si_mean,
si_sd,
si_dist = "gamma",
smoothing = 0,
bootstrap = FALSE,
n_bootstrap = 1000,
conf_level = 0.95,
shift = FALSE
)
Arguments
- incidence
Numeric vector of daily case counts
- dates
Vector of dates corresponding to the incidence data
- si_mean
Mean of the serial interval distribution
- si_sd
Standard deviation of the serial interval distribution
- si_dist
Distribution to use for serial interval ("gamma" or "normal")
- smoothing
Window size for smoothing estimates (0 for no smoothing)
- bootstrap
Logical; whether to compute bootstrap confidence intervals
- n_bootstrap
Number of bootstrap samples to generate
- conf_level
Confidence level for intervals (0.95 = 95% CI)
- shift
Logical; whether to shift estimates by one mean serial interval (TRUE) or not (FALSE). When TRUE, adds a 'shifted_date' column to align case reproduction number estimates with instantaneous reproduction number estimates for proper comparison.
Value
Data frame with columns:
date: Original dates from input
incidence: Daily case counts
R: Estimated case reproduction number
R_corrected: Case reproduction number with right-truncation correction
If bootstrap=TRUE:
R_lower, R_upper: Confidence intervals for R
R_corrected_lower, R_corrected_upper: Confidence intervals for R_corrected
If shift=TRUE:
shifted_date: Dates shifted forward by one mean serial interval
Details
The method works by:
Creating a pairwise comparison between all possible infector-infectee pairs
Calculating the relative likelihood that case j infected case i based on their time difference and the serial interval distribution
Aggregating these likelihoods to estimate the number of secondary cases generated by each case
Applying right-truncation correction to account for yet-unobserved secondary cases
Optionally calculating bootstrap confidence intervals by resampling individual cases
Optionally shifting the estimates forward by one serial interval (if shift=TRUE) to align with instantaneous reproduction number estimates
The function supports both gamma and normal distributions for the serial interval, smoothing of estimates, and bootstrap-based confidence intervals.