estimate_R0: Estimate the time varying R0 - using EpiEstim

Description Usage Arguments Value Examples

View source: R/estimate_R0.R

Description

Estimate the time varying R0 - using EpiEstim

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
estimate_R0(
  cases = NULL,
  generation_times = NULL,
  rt_prior = NULL,
  windows = NULL,
  gt_samples = 100,
  rt_samples = 100,
  min_est_date = NULL,
  forecast_model = NULL,
  horizon = 0
)

Arguments

cases

A dataframe containing a list of local cases with the following variables: date, cases, and import_status

generation_times

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

rt_prior

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

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).

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.

min_est_date

Date to begin estimation.

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.

Value

A list of data.table's containing the date and summarised R estimate and optionally a case forecast

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
29
30
## Nowcast Rts                  
estimates <- estimate_R0(cases = EpiSoon::example_obs_cases, 
                         generation_times = as.matrix(EpiNow::covid_generation_times[,2]), 
                         rt_prior = list(mean_prior = 2.6, std_prior = 2),
                         windows = c(1, 3, 7), rt_samples = 10, gt_samples = 1)
                         
                         
estimates$rts
 
## Not run:  
## Nowcast Rts, forecast Rts and the forecast cases
estimates <- estimate_R0(cases = EpiSoon::example_obs_cases, 
                         generation_times = as.matrix(EpiNow::covid_generation_times[,1]), 
                         rt_prior = list(mean_prior = 2.6, std_prior = 2),
                         windows = c(1, 3, 7), rt_samples = 10, gt_samples = 20,
                         min_est_date =  as.Date("2020-02-18"),
                         forecast_model = function(...){
                              EpiSoon::fable_model(model = fable::ETS(y ~ trend("A")), ...)
                              },
                         horizon = 14)
                                           
## Rt estimates and forecasts
estimates$rts



## Case forecasts
estimates$cases

## End(Not run)

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