Skip to contents

A reporting_triangle object contains the data and metadata needed for nowcasting.

Structure

A reporting_triangle is a matrix with class c("reporting_triangle", "matrix"):

  • Rows: Reference dates

  • Columns: Delays (0, 1, 2, ...)

  • Entries: Incident cases at each reference date and delay

  • Row names: Reference dates as character

  • Column names: Delays as character

Attributes:

  • delays_unit: Character ("days", "weeks", "months", "years")

Reference dates are stored as row names and can be extracted using get_reference_dates(). The maximum delay can be obtained using get_max_delay(). The structure can be computed using get_reporting_structure(). See the corresponding as_reporting_triangle.matrix() and as_reporting_triangle.data.frame() functions for more details on the required input formats to generate the object.

Working with reporting triangles

Reporting triangle objects provide:

Inspection and display:

Subsetting and modification:

  • [ and [<-: Extract or assign values with automatic validation

  • Subsetting preserves class and attributes when result is a matrix

Package functions:

Examples

# Create a reporting triangle from data
data <- syn_nssp_df[syn_nssp_df$report_date <= "2026-04-01", ]
rep_tri <- as_reporting_triangle(data = data)
#>  Using max_delay = 154 from data

# Use with low-level functions
filled <- fill_triangle(rep_tri)
delay_pmf <- estimate_delay(rep_tri)
nowcast <- apply_delay(rep_tri, delay_pmf)

# Direct matrix operations
total_by_date <- rowSums(rep_tri, na.rm = TRUE)
total_by_delay <- colSums(rep_tri, na.rm = TRUE)

# Subsetting and inspection
recent <- tail(rep_tri, n = 10)
summary(rep_tri)
#> Reporting Triangle Summary
#> Dimensions: 159 x 155
#> Reference period: 2025-10-25 to 2026-04-01
#> Max delay: 154 days
#> Structure: 1
#> Most recent complete date: 2025-10-29 (442 cases)
#> Dates requiring nowcast: 154 (complete: 5)
#> Rows with negatives: 0
#> Zeros: 9905 (77.9% of non-NA values)
#> Zeros per row summary:
#>    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
#>     0.0    18.5    63.0    62.3   100.5   145.0 
#> 
#> Mean delay summary (complete rows):
#>    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
#>   3.615   4.298   4.416   4.414   4.679   5.059 
#> 
#> 99% quantile delay (complete rows):
#>    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
#>    22.0    31.0    31.0    33.4    34.0    49.0