Skip to contents

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 variable reference_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.

Value

A data.table summarising the posterior predictions.

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
#>   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
#>   1:         0.3559322     0          21    0.35593220  23.512   22.0  9.740572
#>   2:         0.5593220     1          12    0.20338983  11.574   11.0  5.158016
#>   3:         0.6101695     2           3    0.05084746   6.492    6.0  3.540405
#>   4:         0.6779661     3           4    0.06779661   4.672    4.0  2.726509
#>   5:         0.7288136     4           3    0.05084746   2.765    3.0  1.896674
#>  ---                                                                           
#> 626:         0.9298246     1          61    0.35672515  47.044   43.5 19.194491
#> 627:         1.0000000     2          12    0.07017544  15.098   14.0  6.970867
#> 628:         0.6160714     0          69    0.61607143 109.043  100.0 45.345136
#> 629:         1.0000000     1          43    0.38392857  27.749   26.0 12.245814
#> 630:         1.0000000     0          45    1.00000000  52.151   49.0 23.805565
#>          mad   q50      rhat  ess_bulk  ess_tail
#>   1:  8.8956  22.0 0.9987800 1164.0127  834.6738
#>   2:  4.4478  11.0 0.9988065 1016.1220 1032.3776
#>   3:  2.9652   6.0 1.0010941  942.2827  975.7223
#>   4:  2.9652   4.0 1.0017034  817.9688  782.9234
#>   5:  1.4826   3.0 1.0007183  982.1315  914.5297
#>  ---                                            
#> 626: 17.0499  43.5 1.0056592  975.5135  913.8415
#> 627:  5.9304  14.0 0.9986250  910.5990 1033.0860
#> 628: 38.5476 100.0 1.0011913  989.3871  933.3896
#> 629: 11.8608  26.0 1.0000296  916.6473  922.1847
#> 630: 22.2390  49.0 0.9997764 1035.8098  904.4781