Combine observed data with a single prediction draw
Source:R/get_nowcast_pred_draws.R
combine_obs_with_pred.Rd
Internally it sums observed counts from the reporting triangle by reference time and adds them to the predicted counts to form a single draw of the nowcast for the final counts by reference time.
Arguments
- predicted_counts
Vector of predicted counts at each reference time
- 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).
- 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.
Examples
pred_counts <- c(10, 20, 30, 40)
reporting_matrix <- matrix(
c(
1, 2, 3, 4,
5, 6, 7, 8,
9, 10, 11, 12
),
nrow = 4,
byrow = TRUE
)
reporting_triangle <- generate_triangle(reporting_matrix)
combine_obs_with_pred(pred_counts, reporting_triangle)
#> [1] 16 35 45 50