This function ingests a reporting triangle/matrix and the number of
truncated reporting triangles we want to create, n
, and iteratively
truncates the reporting triangle, working from the latest reference time
(bottom) to the older reference times (top) for n
snapshots.
Arguments
- reporting_triangle
Matrix of the reporting triangle, with rows representing the time points of reference and columns representing the delays. Can be a reporting matrix or incomplete reporting matrix. Can also be a ragged reporting triangle, where multiple columns are reported for the same row. (e.g. weekly reporting of daily data).
- n
Integer indicating the number of retrospective truncated triangles to be generated, always starting from the most recent reference time. Default is to generate truncated matrices for all triangles that would have a sufficient number of rows to generate a nowcast from.
Value
trunc_rep_tri_list
List of n
truncated reporting triangle
matrices with as many rows as available given the truncation, and the same
number of columns as reporting_triangle
.
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
)
truncated_rts <- truncate_triangles(triangle, n = 2)
truncated_rts[1:2]
#> [[1]]
#> [,1] [,2] [,3] [,4]
#> [1,] 65 46 21 7
#> [2,] 70 40 20 5
#> [3,] 80 50 10 10
#> [4,] 100 40 31 20
#> [5,] 95 45 21 NA
#> [6,] 82 42 NA NA
#>
#> [[2]]
#> [,1] [,2] [,3] [,4]
#> [1,] 65 46 21 7
#> [2,] 70 40 20 5
#> [3,] 80 50 10 10
#> [4,] 100 40 31 20
#> [5,] 95 45 21 NA
#>