This function ingests a list of point nowcast matrices and a corresponding list of truncated reporting matrices and uses both to estimate a vector of negative binomial dispersion parameters from the observations and estimates at each horizon, starting at 0 up until the max delay number of horizons.
Usage
estimate_dispersion(
pt_nowcast_mat_list,
trunc_rep_tri_list,
reporting_triangle_list,
n = length(pt_nowcast_mat_list),
fun_to_aggregate = sum,
k = 1
)
Arguments
- pt_nowcast_mat_list
List of point nowcast matrices where rows represent reference time points and columns represent delays.
- trunc_rep_tri_list
List of truncated reporting matrices, containing all observations as of the latest reference time. Elements of list are paired with elements of
pt_nowcast_mat_list
.- reporting_triangle_list
List of
n
truncated reporting triangle matrices with as many rows as available given the truncation.- n
Integer indicating the number of reporting matrices to use to estimate the dispersion parameters.
- 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 length one less than the number of columns in the latest reporting triangle, with each element representing the estimate of the dispersion parameter for each delay d, starting at delay d=1.
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)
retro_nowcasts <- generate_pt_nowcast_mat_list(retro_rts, n = 5)
disp_params <- estimate_dispersion(
pt_nowcast_mat_list = retro_nowcasts,
trunc_rep_tri_list = trunc_rts,
reporting_triangle_list = retro_rts,
n = 2
)
disp_params
#> [1] 999.999935 5.141440 3.181066
# Estimate dispersion parameters from rolling sum
disp_params_agg <- estimate_dispersion(
pt_nowcast_mat_list = retro_nowcasts,
trunc_rep_tri_list = trunc_rts,
reporting_triangle_list = retro_rts,
n = 2,
fun_to_aggregate = sum,
k = 2
)
disp_params_agg
#> [1] 820.169701 5.032175 3.181066