estimate_R0.Rd
Estimate the time varying R0 - using EpiEstim
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 )
cases | A dataframe containing a list of local cases with the following variables: |
---|---|
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 ( |
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 |
horizon | Numeric, defaults to 0. The horizon over which to forecast Rts and cases. |
A list of data.table
's containing the date and summarised R estimate and optionally a case forecast
## 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#> date R sample crps window rt_type #> 1: 2020-01-24 0.3179646 1 0.09 3 nowcast #> 2: 2020-01-24 1.0212079 2 0.09 3 nowcast #> 3: 2020-01-24 1.4533755 3 0.09 3 nowcast #> 4: 2020-01-24 1.6329530 4 0.09 3 nowcast #> 5: 2020-01-24 1.6330397 5 0.09 3 nowcast #> --- #> 586: 2020-03-22 1.4251245 6 166.20 1 nowcast #> 587: 2020-03-22 1.4328383 7 166.20 1 nowcast #> 588: 2020-03-22 1.4339116 8 166.20 1 nowcast #> 589: 2020-03-22 1.4488785 9 166.20 1 nowcast #> 590: 2020-03-22 1.4631037 10 166.20 1 nowcastif (FALSE) { ## 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 }