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 version 2.0.0.
print(reported_cases$samples)
#> sample date value
#> <int> <Date> <int>
#> 1: 1 2020-02-25 1
#> 2: 1 2020-02-26 3
#> 3: 1 2020-02-27 14
#> 4: 1 2020-02-28 19
#> 5: 1 2020-02-29 29
#> 6: 1 2020-03-01 40
#> 7: 1 2020-03-02 65
#> 8: 1 2020-03-03 82
#> 9: 1 2020-03-04 112
#> 10: 1 2020-03-05 155
#> 11: 1 2020-03-06 195
#> 12: 1 2020-03-07 242
#> 13: 1 2020-03-08 303
#> 14: 1 2020-03-09 367
#> 15: 1 2020-03-10 462
#> 16: 1 2020-03-11 525
#> 17: 1 2020-03-12 635
#> 18: 1 2020-03-13 824
#> 19: 1 2020-03-14 957
#> 20: 1 2020-03-15 1172
#> 21: 1 2020-03-16 1350
#> 22: 1 2020-03-17 1489
#> 23: 1 2020-03-18 1783
#> 24: 1 2020-03-19 2121
#> 25: 1 2020-03-20 2362
#> 26: 1 2020-03-21 2787
#> 27: 1 2020-03-22 2985
#> 28: 1 2020-03-23 3261
#> 29: 1 2020-03-24 3582
#> 30: 1 2020-03-25 3994
#> 31: 1 2020-03-26 4485
#> 32: 1 2020-03-27 4816
#> 33: 1 2020-03-28 5077
#> 34: 1 2020-03-29 5196
#> 35: 1 2020-03-30 5284
#> 36: 1 2020-03-31 5329
#> 37: 1 2020-04-01 5483
#> 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 5
#> 6: 2020-02-27 6
#> 7: 2020-02-28 16
#> 8: 2020-02-29 26
#> 9: 2020-03-01 30
#> 10: 2020-03-02 49
#> 11: 2020-03-03 64
#> 12: 2020-03-04 115
#> 13: 2020-03-05 137
#> 14: 2020-03-06 168
#> 15: 2020-03-07 242
#> 16: 2020-03-08 307
#> 17: 2020-03-09 372
#> 18: 2020-03-10 403
#> 19: 2020-03-11 539
#> 20: 2020-03-12 585
#> 21: 2020-03-13 793
#> 22: 2020-03-14 964
#> 23: 2020-03-15 1114
#> 24: 2020-03-16 1304
#> 25: 2020-03-17 1450
#> 26: 2020-03-18 1725
#> 27: 2020-03-19 2085
#> 28: 2020-03-20 2290
#> 29: 2020-03-21 2607
#> 30: 2020-03-22 2855
#> 31: 2020-03-23 3288
#> 32: 2020-03-24 3517
#> 33: 2020-03-25 3953
#> 34: 2020-03-26 4407
#> 35: 2020-03-27 4727
#> 36: 2020-03-28 5113
#> 37: 2020-03-29 5173
#> 38: 2020-03-30 5269
#> 39: 2020-03-31 5322
#> 40: 2020-04-01 5558
#> date.date secondary
# }