Implements the Wallinga-Lipsitch algorithm to estimate case reproduction numbers from incidence data and serial interval probabilities. This function performs the likelihood calculations for retrospective reproduction number estimation.
calculate_r_estimates(
incidence,
si_prob,
dates,
si_mean,
si_sd,
si_dist,
smoothing
)named list with two numeric vectors of the same length as incidence:
r: Raw case reproduction number estimates. Returns NA for days
with zero cases or single-case epidemics
r_corrected: Estimates with right-truncation correction applied.
Values > 10 are capped at NA to avoid unrealistic estimates
numeric vector; daily case counts. Must be non-negative integers. Days with zero cases will have R estimates of NA
numeric matrix; serial interval probability matrix from
calculate_si_probability_matrix. Element [i,j]
represents the probability that case j infected case i
vector; dates corresponding to incidence data. Used for right-truncation correction calculations
numeric; mean of the serial interval distribution in days
numeric; standard deviation of the serial interval distribution in days
character; distribution type for serial interval, either "gamma" or "normal"
integer; window size for temporal smoothing (0 = no smoothing). When > 1, applies centered moving average to reduce noise
The algorithm calculates the probability that each earlier case infected each later case based on their time difference and the serial interval distribution. These probabilities are then aggregated to estimate the expected number of secondary cases generated by cases on each day.
The Wallinga-Lipsitch method works by:
Computing transmission likelihoods from earlier to later cases
Normalizing these likelihoods to create proper probabilities
Aggregating probabilities to estimate expected secondary cases per primary case
Applying right-truncation correction for cases near the observation end
The right-truncation correction accounts for the fact that cases near the end of the observation period may have generated secondary cases that occur after data collection ended.
wallinga_lipsitch for the main user interface,
calculate_si_probability_matrix for probability matrix creation,
calculate_truncation_correction for correction details