
Apply reporting structures to generate retrospective reporting triangles
Source:R/apply_reporting_structure.R
apply_reporting_structures.RdThis function applies a reporting structure to a list of truncated reporting triangles by setting observations to NA row by row from the bottom up based on the specified structure. This generates the reporting triangles that would have been available at each retrospective time point. It operates on each element in the list in order (from most recent retrospective nowcast time to oldest retrospective nowcast time).
Arguments
- truncated_reporting_triangles
List of
ntruncated reporting triangle matrices with as many rows as available given the truncation.- structure
Integer or vector specifying the reporting structure. If integer, divides columns evenly by that integer (with last possibly truncated). If vector, the sum must not be greater than or equal to the number of columns. Default is 1 (standard triangular structure).
- validate
Logical. If TRUE (default), validates the object. Set to FALSE only when called from functions that already validated.
Value
reporting_triangles List of retrospective reporting triangles,
generated by removing the bottom right observations from the truncated
reporting triangle matrices.
See also
Retrospective data generation functions
apply_reporting_structure(),
truncate_triangle(),
truncate_triangles()
Examples
# Generate retrospective triangles from truncated triangles
trunc_rts <- truncate_triangles(example_reporting_triangle, n = 2)
retro_rts <- apply_reporting_structures(trunc_rts)
# With custom structure
retro_rts_custom <- apply_reporting_structures(
trunc_rts,
structure = 2
)
retro_rts_custom
#> [[1]]
#> Reporting Triangle
#> Delays unit: days
#> Reference dates: 2024-01-01 to 2024-01-04
#> Max delay: 3
#> Structure: 1
#>
#> 0 1 2 3
#> 2024-01-01 80 50 25 10
#> 2024-01-02 100 50 20 NA
#> 2024-01-03 90 45 NA NA
#> 2024-01-04 110 NA NA NA
#>
#> [[2]]
#> Reporting Triangle
#> Delays unit: days
#> Reference dates: 2024-01-01 to 2024-01-03
#> Max delay: 3
#> Structure: 2
#>
#> 0 1 2 3
#> 2024-01-01 80 50 25 10
#> 2024-01-02 100 50 20 NA
#> 2024-01-03 90 45 NA NA
#>