Estimate the Effective Reproductive Number with Trend Filtering

Use trend filtering, a type of regularized nonparametric regression, to estimate the instantaneous reproduction number, also called Rt. This value roughly says how many new infections will result from each new infection today. Values larger than 1 indicate that an epidemic is growing while those less than 1 indicate decline. For more details about this methodology, see Liu, Cai, Gustafson, and McDonald (2024) .


rtestim rtestim website

R-CMD-check CRANstatus

This package uses Poisson likelihood with a trend filtering penalty (a type of regularized nonparametric regression) to estimate the effective reproductive number, Rt. This value roughly says “how many new infections will result from each new infection today”. Values larger than 1 indicate that an epidemic is growing while those less than 1 indicate decline.

Installation

You can install the development version of rtestim from GitHub with:

# install.packages("remotes")
remotes::install_github("dajmcdon/rtestim")

Or the released version on CRAN

install.packages("rtestim")

Quick example

Here we create some data that “looks” like a typical wave in an epidemic. Because the model uses regularized regression, we estimate the model at a range of tuning parameters simultaneously.

set.seed(12345)
library(rtestim)
library(ggplot2)
dat <- data.frame(
  Time = 1:101,
  incident_cases = c(1, rpois(100, dnorm(1:100, 50, 15) * 500 + 1))
)
ggplot(dat, aes(Time, incident_cases)) +
  geom_point(colour = "cornflowerblue") +
  theme_bw()

We fit the model and visualize the resulting estimated sequences of $R_t$:

mod <- estimate_rt(observed_counts = dat$incident_cases, nsol = 20)
plot(mod)

The additional parameter nsol = 20 specifies the number of tuning parameters for which $R_t$ is estimated. A built in function for cross-validation can be used to select the tuning parameter.

mod_cv <- cv_estimate_rt(dat$incident_cases, nsol = 20)
plot(mod_cv, which_lambda = "lambda.1se")

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("rtestim")

1.0.2 by Daniel J. McDonald, 7 months ago


https://github.com/dajmcdon/rtestim, https://dajmcdon.github.io/rtestim/


Report a bug at https://github.com/dajmcdon/rtestim/issues


Browse source code at https://github.com/cran/rtestim


Authors: Daniel J. McDonald [aut, cre, cph] , Jiaping Liu [aut] , Zhenglun Cai [ctb]


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports checkmate, cli, dspline, ggplot2, Matrix, methods, Rcpp, rlang, tibble, tvdenoising, vctrs

Suggests dplyr, forcats, knitr, nnet, rmarkdown, testthat, tidyr, xml2

Linking to BH, dspline, Rcpp, RcppEigen, testthat, tvdenoising


See at CRAN