nowcast_pipeline.Rd
Impute Cases Date of Infection
nowcast_pipeline( reported_cases = NULL, linelist = NULL, target_date = NULL, earliest_allowed_onset = NULL, merge_actual_onsets = FALSE, approx_delay = FALSE, max_delay = 120, verbose = FALSE, delay_defs = NULL, incubation_defs = NULL, nowcast_lag = 8, max_upscale = 5, onset_modifier = NULL )
reported_cases | A dataframe of reported cases |
---|---|
linelist | A linelist of report dates and onset dates |
target_date | Character string, in the form "2020-01-01". Date to cast. |
earliest_allowed_onset | A character string in the form of a date ("2020-01-01") indiciating the earliest allowed onset. |
merge_actual_onsets | Logical, defaults to |
approx_delay | Logical, defaults to |
max_delay | Numeric, maximum delay to allow. Defaults to 120 days |
verbose | Logical, defaults to |
delay_defs | A data.table that defines the delay distributions (model, parameters and maximum delay for each model).
See |
incubation_defs | A data.table that defines the incubation distributions (model, parameters and maximum delay for each model).
See |
nowcast_lag | Numeric, defaults to 4. The number of days by which to lag nowcasts. Helps reduce bias due to case upscaling. |
max_upscale | Numeric, maximum upscaling of cases allowed at each time point. Defaults to 100 times the observed cases. |
onset_modifier | data.frame containing a |
A dataframe of nowcast cases from each step of the nowcasting process (defined by type
).
## Construct example distributions ## reporting delay dist delay_dist <- suppressWarnings( EpiNow::get_dist_def(rexp(25, 1 / 10), samples = 1, bootstraps = 1)) ## incubation delay dist incubation_dist <- delay_dist ## Uses example case vector from EpiSoon cases <- data.table::setDT(EpiSoon::example_obs_cases) cases <- cases[, `:=`(confirm = as.integer(cases), import_status = "local")] ## Basic nowcast nowcast <- nowcast_pipeline(reported_cases = cases, target_date = max(cases$date), delay_defs = delay_dist, incubation_defs = incubation_dist) nowcast#> sample date cases type import_status confidence #> 1: 1 2020-01-15 1 onset local 1.0000000 #> 2: 1 2020-01-16 0 onset local 1.0000000 #> 3: 1 2020-01-17 1 onset local 1.0000000 #> 4: 1 2020-01-18 0 onset local 1.0000000 #> 5: 1 2020-01-19 2 onset local 1.0000000 #> --- #> 254: 1 2020-03-10 332 infection_upscaled local 0.6480296 #> 255: 1 2020-03-11 293 infection_upscaled local 0.5988762 #> 256: 1 2020-03-12 328 infection_upscaled local 0.5466796 #> 257: 1 2020-03-13 367 infection_upscaled local 0.4916264 #> 258: 1 2020-03-14 318 infection_upscaled local 0.4340406