Skip to contents

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.

Usage

calculate_r_estimates(
  incidence,
  si_prob,
  dates,
  si_mean,
  si_sd,
  si_dist,
  smoothing
)

Arguments

incidence

numeric vector; daily case counts. Must be non-negative integers. Days with zero cases will have R estimates of NA

si_prob

numeric matrix; serial interval probability matrix from calculate_si_probability_matrix. Element [i,j] represents the probability that case j infected case i

dates

vector; dates corresponding to incidence data. Used for right-truncation correction calculations

si_mean

numeric; mean of the serial interval distribution in days

si_sd

numeric; standard deviation of the serial interval distribution in days

si_dist

character; distribution type for serial interval, either "gamma" or "normal"

smoothing

integer; window size for temporal smoothing (0 = no smoothing). When > 1, applies centered moving average to reduce noise

Value

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

Details

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:

  1. Computing transmission likelihoods from earlier to later cases

  2. Normalizing these likelihoods to create proper probabilities

  3. Aggregating probabilities to estimate expected secondary cases per primary case

  4. 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.

See also

wallinga_lipsitch for the main user interface, calculate_si_probability_matrix for probability matrix creation, calculate_truncation_correction for correction details