Get a draw of only the predicted elements of the nowcast vector
Source:R/get_nowcast_pred_draws.R
get_nowcast_pred_draw.Rd
Get a draw of only the predicted elements of the nowcast vector
Usage
get_nowcast_pred_draw(
point_nowcast_matrix,
reporting_triangle,
dispersion,
fun_to_aggregate = sum,
k = 1
)
Arguments
- point_nowcast_matrix
Matrix of point nowcast predictions and observations, with rows representing the reference times and columns representing the delays.
- 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).
- dispersion
Vector of dispersion parameters indexed by horizon from minus one to the maximum delay.
- fun_to_aggregate
Function that will operate along the nowcast vectors after summing across delays. Eventually, we can add things like mean, but for now since we are only providing a negative binomial observation model, we can only allow sum. Currently supported functions:
sum
.- k
Integer indicating the number of reference times to apply the
fun_to_aggregate
over to create target used to compute the nowcast errors.
Value
Vector of predicted draws at each reference time, for all reference
times in the input point_nowcast_matrix
.
Examples
point_nowcast_matrix <- matrix(
c(
80, 50, 25, 10,
100, 50, 30, 20,
90, 45, 25, 16.8,
80, 40, 21.2, 19.5,
70, 34.5, 15.4, 9.1
),
nrow = 5,
byrow = TRUE
)
reporting_triangle <- generate_triangle(point_nowcast_matrix)
disp <- c(0.8, 12.4, 9.1)
nowcast_pred_draw <- get_nowcast_pred_draw(
point_nowcast_matrix,
reporting_triangle,
disp
)
nowcast_pred_draw
#> [1] 0 0 34 46 1
# Get draws on the rolling sum
nowcast_pred_draw_agg <- get_nowcast_pred_draw(
point_nowcast_matrix,
reporting_triangle,
disp,
fun_to_aggregate = sum,
k = 2
)
nowcast_pred_draw_agg
#> [1] 0 0 12 59 0