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.789    136
#>  4:       DE       00+                 1    16   0.000000000 141.288    141
#>  5:       DE       00+                 1    15   0.007194245 146.019    146
#>  6:       DE       00+                 1    14   0.000000000 103.853    104
#>  7:       DE       00+                 1    13   0.000000000  62.766     63
#>  8:       DE       00+                 1    12   0.000000000 185.035    185
#>  9:       DE       00+                 1    11   0.000000000 256.031    256
#> 10:       DE       00+                 1    10   0.004219409 267.692    267
#> 11:       DE       00+                 1     9   0.000000000 236.057    235
#> 12:       DE       00+                 1     8   0.015873016 231.407    231
#> 13:       DE       00+                 1     7   0.040000000 164.876    164
#> 14:       DE       00+                 1     6   0.010204082 128.858    128
#> 15:       DE       00+                 1     5   0.012396694 293.309    292
#> 16:       DE       00+                 1     4   0.017937220 293.042    292
#> 17:       DE       00+                 1     3   0.019801980 291.478    290
#> 18:       DE       00+                 1     2   0.070175439 293.178    291
#> 19:       DE       00+                 1     1   0.383928571 308.518    302
#> 20:       DE       00+                 1     0   1.000000000 375.644    363
#>     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 149.00   149 149.00   149 149.00        NA
#>  2:   1.318432  1.4826 166.00   166 167.00   167 168.00   168 170.00 0.9997778
#>  3:   1.854162  1.4826 133.00   134 135.00   136 136.00   137 139.00 1.0005878
#>  4:   2.378805  1.4826 138.00   139 140.00   141 142.00   143 146.00 1.0056729
#>  5:   3.079630  2.9652 141.00   143 145.00   146 147.00   148 152.00 1.0001025
#>  6:   2.969884  2.9652 100.00   101 102.65   104 105.00   106 109.00 0.9991163
#>  7:   2.432110  2.9652  59.00    61  62.00    63  63.00    65  67.00 1.0009067
#>  8:   3.847932  4.4478 179.00   182 183.00   185 186.00   188 192.00 1.0002531
#>  9:   6.498790  5.9304 246.00   251 253.00   256 258.00   261 268.00 0.9997137
#> 10:   7.713536  7.4130 256.00   261 265.00   267 270.00   274 282.00 1.0004951
#> 11:   8.508004  7.4130 223.00   229 233.00   235 239.00   243 251.00 0.9985724
#> 12:  10.083304 10.3782 216.00   222 227.00   231 234.00   240 250.00 1.0035756
#> 13:   9.848127 10.3782 150.00   157 160.00   164 168.00   173 181.00 1.0025186
#> 14:   8.134495  7.4130 117.00   122 125.00   128 131.00   135 143.00 1.0010009
#> 15:  11.938427 11.8608 276.00   283 288.00   292 297.00   303 315.00 1.0002316
#> 16:  15.799489 14.8260 268.00   280 286.00   292 299.00   306 320.00 1.0047058
#> 17:  21.108128 19.2738 260.00   274 282.00   290 298.35   308 330.00 1.0002334
#> 18:  29.440398 28.1694 250.00   269 280.00   291 301.00   316 344.00 0.9993186
#> 19:  51.151522 46.7019 239.00   267 286.00   302 322.00   343 399.10 0.9992178
#> 20: 103.424281 91.1799 233.95   292 327.00   363 397.00   447 565.05 0.9991666
#>             sd     mad     q5   q20    q35   q50    q65   q80    q95      rhat
#>      ess_bulk  ess_tail
#>         <num>     <num>
#>  1:        NA        NA
#>  2: 1003.5643  828.2026
#>  3:  991.0805  916.0962
#>  4: 1041.2029  872.9772
#>  5:  991.1639  885.1056
#>  6:  982.3833  917.3468
#>  7:  911.2098  793.6687
#>  8: 1004.7790  972.0392
#>  9: 1025.3311  936.5679
#> 10: 1040.1417 1008.8448
#> 11: 1201.4893  863.9704
#> 12:  751.4194  655.0188
#> 13:  927.9122  920.9413
#> 14: 1080.4014  964.2083
#> 15: 1159.2978  984.6276
#> 16: 1087.6045  957.9921
#> 17: 1129.6391  914.6275
#> 18: 1126.3831  903.3288
#> 19: 1328.2832  998.7573
#> 20: 1554.0485  999.3402
#>      ess_bulk  ess_tail