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:
print(): Informative display with metadatasummary(): Statistics including completion, delays, and zeros
Subsetting and modification:
[and[<-: Extract or assign values with automatic validationSubsetting preserves class and attributes when result is a matrix
Package functions:
fill_triangle(): Fill missing values with zerosestimate_delay(): Extract delay distribution from triangleapply_delay(): Apply delay distribution for nowcastingtruncate_triangle(): Remove most recent rowspreprocess_negative_values(): Handle reporting corrections
See also
Reporting triangle construction and validation
[.reporting_triangle(),
[<-.reporting_triangle(),
as.data.frame.reporting_triangle(),
as.matrix.reporting_triangle(),
as_ChainLadder_triangle(),
as_reporting_triangle(),
as_reporting_triangle.data.frame(),
as_reporting_triangle.matrix(),
as_reporting_triangle.triangle(),
assert_reporting_triangle(),
get_delays_from_dates(),
get_delays_unit(),
get_max_delay(),
get_mean_delay(),
get_quantile_delay(),
get_reference_dates(),
get_report_dates(),
get_reporting_structure(),
head.reporting_triangle(),
is_reporting_triangle(),
new_reporting_triangle(),
print.reporting_triangle(),
summary.reporting_triangle(),
tail.reporting_triangle(),
truncate_to_delay(),
truncate_to_quantile(),
validate_reporting_triangle()
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
