epi_measures_pipeline: Estimate time-varying measures and forecast

Description Usage Arguments Value Examples

View source: R/epi_measures_pipeline.R

Description

Estimate time-varying measures and forecast

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
epi_measures_pipeline(
  nowcast = NULL,
  generation_times = NULL,
  min_est_date = NULL,
  gt_samples = 1,
  rt_samples = 5,
  rt_windows = 7,
  rate_window = 7,
  rt_prior = NULL,
  forecast_model = NULL,
  horizon = 0,
  verbose = TRUE
)

Arguments

nowcast

A nowcast as produced by nowcast_pipeline

generation_times

A matrix with columns representing samples and rows representing the probability of the generation timebeing on that day.

min_est_date

Date to begin estimation.

gt_samples

Numeric, the number of samples to take from the generaiton times supplied

rt_samples

Numeric, the number of samples to take from the estimated R distribution for each time point.

rt_windows

Numeric vector, windows over which to estimate time-varying R. The best performing window will be selected per serial interval sample by default (based on which window best forecasts current cases).

rate_window

Numeric, the window to use to estimate the rate of spread.

rt_prior

A list defining the reproduction number prior containing the mean (mean_prior) and standard deviation (std_prior)

forecast_model

An uninitialised bsts model passed to EpiSoon::forecast_rt to be used for forecasting future Rt values. An example of the required structure is: function(ss, y){bsts::AddSemilocalLinearTrend(ss, y = y)}.

horizon

Numeric, defaults to 0. The horizon over which to forecast Rts and cases.

verbose

Logical, defaults to TRUE. Should progress messages be shown.

Value

A list of data frames containing reproduction number estimates, case forecasts, rate of growth estimates both summarised and raw.

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
27
28
## Construct example distributions
## reporting delay dist
delay_dist <- EpiNow::lognorm_dist_def(mean = 3, 
                                      mean_sd = 1,
                                      sd = 3,
                                      sd_sd = 1,
                                      max_value = 30,
                                      samples = 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)
 
## Estimate parameters                           
estimates <- epi_measures_pipeline(nowcast[type %in% "infection_upscaled"], 
                       generation_times = EpiNow::covid_generation_times,
                       rt_prior = list(mean_prior = 2.6, std_prior = 2))   
                       
estimates                                                             

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