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
build_ord_obs()
,
enw_add_latest_obs_to_nowcast()
,
enw_nowcast_samples()
,
enw_nowcast_summary()
,
enw_posterior()
,
enw_quantiles_to_long()
,
enw_summarise_samples()
,
subset_obs()
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.818 18 8.997768
#> 2: 0.5593220 1 12 0.20338983 20.808 19 9.249903
#> 3: 0.6101695 2 3 0.05084746 5.894 5 3.385887
#> 4: 0.6779661 3 4 0.06779661 4.209 4 2.753707
#> 5: 0.7288136 4 3 0.05084746 2.454 2 1.870664
#> ---
#> 626: 0.9298246 1 61 0.35672515 80.300 75 34.009714
#> 627: 1.0000000 2 12 0.07017544 12.721 12 6.182182
#> 628: 0.6160714 0 69 0.61607143 75.275 71 32.177737
#> 629: 1.0000000 1 43 0.38392857 47.607 45 21.042085
#> 630: 1.0000000 0 45 1.00000000 40.819 38 19.833043
#> mad q50 rhat ess_bulk ess_tail
#> <num> <num> <num> <num> <num>
#> 1: 8.8956 18 1.0019355 1061.4434 992.3891
#> 2: 8.8956 19 1.0042792 666.2820 963.7879
#> 3: 2.9652 5 1.0005725 1045.8014 911.8297
#> 4: 2.9652 4 0.9990272 883.7513 983.1110
#> 5: 1.4826 2 0.9998082 968.8058 951.5574
#> ---
#> 626: 31.1346 75 1.0054516 1084.5743 947.1035
#> 627: 5.9304 12 1.0001721 1002.8719 967.7479
#> 628: 29.6520 71 1.0006111 1053.0376 977.8959
#> 629: 19.2738 45 1.0053457 947.7744 832.7111
#> 630: 17.7912 38 0.9990299 1049.2785 994.5472