Skip to contents

Automatically determines an appropriate maximum delay based on when a specified proportion of cases have been reported (CDF cutoff). This is useful for reducing computational burden when most cases are reported within a shorter delay window.

Usage

truncate_to_quantile(x, p = 0.99)

Arguments

x

A reporting_triangle object

p

Numeric value between 0 and 1 indicating the quantile cutoff. For example, p = 0.99 truncates to the delay at which 99% of cases have been reported. Default is 0.99.

Value

A reporting_triangle object truncated to the maximum quantile delay, or the original object if no truncation is needed

Examples

data_as_of_df <- syn_nssp_df[syn_nssp_df$report_date <= "2026-04-01", ]
# Create triangle, max_delay is automatically computed
rep_tri <- suppressMessages(as_reporting_triangle(data = data_as_of_df))

# Check the maximum delay in the triangle
ncol(rep_tri)
#> [1] 155

# Truncate to 99th percentile of reporting
rep_tri_trunc <- truncate_to_quantile(rep_tri, p = 0.99)
#>  Truncating to 136 based on 99% quantile.
#>  Truncating from max_delay = 154 to 136.
ncol(rep_tri_trunc)
#> [1] 137

# More aggressive truncation
rep_tri_trunc90 <- truncate_to_quantile(rep_tri, p = 0.90)
#>  Truncating to 62 based on 90% quantile.
#>  Truncating from max_delay = 154 to 62.
ncol(rep_tri_trunc90)
#> [1] 63