Skip to contents

Estimate a delay distribution from a reporting triangle Provides an estimate of the reporting delay as a function of the delay, based on the reporting triangle and the specified maximum delay and number of reference date observations to be used in the estimation. This point estimate of the delay is computed empirically, using an iterative algorithm starting from the most recent observations. This code was adapted from code written (under an MIT license) by the Karlsruhe Institute of Technology RESPINOW German Hospitalization Nowcasting Hub. Modified from: https://github.com/KITmetricslab/RESPINOW-Hub/blob/7cce3ae2728116e8c8cc0e4ab29074462c24650e/code/baseline/functions.R#L55 #nolint

Usage

get_delay_estimate(
  triangle,
  max_delay = ncol(triangle) - 1,
  n_history = nrow(triangle)
)

Arguments

triangle

Matrix of the reporting triangle, with rows representing the time points of reference and columns representing the delays

max_delay

Integer indicating the maximum delay to estimate, in units of the delay. The default is to use the whole reporting triangle, ncol(triangle) -1.

n_history

Integer indicating the number of reference dates to be used in the estimate of the reporting delay, always starting from the most recent reporting delay. The default is to use the whole reporting triangle, so nrow(triangle)-1

Value

delay_df 0-indexed vector of length max_delay + 1 with columns indicating the point estimate of the empirical probability mass on each delay

Examples

triangle <- matrix(
  c(
    80, 50, 25, 10,
    100, 50, 30, 20,
    90, 45, 25, NA,
    80, 40, NA, NA,
    70, NA, NA, NA
  ),
  nrow = 5,
  byrow = TRUE
)
delay_pmf <- get_delay_estimate(
  triangle = triangle,
  max_delay = 3,
  n_history = 4
)
print(delay_pmf)
#> [1] 0.5029412 0.2514706 0.1455882 0.1000000