Learn R Programming

baselinenowcast (version 0.2.0)

estimate_and_apply_delay: Estimate and apply delay from a reporting triangle

Description

This function generates a point nowcast by estimating a delay distribution from the reporting triangle and applying it to complete the triangle. If a delay distribution is specified, this will be used to generate the nowcast, otherwise, a delay distribution will be estimated from the reporting_triangle.

Usage

estimate_and_apply_delay(
  reporting_triangle,
  n = nrow(reporting_triangle),
  delay_pmf = NULL,
  validate = TRUE
)

Value

pt_nowcast_matrix A reporting_triangle object of point nowcasts with the same structure as the input

Arguments

reporting_triangle

A reporting_triangle object with rows representing reference times and columns representing delays. Can be a reporting matrix or incomplete reporting matrix. Can also be a ragged reporting triangle, where multiple columns are reported for the same row (e.g., weekly reporting of daily data).

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(reporting_triangle).

delay_pmf

Vector of delays assumed to be indexed starting at the first delay column in reporting_triangle. Default is NULL, which will estimate a delay from the reporting_triangle.

validate

Logical. If TRUE (default), validates the object. Set to FALSE only when called from functions that already validated.

See Also

High-level workflow wrapper functions allocate_reference_times(), estimate_and_apply_delays(), estimate_and_apply_uncertainty(), estimate_uncertainty_retro()

Examples

Run this code
# Estimate and apply delay using default parameters
pt_nowcast_matrix <- estimate_and_apply_delay(
  reporting_triangle = example_reporting_triangle
)
pt_nowcast_matrix

# Use downward correction example with specific rows for delay estimation
pt_nowcast_matrix <- estimate_and_apply_delay(
  reporting_triangle = example_downward_corr_rt,
  n = 5
)
pt_nowcast_matrix

# Provide a pre-computed delay PMF
delay_pmf <- estimate_delay(
  reporting_triangle = example_reporting_triangle
)
pt_nowcast_matrix <- estimate_and_apply_delay(
  reporting_triangle = example_reporting_triangle,
  delay_pmf = delay_pmf
)
pt_nowcast_matrix

Run the code above in your browser using DataLab