Skip to contents

This function projects Rt (reproductive rate) values for a given time period and location using either an ARIMA or DLM model.

Usage

Rt_projection(
  train_data,
  mean_si = 5.7,
  std_si = 2,
  forecast_horizon = 28,
  method = c("arima", "dlm")
)

Arguments

train_data

A dataframe with columns for date, location_name, and value, where value is a numeric vector representing the number of new cases or incidences for that day and location.

mean_si

A numeric value representing the mean serial interval for the disease being modeled. Default is 5.7.

std_si

A numeric value representing the standard deviation of the serial interval for the disease being modeled. Default is 2.

forecast_horizon

a positive integer specifying the number of periods to forecast

method

A character vector specifying the method to use for projecting Rt values. Valid options are "arima" or "dlm". Default is "arima".

forecast_horiz_start

A date string representing the start of the time period to project Rt values for.

forecast_horiz_end

A date string representing the end of the time period to project Rt values for.

Value

A dataframe with the same columns as `train_data`, plus an additional column `Rt` representing the projected reproductive rate for each day and location.

Examples

# Load example data
data(covid_cases)
#> Warning: data set 'covid_cases' not found

# Project Rt values using default parameters and ARIMA method
Rt_df <- Rt_projection(train_data = covid_cases,
                        forecast_horiz_start = "2020-04-12",
                        forecast_horiz_end = "2020-04-26")
#> Error in Rt_projection(train_data = covid_cases, forecast_horiz_start = "2020-04-12",     forecast_horiz_end = "2020-04-26"): unused arguments (forecast_horiz_start = "2020-04-12", forecast_horiz_end = "2020-04-26")

# Project Rt values using DLM method
Rt_df <- Rt_projection(train_data = covid_cases,
                        forecast_horiz_start = "2020-04-12",
                        forecast_horiz_end = "2020-04-26",
                        method = "dlm")
#> Error in Rt_projection(train_data = covid_cases, forecast_horiz_start = "2020-04-12",     forecast_horiz_end = "2020-04-26", method = "dlm"): unused arguments (forecast_horiz_start = "2020-04-12", forecast_horiz_end = "2020-04-26")