This function summarises posterior predictives
for observed data (by report and reference date). The functionality of
this function can be used directly on the output of epinowcast()
using
the supplied summary.epinowcast()
method.
Usage
enw_pp_summary(fit, diff_obs, probs = c(0.05, 0.2, 0.35, 0.5, 0.65, 0.8, 0.95))
Arguments
- fit
A
cmdstanr
fit object.- diff_obs
A
data.frame
of observed data with at least a date variablereference_date
, and a grouping variable.group
.- probs
A vector of numeric probabilities to produce quantile summaries for. By default these are the 5%, 20%, 80%, and 95% quantiles which are also the minimum set required for plotting functions to work.
See also
Functions used for postprocessing of model fits
enw_add_latest_obs_to_nowcast()
,
enw_nowcast_samples()
,
enw_nowcast_summary()
,
enw_posterior()
,
enw_quantiles_to_long()
,
enw_summarise_samples()
Examples
fit <- enw_example("nowcast")
enw_pp_summary(fit$fit[[1]], fit$new_confirm[[1]], probs = c(0.5))
#> reference_date report_date .group max_confirm location age_group confirm
#> <IDat> <IDat> <num> <int> <fctr> <fctr> <int>
#> 1: 2021-07-13 2021-07-13 1 59 DE 00+ 21
#> 2: 2021-07-13 2021-07-14 1 59 DE 00+ 33
#> 3: 2021-07-13 2021-07-15 1 59 DE 00+ 36
#> 4: 2021-07-13 2021-07-16 1 59 DE 00+ 40
#> 5: 2021-07-13 2021-07-17 1 59 DE 00+ 43
#> ---
#> 626: 2021-08-20 2021-08-21 1 171 DE 00+ 159
#> 627: 2021-08-20 2021-08-22 1 171 DE 00+ 171
#> 628: 2021-08-21 2021-08-21 1 112 DE 00+ 69
#> 629: 2021-08-21 2021-08-22 1 112 DE 00+ 112
#> 630: 2021-08-22 2021-08-22 1 45 DE 00+ 45
#> cum_prop_reported delay new_confirm prop_reported mean median sd
#> <num> <num> <int> <num> <num> <num> <num>
#> 1: 0.3559322 0 21 0.35593220 19.639 19 8.642649
#> 2: 0.5593220 1 12 0.20338983 20.812 19 9.566932
#> 3: 0.6101695 2 3 0.05084746 6.137 6 3.627311
#> 4: 0.6779661 3 4 0.06779661 4.147 4 2.595019
#> 5: 0.7288136 4 3 0.05084746 2.396 2 1.842438
#> ---
#> 626: 0.9298246 1 61 0.35672515 79.760 76 31.667100
#> 627: 1.0000000 2 12 0.07017544 12.362 11 6.193328
#> 628: 0.6160714 0 69 0.61607143 74.098 70 30.701090
#> 629: 1.0000000 1 43 0.38392857 47.543 43 22.022605
#> 630: 1.0000000 0 45 1.00000000 40.036 37 18.937617
#> mad q50 rhat ess_bulk ess_tail
#> <num> <num> <num> <num> <num>
#> 1: 8.8956 19 0.9998578 950.1480 983.7776
#> 2: 8.8956 19 0.9996637 806.5805 667.5845
#> 3: 2.9652 6 1.0032698 967.3662 1001.0476
#> 4: 2.9652 4 0.9991688 1110.2815 975.4648
#> 5: 1.4826 2 0.9996678 896.9374 922.8697
#> ---
#> 626: 31.1346 76 1.0003079 1054.6289 881.3948
#> 627: 5.9304 11 1.0025396 998.3479 1035.5098
#> 628: 29.6520 70 0.9988369 1194.4760 1028.2922
#> 629: 19.2738 43 1.0010545 1154.8141 814.1646
#> 630: 17.7912 37 0.9993409 1159.6413 855.4762