Skip to contents

Add the latest observations to the nowcast output. This is useful for plotting the nowcast against the latest observations.

Usage

enw_add_latest_obs_to_nowcast(nowcast, obs)

Arguments

nowcast

A data.frame of nowcast output from enw_nowcast_summary().

obs

An observation data.frame containing reference_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 of enw_preprocess_data() or enw_latest_data().

Value

A data.frame of nowcast output with the latest observations added.

See also

Examples

fit <- enw_example("nowcast")
obs <- enw_example("obs")
nowcast <- summary(fit, type = "nowcast")
enw_add_latest_obs_to_nowcast(nowcast, obs)
#> Key: <reference_date, .group>
#>     reference_date .group latest_confirm confirm report_date max_confirm
#>             <IDat>  <num>          <int>   <int>      <IDat>       <int>
#>  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
#>     reference_date .group latest_confirm confirm report_date max_confirm
#>     location age_group cum_prop_reported delay prop_reported    mean median
#>       <fctr>    <fctr>             <num> <num>         <num>   <num>  <num>
#>  1:       DE       00+                 1    19   0.000000000 149.000    149
#>  2:       DE       00+                 1    18   0.000000000 167.426    167
#>  3:       DE       00+                 1    17   0.000000000 135.812    136
#>  4:       DE       00+                 1    16   0.000000000 141.255    141
#>  5:       DE       00+                 1    15   0.007194245 145.884    146
#>  6:       DE       00+                 1    14   0.000000000 103.681    103
#>  7:       DE       00+                 1    13   0.000000000  62.762     62
#>  8:       DE       00+                 1    12   0.000000000 185.138    185
#>  9:       DE       00+                 1    11   0.000000000 255.903    255
#> 10:       DE       00+                 1    10   0.004219409 267.488    267
#> 11:       DE       00+                 1     9   0.000000000 236.164    236
#> 12:       DE       00+                 1     8   0.015873016 230.867    230
#> 13:       DE       00+                 1     7   0.040000000 165.026    165
#> 14:       DE       00+                 1     6   0.010204082 129.307    128
#> 15:       DE       00+                 1     5   0.012396694 292.749    292
#> 16:       DE       00+                 1     4   0.017937220 293.296    292
#> 17:       DE       00+                 1     3   0.019801980 291.404    290
#> 18:       DE       00+                 1     2   0.070175439 295.703    292
#> 19:       DE       00+                 1     1   0.383928571 309.456    304
#> 20:       DE       00+                 1     0   1.000000000 381.243    371
#>     location age_group cum_prop_reported delay prop_reported    mean median
#>             sd     mad     q5   q20   q35   q50   q65   q80    q95      rhat
#>          <num>   <num>  <num> <num> <num> <num> <num> <num>  <num>     <num>
#>  1:   0.000000  0.0000 149.00 149.0   149   149   149 149.0 149.00        NA
#>  2:   1.316912  1.4826 166.00 166.0   167   167   168 168.0 170.00 0.9988498
#>  3:   1.867121  1.4826 133.00 134.0   135   136   136 137.0 139.00 0.9997035
#>  4:   2.341679  2.2239 138.00 139.0   140   141   142 143.0 145.00 1.0017705
#>  5:   3.085460  2.9652 141.00 143.0   144   146   147 148.0 151.05 0.9984520
#>  6:   3.072243  2.9652  99.00 101.0   102   103   105 106.0 109.00 0.9997410
#>  7:   2.461588  1.4826  59.00  61.0    62    62    63  65.0  67.00 0.9987681
#>  8:   3.827742  4.4478 180.00 182.0   183   185   186 188.0 192.00 1.0064762
#>  9:   6.410514  5.9304 246.00 250.0   253   255   258 261.0 267.00 1.0014583
#> 10:   7.975931  7.4130 255.00 261.0   264   267   270 274.0 281.00 1.0052639
#> 11:   8.459235  8.8956 223.00 229.0   232   236   239 243.0 252.00 1.0041063
#> 12:  10.092332 10.3782 216.00 222.0   226   230   234 239.0 249.00 1.0026046
#> 13:  10.254095 10.3782 149.95 156.8   160   165   168 173.0 183.00 0.9991933
#> 14:   8.532969  8.8956 116.00 122.0   126   128   132 136.0 144.05 1.0000500
#> 15:  11.792076 11.8608 275.00 283.0   288   292   297 303.0 313.00 0.9993709
#> 16:  15.992941 14.8260 270.00 280.0   286   292   298 306.0 320.00 1.0008511
#> 17:  19.436887 19.2738 263.00 274.0   284   290   298 306.0 325.00 0.9992936
#> 18:  28.861250 28.1694 254.95 271.0   282   292   304 319.0 348.00 1.0008356
#> 19:  51.295236 47.4432 237.00 266.8   285   304   323 349.0 406.00 0.9988372
#> 20: 103.890978 96.3690 240.85 293.8   332   371   405 459.2 569.05 0.9993392
#>             sd     mad     q5   q20   q35   q50   q65   q80    q95      rhat
#>      ess_bulk  ess_tail
#>         <num>     <num>
#>  1:        NA        NA
#>  2:  997.2790  946.6047
#>  3: 1015.7372 1017.4859
#>  4:  901.5890  958.7197
#>  5: 1097.0842 1044.2543
#>  6: 1034.2365  913.6061
#>  7: 1012.1885  904.7496
#>  8:  885.6025  907.2186
#>  9:  933.4472  918.6322
#> 10: 1044.4533 1055.2781
#> 11: 1039.8102  897.5389
#> 12: 1018.9795  919.8161
#> 13: 1090.1636  782.0808
#> 14: 1023.7823  888.2873
#> 15: 1145.8224  968.8335
#> 16: 1056.0595  914.9342
#> 17: 1248.9469  968.8798
#> 18: 1412.5892 1036.8252
#> 19: 1195.0907  985.8485
#> 20: 1349.1168 1029.2555
#>      ess_bulk  ess_tail