regional_rt_pipeline: Regional Realtime Pipeline

Description Usage Arguments Examples

View source: R/regional_rt_pipeline.R

Description

Runs a pipeline by region.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
regional_rt_pipeline(
  cases = NULL,
  linelist = NULL,
  delay_defs = NULL,
  incubation_defs = NULL,
  target_folder = "results",
  target_date = NULL,
  merge_onsets = FALSE,
  case_limit = 40,
  onset_modifier = NULL,
  dt_threads = 1,
  verbose = FALSE,
  ...
)

Arguments

cases

A dataframe of cases (confirm) by date of confirmation (date), import status (import_status; ("imp)), and region (region).

linelist

A dataframe of of cases (by row) containing the following variables: import_status (values "local" and "imported"), date_onset, date_confirm, report_delay, and region. If a national linelist is not available a proxy linelist may be used but in this case merge_onsets should be set to FALSE.

delay_defs

A data.table that defines the delay distributions (model, parameters and maximum delay for each model). See get_delay_dist for an example of the structure.

incubation_defs

A data.table that defines the incubation distributions (model, parameters and maximum delay for each model). See get_delay_dist for an example of the structure.

target_folder

Character string indicating the folder into which to save results. Also used to extract previously generated results.

target_date

Character string, in the form "2020-01-01". Date to cast.

merge_onsets

Logical defaults to FALSE. Should available onset data be used. Typically if regional_delay is

case_limit

Numeric, the minimum number of cases in a region required for that region to be evaluated. Defaults to 10. set to FALSE this should also be FALSE

onset_modifier

data.frame containing a date variable and a function modifier variable. This is used to modify estimated cases by onset date. modifier must be a function that returns a proportion when called (enables inclusion of uncertainty) and takes the following arguments: n (samples to return) and status ("local" or "import").

dt_threads

Numeric, the number of data.table threads to use. Set internally to avoid issue when running in parallel. Defaults to 1 thread.

verbose

Logical, defaults to FALSE. Should progress messages be shown for each reigon?

...

Pass additional arguments to rt_pipeline

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
 ## Not run: 
## Save everything to a temporary directory 
## Change this to inspect locally
target_dir <- tempdir() 

## Construct example distributions
## reporting delay dist
delay_dist <- suppressWarnings(
               EpiNow::get_dist_def(rexp(25, 1/10), 
                                    samples = 5, bootstraps = 1))

## Uses example case vector from EpiSoon
cases <- data.table::setDT(EpiSoon::example_obs_cases)
cases <- cases[, `:=`(confirm = as.integer(cases), import_status = "local")][,
                  cases := NULL]

cases <- data.table::rbindlist(list(
  data.table::copy(cases)[, region := "testland"],
  cases[, region := "realland"]))
  
## Run basic nowcasting pipeline
regional_rt_pipeline(cases = cases,
            delay_defs = delay_dist,
            target_folder = target_dir)

## End(Not run)

epiforecasts/EpiNow documentation built on Oct. 26, 2020, 2:38 p.m.