Add the latest observations to the nowcast output. This is useful for plotting the nowcast against the latest observations.
Arguments
- nowcast
A
data.frame
of nowcast output fromenw_nowcast_summary()
.- obs
An observation
data.frame
containingreference_date
columns of the same length as the number of rows in the posterior and the most up to date observation for each date. This is used to align the posterior with the observations. The easiest source of this data is the output of latest output ofenw_preprocess_data()
orenw_latest_data()
.
See also
Functions used for postprocessing of model fits
enw_nowcast_samples()
,
enw_nowcast_summary()
,
enw_posterior()
,
enw_pp_summary()
,
enw_quantiles_to_long()
,
enw_summarise_samples()
Examples
fit <- enw_example("nowcast")
obs <- enw_example("obs")
nowcast <- summary(fit, type = "nowcast")
enw_add_latest_obs_to_nowcast(nowcast, obs)
#> reference_date .group latest_confirm confirm report_date max_confirm
#> 1: 2021-08-03 1 156 149 2021-08-22 149
#> 2: 2021-08-04 1 183 166 2021-08-22 166
#> 3: 2021-08-05 1 147 133 2021-08-22 133
#> 4: 2021-08-06 1 155 137 2021-08-22 137
#> 5: 2021-08-07 1 159 139 2021-08-22 139
#> 6: 2021-08-08 1 119 97 2021-08-22 97
#> 7: 2021-08-09 1 65 58 2021-08-22 58
#> 8: 2021-08-10 1 204 175 2021-08-22 175
#> 9: 2021-08-11 1 275 233 2021-08-22 233
#> 10: 2021-08-12 1 273 237 2021-08-22 237
#> 11: 2021-08-13 1 270 204 2021-08-22 204
#> 12: 2021-08-14 1 262 189 2021-08-22 189
#> 13: 2021-08-15 1 192 125 2021-08-22 125
#> 14: 2021-08-16 1 140 98 2021-08-22 98
#> 15: 2021-08-17 1 323 242 2021-08-22 242
#> 16: 2021-08-18 1 409 223 2021-08-22 223
#> 17: 2021-08-19 1 370 202 2021-08-22 202
#> 18: 2021-08-20 1 361 171 2021-08-22 171
#> 19: 2021-08-21 1 339 112 2021-08-22 112
#> 20: 2021-08-22 1 258 45 2021-08-22 45
#> location age_group cum_prop_reported delay prop_reported mean median
#> 1: DE 00+ 1 19 0.000000000 149.000 149.0
#> 2: DE 00+ 1 18 0.000000000 167.453 167.0
#> 3: DE 00+ 1 17 0.000000000 135.677 135.0
#> 4: DE 00+ 1 16 0.000000000 140.896 141.0
#> 5: DE 00+ 1 15 0.007194245 145.222 145.0
#> 6: DE 00+ 1 14 0.000000000 103.248 103.0
#> 7: DE 00+ 1 13 0.000000000 62.742 62.0
#> 8: DE 00+ 1 12 0.000000000 185.065 185.0
#> 9: DE 00+ 1 11 0.000000000 255.574 255.0
#> 10: DE 00+ 1 10 0.004219409 266.480 266.0
#> 11: DE 00+ 1 9 0.000000000 235.082 235.0
#> 12: DE 00+ 1 8 0.015873016 229.150 229.0
#> 13: DE 00+ 1 7 0.040000000 163.327 163.0
#> 14: DE 00+ 1 6 0.010204082 130.404 130.0
#> 15: DE 00+ 1 5 0.012396694 299.890 299.0
#> 16: DE 00+ 1 4 0.017937220 303.138 301.0
#> 17: DE 00+ 1 3 0.019801980 311.131 309.0
#> 18: DE 00+ 1 2 0.070175439 318.522 315.0
#> 19: DE 00+ 1 1 0.383928571 334.231 327.5
#> 20: DE 00+ 1 0 1.000000000 322.430 306.0
#> sd mad q5 q20 q35 q50 q65 q80 q95 rhat
#> 1: 0.000000 0.0000 149 149.0 149.00 149.0 149.00 149.0 149.00 NA
#> 2: 1.291301 1.4826 166 166.0 167.00 167.0 168.00 168.0 170.00 1.0002481
#> 3: 1.853674 1.4826 133 134.0 135.00 135.0 136.00 137.0 139.00 0.9986872
#> 4: 2.169768 2.9652 138 139.0 140.00 141.0 142.00 143.0 145.00 0.9999757
#> 5: 2.760133 2.9652 141 143.0 144.00 145.0 146.00 147.0 150.00 1.0007676
#> 6: 2.893591 2.9652 99 101.0 102.00 103.0 104.00 106.0 109.00 0.9991973
#> 7: 2.412313 2.9652 59 61.0 62.00 62.0 63.00 65.0 67.00 1.0036034
#> 8: 3.687054 4.4478 180 182.0 183.00 185.0 186.00 188.0 191.00 0.9989872
#> 9: 6.079925 5.9304 246 251.0 253.00 255.0 258.00 261.0 266.00 0.9991648
#> 10: 7.480345 7.4130 255 260.0 263.00 266.0 269.00 272.0 279.05 1.0073591
#> 11: 7.671123 7.4130 224 228.0 232.00 235.0 237.35 241.0 248.00 1.0012317
#> 12: 9.532280 10.3782 215 221.0 225.00 229.0 232.00 237.0 246.00 0.9999872
#> 13: 8.941478 8.8956 149 155.0 159.00 163.0 166.00 171.0 178.00 0.9994459
#> 14: 8.343284 8.8956 118 123.0 127.00 130.0 133.00 137.0 145.00 1.0012796
#> 15: 12.795923 13.3434 280 289.0 294.00 299.0 304.00 310.2 322.00 1.0017171
#> 16: 17.375755 17.0499 278 288.8 295.00 301.0 308.00 317.0 334.05 1.0055266
#> 17: 24.503638 23.7216 275 291.0 300.65 309.0 317.35 329.0 356.00 1.0105072
#> 18: 34.923992 34.0998 270 288.8 303.00 315.0 330.00 343.2 383.00 1.0047446
#> 19: 53.967621 51.1497 258 288.8 308.00 327.5 347.00 375.0 436.00 1.0005068
#> 20: 93.868922 80.8017 198 247.8 276.00 306.0 340.35 390.2 493.05 1.0003640
#> ess_bulk ess_tail
#> 1: NA NA
#> 2: 858.3035 887.5883
#> 3: 784.2638 908.5946
#> 4: 986.1909 904.5245
#> 5: 865.5054 947.2221
#> 6: 893.3750 835.9871
#> 7: 926.5402 861.1900
#> 8: 1097.4089 937.1445
#> 9: 1111.3917 1021.2936
#> 10: 1059.0036 983.0723
#> 11: 975.8115 927.8796
#> 12: 1084.7105 951.3275
#> 13: 1041.2300 974.4463
#> 14: 935.7652 1050.2310
#> 15: 1130.4067 958.2443
#> 16: 848.0051 763.8073
#> 17: 1083.0271 1028.2641
#> 18: 1063.6034 939.8372
#> 19: 1007.8998 874.2774
#> 20: 1366.8407 840.3280