options(width = 76) knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
Note: This package is currently in development and may not work as expected. Please file bug reports as issues in this repo, and we will do our best to address them quickly.
To install (unless you're making changes to the package, use the stable version):
# Stable version pak::pkg_install("cmu-delphi/epipredict@main") # Dev version pak::pkg_install("cmu-delphi/epipredict@dev")
You can view documentation for the main
branch at https://cmu-delphi.github.io/epipredict.
epipredict
We hope to provide:
Target audiences:
The Advanced user should find their task to be relatively easy. Examples of these tasks are illustrated in the vignettes and articles.
See also the (in progress) Forecasting Book.
The package comes with some built-in historical data for illustration, but
up-to-date versions of this could be downloaded with the
{epidatr}
package
and processed using
{epiprocess}
.[^1]
[^1]: Other epidemiological signals for non-Covid related illnesses are also
available with {epidatr}
which
interfaces directly to Delphi's
Epidata API
library(epipredict)
covid_case_death_rates
To create and train a simple auto-regressive forecaster to predict the death rate two weeks into the future using past (lagged) deaths and cases, we could use the following function.
two_week_ahead <- arx_forecaster( covid_case_death_rates, outcome = "death_rate", predictors = c("case_rate", "death_rate"), args_list = arx_args_list( lags = list(c(0, 1, 2, 3, 7, 14), c(0, 7, 14)), ahead = 14 ) ) two_week_ahead
In this case, we have used a number of different lags for the case rate, while only using 3 weekly lags for the death rate (as predictors). The result is both a fitted model object which could be used any time in the future to create different forecasts, as well as a set of predicted values (and prediction intervals) for each location 14 days after the last available time value in the data.
two_week_ahead$epi_workflow
The fitted model here involved preprocessing the data to appropriately generate
lagged predictors, estimating a linear model with stats::lm()
and then
postprocessing the results to be meaningful for epidemiological tasks. We can
also examine the predictions.
two_week_ahead$predictions
The results above show a distributional forecast produced using data through
the end of 2021 for the 14th of January 2022. A prediction for the death rate
per 100K inhabitants is available for every state (geo_value
) along with a
90% predictive interval.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.