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 ofdelay_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 innowcast
),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.table
s. The first entry contains the following
variables sample
, date
and cases
with the second being summarised
across samples.
Examples
# \donttest{
# This function is deprecated and its functionality can now be accessed
# from [simulate_secondary()].
# Here are some examples of how to use [simulate_secondary()] to replace
# report_cases().
# Old (using report_cases()):
# Define case data
cases <- example_confirmed[1:40]
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"
)
#> Warning: `report_cases()` was deprecated in EpiNow2 1.5.0.
#> ℹ Please use `simulate_secondary()` instead.
#> ℹ See equivalent examples using `simulate_secondary()`
#> ℹ in ?report_cases.
#> ℹ This function will be removed completely in the next version.
print(reported_cases$samples)
#> sample date value
#> <int> <Date> <int>
#> 1: 1 2020-02-26 3
#> 2: 1 2020-02-27 8
#> 3: 1 2020-02-28 14
#> 4: 1 2020-02-29 28
#> 5: 1 2020-03-01 31
#> 6: 1 2020-03-02 48
#> 7: 1 2020-03-03 58
#> 8: 1 2020-03-04 98
#> 9: 1 2020-03-05 163
#> 10: 1 2020-03-06 195
#> 11: 1 2020-03-07 217
#> 12: 1 2020-03-08 259
#> 13: 1 2020-03-09 360
#> 14: 1 2020-03-10 378
#> 15: 1 2020-03-11 495
#> 16: 1 2020-03-12 585
#> 17: 1 2020-03-13 739
#> 18: 1 2020-03-14 900
#> 19: 1 2020-03-15 1008
#> 20: 1 2020-03-16 1205
#> 21: 1 2020-03-17 1363
#> 22: 1 2020-03-18 1683
#> 23: 1 2020-03-19 1929
#> 24: 1 2020-03-20 2249
#> 25: 1 2020-03-21 2557
#> 26: 1 2020-03-22 2636
#> 27: 1 2020-03-23 3127
#> 28: 1 2020-03-24 3523
#> 29: 1 2020-03-25 3840
#> 30: 1 2020-03-26 4216
#> 31: 1 2020-03-27 4645
#> 32: 1 2020-03-28 4887
#> 33: 1 2020-03-29 5228
#> 34: 1 2020-03-30 5177
#> 35: 1 2020-03-31 5371
#> 36: 1 2020-04-01 5447
#> sample date value
# New (using simulate_secondary()):
cases <- example_confirmed[1:40]
cases <- cases[, primary := as.integer(confirm)]
report <- simulate_secondary(
cases,
delays = delay_opts(
fix_dist(example_incubation_period + example_reporting_delay)
),
obs = obs_opts(family = "poisson")
)
print(report)
#> date.date secondary
#> <Date> <num>
#> 1: 2020-02-22 0
#> 2: 2020-02-23 0
#> 3: 2020-02-24 0
#> 4: 2020-02-25 1
#> 5: 2020-02-26 4
#> 6: 2020-02-27 5
#> 7: 2020-02-28 16
#> 8: 2020-02-29 37
#> 9: 2020-03-01 53
#> 10: 2020-03-02 55
#> 11: 2020-03-03 91
#> 12: 2020-03-04 113
#> 13: 2020-03-05 165
#> 14: 2020-03-06 193
#> 15: 2020-03-07 249
#> 16: 2020-03-08 309
#> 17: 2020-03-09 357
#> 18: 2020-03-10 439
#> 19: 2020-03-11 485
#> 20: 2020-03-12 656
#> 21: 2020-03-13 786
#> 22: 2020-03-14 927
#> 23: 2020-03-15 1122
#> 24: 2020-03-16 1267
#> 25: 2020-03-17 1535
#> 26: 2020-03-18 1778
#> 27: 2020-03-19 2006
#> 28: 2020-03-20 2352
#> 29: 2020-03-21 2677
#> 30: 2020-03-22 2951
#> 31: 2020-03-23 3149
#> 32: 2020-03-24 3471
#> 33: 2020-03-25 3861
#> 34: 2020-03-26 4266
#> 35: 2020-03-27 4806
#> 36: 2020-03-28 5174
#> 37: 2020-03-29 5230
#> 38: 2020-03-30 5345
#> 39: 2020-03-31 5477
#> 40: 2020-04-01 5341
#> date.date secondary
# }