Skip to contents

[Soft-deprecated] Convolves latent infections to reported cases via an observation model. Likely to be removed/replaced in later releases by functionality drawing on the stan implementation.

Usage

report_cases(
  case_estimates,
  case_forecast = NULL,
  delays,
  type = "sample",
  reporting_effect,
  CrIs = c(0.2, 0.5, 0.9)
)

Arguments

case_estimates

A data.table of case estimates with the following variables: date, sample, cases

case_forecast

A data.table of case forecasts with the following variables: date, sample, cases. If not supplied the default is not to incorporate forecasts.

delays

A call to delay_opts() defining delay distributions and options. See the documentation of delay_opts() and the examples below for details.

type

Character string indicating the method to use to transform counts. Supports either "sample" which approximates sampling or "median" would shift by the median of the distribution.

reporting_effect

A data.table giving the weekly reporting effect with the following variables: sample (must be the same as in nowcast), effect (numeric scaling factor for each weekday),day (numeric 1 - 7 (1 = Monday and 7 = Sunday)). If not supplied then no weekly reporting effect is assumed.

CrIs

Numeric vector of credible intervals to calculate.

Value

A list of data.tables. The first entry contains the following variables sample, date and cases with the second being summarised across samples.

Examples

# \donttest{
# define example cases
cases <- example_confirmed[1:40]

# get example delays
# Instead of running them model we use example
# data for speed in this example.
cases <- cases[, cases := as.integer(confirm)]
cases <- cases[, confirm := NULL][, sample := 1]

reported_cases <- report_cases(
  case_estimates = cases,
  delays = delay_opts(example_incubation_period + example_reporting_delay),
  type = "sample"
)
print(reported_cases)
#> $samples
#>     sample       date value
#>      <int>     <Date> <int>
#>  1:      1 2020-02-22     5
#>  2:      1 2020-02-23    18
#>  3:      1 2020-02-24    22
#>  4:      1 2020-02-25    34
#>  5:      1 2020-02-26    48
#>  6:      1 2020-02-27    52
#>  7:      1 2020-02-28   108
#>  8:      1 2020-02-29   140
#>  9:      1 2020-03-01   142
#> 10:      1 2020-03-02   231
#> 11:      1 2020-03-03   262
#> 12:      1 2020-03-04   298
#> 13:      1 2020-03-05   352
#> 14:      1 2020-03-06   438
#> 15:      1 2020-03-07   498
#> 16:      1 2020-03-08   673
#> 17:      1 2020-03-09   834
#> 18:      1 2020-03-10  1006
#> 19:      1 2020-03-11  1002
#> 20:      1 2020-03-12  1305
#> 21:      1 2020-03-13  1568
#> 22:      1 2020-03-14  1822
#> 23:      1 2020-03-15  2111
#> 24:      1 2020-03-16  2234
#> 25:      1 2020-03-17  2677
#> 26:      1 2020-03-18  2778
#> 27:      1 2020-03-19  3053
#> 28:      1 2020-03-20  3653
#> 29:      1 2020-03-21  4067
#> 30:      1 2020-03-22  4658
#> 31:      1 2020-03-23  4793
#> 32:      1 2020-03-24  4683
#> 33:      1 2020-03-25  4841
#> 34:      1 2020-03-26  4926
#> 35:      1 2020-03-27  5202
#> 36:      1 2020-03-28  5304
#> 37:      1 2020-03-29  5582
#> 38:      1 2020-03-30  5388
#> 39:      1 2020-03-31  5297
#> 40:      1 2020-04-01  4853
#>     sample       date value
#> 
#> $summarised
#>           date median  mean    sd lower_90 lower_50 lower_20 upper_20 upper_50
#>         <Date>  <num> <num> <num>    <num>    <num>    <num>    <num>    <num>
#>  1: 2020-02-22      5     5    NA        5        5        5        5        5
#>  2: 2020-02-23     18    18    NA       18       18       18       18       18
#>  3: 2020-02-24     22    22    NA       22       22       22       22       22
#>  4: 2020-02-25     34    34    NA       34       34       34       34       34
#>  5: 2020-02-26     48    48    NA       48       48       48       48       48
#>  6: 2020-02-27     52    52    NA       52       52       52       52       52
#>  7: 2020-02-28    108   108    NA      108      108      108      108      108
#>  8: 2020-02-29    140   140    NA      140      140      140      140      140
#>  9: 2020-03-01    142   142    NA      142      142      142      142      142
#> 10: 2020-03-02    231   231    NA      231      231      231      231      231
#> 11: 2020-03-03    262   262    NA      262      262      262      262      262
#> 12: 2020-03-04    298   298    NA      298      298      298      298      298
#> 13: 2020-03-05    352   352    NA      352      352      352      352      352
#> 14: 2020-03-06    438   438    NA      438      438      438      438      438
#> 15: 2020-03-07    498   498    NA      498      498      498      498      498
#> 16: 2020-03-08    673   673    NA      673      673      673      673      673
#> 17: 2020-03-09    834   834    NA      834      834      834      834      834
#> 18: 2020-03-10   1006  1006    NA     1006     1006     1006     1006     1006
#> 19: 2020-03-11   1002  1002    NA     1002     1002     1002     1002     1002
#> 20: 2020-03-12   1305  1305    NA     1305     1305     1305     1305     1305
#> 21: 2020-03-13   1568  1568    NA     1568     1568     1568     1568     1568
#> 22: 2020-03-14   1822  1822    NA     1822     1822     1822     1822     1822
#> 23: 2020-03-15   2111  2111    NA     2111     2111     2111     2111     2111
#> 24: 2020-03-16   2234  2234    NA     2234     2234     2234     2234     2234
#> 25: 2020-03-17   2677  2677    NA     2677     2677     2677     2677     2677
#> 26: 2020-03-18   2778  2778    NA     2778     2778     2778     2778     2778
#> 27: 2020-03-19   3053  3053    NA     3053     3053     3053     3053     3053
#> 28: 2020-03-20   3653  3653    NA     3653     3653     3653     3653     3653
#> 29: 2020-03-21   4067  4067    NA     4067     4067     4067     4067     4067
#> 30: 2020-03-22   4658  4658    NA     4658     4658     4658     4658     4658
#> 31: 2020-03-23   4793  4793    NA     4793     4793     4793     4793     4793
#> 32: 2020-03-24   4683  4683    NA     4683     4683     4683     4683     4683
#> 33: 2020-03-25   4841  4841    NA     4841     4841     4841     4841     4841
#> 34: 2020-03-26   4926  4926    NA     4926     4926     4926     4926     4926
#> 35: 2020-03-27   5202  5202    NA     5202     5202     5202     5202     5202
#> 36: 2020-03-28   5304  5304    NA     5304     5304     5304     5304     5304
#> 37: 2020-03-29   5582  5582    NA     5582     5582     5582     5582     5582
#> 38: 2020-03-30   5388  5388    NA     5388     5388     5388     5388     5388
#> 39: 2020-03-31   5297  5297    NA     5297     5297     5297     5297     5297
#> 40: 2020-04-01   4853  4853    NA     4853     4853     4853     4853     4853
#>           date median  mean    sd lower_90 lower_50 lower_20 upper_20 upper_50
#>     upper_90
#>        <num>
#>  1:        5
#>  2:       18
#>  3:       22
#>  4:       34
#>  5:       48
#>  6:       52
#>  7:      108
#>  8:      140
#>  9:      142
#> 10:      231
#> 11:      262
#> 12:      298
#> 13:      352
#> 14:      438
#> 15:      498
#> 16:      673
#> 17:      834
#> 18:     1006
#> 19:     1002
#> 20:     1305
#> 21:     1568
#> 22:     1822
#> 23:     2111
#> 24:     2234
#> 25:     2677
#> 26:     2778
#> 27:     3053
#> 28:     3653
#> 29:     4067
#> 30:     4658
#> 31:     4793
#> 32:     4683
#> 33:     4841
#> 34:     4926
#> 35:     5202
#> 36:     5304
#> 37:     5582
#> 38:     5388
#> 39:     5297
#> 40:     4853
#>     upper_90
#> 
# }