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(
  reporting_triangle,
  max_delay = ncol(reporting_triangle) - 1,
  n = nrow(reporting_triangle)
)

Arguments

reporting_triangle

Matrix of the reporting triangle, with rows representing the time points of reference and columns representing the delays. Can be a reporting matrix or incomplete reporting matrix.

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

Integer indicating the number of reference times (observations) 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).

Value

Vector indexed at 0 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(
  reporting_triangle = triangle,
  max_delay = 3,
  n = 4
)
print(delay_pmf)
#> [1] 0.5029412 0.2514706 0.1455882 0.1000000