Skip to contents

This function takes in a integer t and a reporting triangle and generates a truncated reporting triangle, remove the last t observations.

Usage

truncate_triangle(t, matr_observed)

Arguments

t

Integer indicating the number of timepoints to truncate off the bottom of the original reporting triangle.

matr_observed

Matrix of the reporting triangle/matrix to be used to generate retrospective nowcast matrices, with rows representing the time points of reference and columns representing the delays.

Value

Matrix with t fewer rows than matr_observed.

Examples

# example code
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_rep_tri <- truncate_triangle(
  t = 1,
  matr_observed = triangle
)
print(trunc_rep_tri)
#>      [,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