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]

# set up example delays
generation_time <- get_generation_time(
 disease = "SARS-CoV-2", source = "ganyani"
)
incubation_period <- get_incubation_period(
 disease = "SARS-CoV-2", source = "lauer"
)
reporting_delay <- dist_spec(
  mean = convert_to_logmean(2, 1), mean_sd = 0.1,
  sd = convert_to_logsd(2, 1), sd_sd = 0.1, max = 10
)

# 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(incubation_period + reporting_delay),
  type = "sample"
)
print(reported_cases)
#> $samples
#>     sample       date value
#>  1:      1 2020-02-23     6
#>  2:      1 2020-02-24    10
#>  3:      1 2020-02-25    16
#>  4:      1 2020-02-26    17
#>  5:      1 2020-02-27    25
#>  6:      1 2020-02-28    52
#>  7:      1 2020-02-29    58
#>  8:      1 2020-03-01    76
#>  9:      1 2020-03-02   107
#> 10:      1 2020-03-03   150
#> 11:      1 2020-03-04   165
#> 12:      1 2020-03-05   183
#> 13:      1 2020-03-06   215
#> 14:      1 2020-03-07   274
#> 15:      1 2020-03-08   324
#> 16:      1 2020-03-09   410
#> 17:      1 2020-03-10   497
#> 18:      1 2020-03-11   585
#> 19:      1 2020-03-12   670
#> 20:      1 2020-03-13   834
#> 21:      1 2020-03-14   936
#> 22:      1 2020-03-15  1172
#> 23:      1 2020-03-16  1267
#> 24:      1 2020-03-17  1490
#> 25:      1 2020-03-18  1627
#> 26:      1 2020-03-19  1720
#> 27:      1 2020-03-20  1927
#> 28:      1 2020-03-21  2223
#> 29:      1 2020-03-22  2619
#> 30:      1 2020-03-23  2854
#> 31:      1 2020-03-24  2993
#> 32:      1 2020-03-25  2938
#> 33:      1 2020-03-26  3054
#> 34:      1 2020-03-27  3164
#> 35:      1 2020-03-28  3177
#> 36:      1 2020-03-29  3445
#> 37:      1 2020-03-30  3499
#> 38:      1 2020-03-31  3324
#> 39:      1 2020-04-01  3333
#>     sample       date value
#> 
#> $summarised
#>           date median mean sd lower_90 lower_50 lower_20 upper_20 upper_50
#>  1: 2020-02-23      6    6 NA        6        6        6        6        6
#>  2: 2020-02-24     10   10 NA       10       10       10       10       10
#>  3: 2020-02-25     16   16 NA       16       16       16       16       16
#>  4: 2020-02-26     17   17 NA       17       17       17       17       17
#>  5: 2020-02-27     25   25 NA       25       25       25       25       25
#>  6: 2020-02-28     52   52 NA       52       52       52       52       52
#>  7: 2020-02-29     58   58 NA       58       58       58       58       58
#>  8: 2020-03-01     76   76 NA       76       76       76       76       76
#>  9: 2020-03-02    107  107 NA      107      107      107      107      107
#> 10: 2020-03-03    150  150 NA      150      150      150      150      150
#> 11: 2020-03-04    165  165 NA      165      165      165      165      165
#> 12: 2020-03-05    183  183 NA      183      183      183      183      183
#> 13: 2020-03-06    215  215 NA      215      215      215      215      215
#> 14: 2020-03-07    274  274 NA      274      274      274      274      274
#> 15: 2020-03-08    324  324 NA      324      324      324      324      324
#> 16: 2020-03-09    410  410 NA      410      410      410      410      410
#> 17: 2020-03-10    497  497 NA      497      497      497      497      497
#> 18: 2020-03-11    585  585 NA      585      585      585      585      585
#> 19: 2020-03-12    670  670 NA      670      670      670      670      670
#> 20: 2020-03-13    834  834 NA      834      834      834      834      834
#> 21: 2020-03-14    936  936 NA      936      936      936      936      936
#> 22: 2020-03-15   1172 1172 NA     1172     1172     1172     1172     1172
#> 23: 2020-03-16   1267 1267 NA     1267     1267     1267     1267     1267
#> 24: 2020-03-17   1490 1490 NA     1490     1490     1490     1490     1490
#> 25: 2020-03-18   1627 1627 NA     1627     1627     1627     1627     1627
#> 26: 2020-03-19   1720 1720 NA     1720     1720     1720     1720     1720
#> 27: 2020-03-20   1927 1927 NA     1927     1927     1927     1927     1927
#> 28: 2020-03-21   2223 2223 NA     2223     2223     2223     2223     2223
#> 29: 2020-03-22   2619 2619 NA     2619     2619     2619     2619     2619
#> 30: 2020-03-23   2854 2854 NA     2854     2854     2854     2854     2854
#> 31: 2020-03-24   2993 2993 NA     2993     2993     2993     2993     2993
#> 32: 2020-03-25   2938 2938 NA     2938     2938     2938     2938     2938
#> 33: 2020-03-26   3054 3054 NA     3054     3054     3054     3054     3054
#> 34: 2020-03-27   3164 3164 NA     3164     3164     3164     3164     3164
#> 35: 2020-03-28   3177 3177 NA     3177     3177     3177     3177     3177
#> 36: 2020-03-29   3445 3445 NA     3445     3445     3445     3445     3445
#> 37: 2020-03-30   3499 3499 NA     3499     3499     3499     3499     3499
#> 38: 2020-03-31   3324 3324 NA     3324     3324     3324     3324     3324
#> 39: 2020-04-01   3333 3333 NA     3333     3333     3333     3333     3333
#>           date median mean sd lower_90 lower_50 lower_20 upper_20 upper_50
#>     upper_90
#>  1:        6
#>  2:       10
#>  3:       16
#>  4:       17
#>  5:       25
#>  6:       52
#>  7:       58
#>  8:       76
#>  9:      107
#> 10:      150
#> 11:      165
#> 12:      183
#> 13:      215
#> 14:      274
#> 15:      324
#> 16:      410
#> 17:      497
#> 18:      585
#> 19:      670
#> 20:      834
#> 21:      936
#> 22:     1172
#> 23:     1267
#> 24:     1490
#> 25:     1627
#> 26:     1720
#> 27:     1927
#> 28:     2223
#> 29:     2619
#> 30:     2854
#> 31:     2993
#> 32:     2938
#> 33:     3054
#> 34:     3164
#> 35:     3177
#> 36:     3445
#> 37:     3499
#> 38:     3324
#> 39:     3333
#>     upper_90
#> 
# }