Skip to contents

This function ingests a list of truncated reporting triangles and iteratively generates the reporting triangle that would have been available as of the maximum reference time. It operates on each element in the list in order (from most recent retrospective nowcast time to oldest retrospective nowcast time).

Usage

generate_triangles(trunc_rep_tri_list, structure = 1)

Arguments

trunc_rep_tri_list

List of n truncated 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, must sum to number of columns. Default is 1 (standard triangular structure).

Value

reporting_triangle_list List of retrospective reporting triangles, generated by removing the bottom right observations from the truncated reporting triangle matrices.

Examples

triangle <- matrix(
  c(
    65, 46, 21, 7,
    70, 40, 20, 5,
    80, 50, 10, 10,
    100, 40, 31, 20,
    95, 45, 21, NA,
    82, 42, NA, NA,
    70, NA, NA, NA
  ),
  nrow = 7,
  byrow = TRUE
)

trunc_rts <- truncate_triangles(triangle, n = 2)
retro_rts <- generate_triangles(trunc_rts)

# With custom structure
retro_rts_custom <- generate_triangles(
  retro_rts,
  structure = 2
)
retro_rts_custom
#> [[1]]
#>      [,1] [,2] [,3] [,4]
#> [1,]   65   46   21    7
#> [2,]   70   40   20    5
#> [3,]   80   50   10   10
#> [4,]  100   40   31   NA
#> [5,]   95   45   NA   NA
#> [6,]   82   NA   NA   NA
#> 
#> [[2]]
#>      [,1] [,2] [,3] [,4]
#> [1,]   65   46   21    7
#> [2,]   70   40   20    5
#> [3,]   80   50   10   NA
#> [4,]  100   40   NA   NA
#> [5,]   95   NA   NA   NA
#>