Skip to contents

This option estimates the effective reproduction number using penalized B-splines.

Usage

R_estimate_splines(
  knot_distance = 7,
  spline_degree = 3,
  coef_intercept_prior_mu = 1,
  coef_intercept_prior_sigma = 0.8,
  coef_sd_prior_mu = 0,
  coef_sd_prior_sigma = 0.2,
  coef_sd_changepoint_dist = 7 * 26,
  coef_sd_changepoint_sd = 0.05,
  link = "inv_softplus",
  R_max = 6,
  modeldata = modeldata_init()
)

Arguments

knot_distance

Distance between spline breakpoints (knots) in days (default is 7, i.e. one knot each week). Placing knots further apart increases the smoothness of Rt estimates and can speed up model fitting. The Rt time series remains surprisingly flexible even at larger knot distances, but placing knots too far apart can lead to inaccurate estimates.

spline_degree

Degree of the spline polynomials (default is 3 for cubic splines).

coef_intercept_prior_mu

Prior (mean) on the intercept of the random walk over spline coefficients.

coef_intercept_prior_sigma

Prior (standard deviation) on the intercept of the random walk over spline coefficients.

coef_sd_prior_mu

Prior (mean) on the daily standard deviation of the random walk over spline coefficients (see details).

coef_sd_prior_sigma

Prior (standard deviation) on the daily standard deviation of the random walk over spline coefficients. Please note that for consistency the overall prior on the daily standard deviation of the random walk will have a standard deviation of coef_sd_prior_sigma + coef_sd_changepoint_sd even if no changepoints are modeled (see below).

coef_sd_changepoint_dist

The variability of Rt can change over time, e.g. during the height of an epidemic wave, countermeasures may lead to much faster changes in Rt than observable at other times. This potential variability is accounted for using change points placed at regular intervals. The standard deviation of the random walk over spline coefficients then evolves linearly between the change points. The default change point distance is 26 weeks (182 days). Short changepoint distances (e.g. 4 weeks or less) must be chosen with care, as they can make the Rt time series too flexible. If set to zero, no change points are modeled.

coef_sd_changepoint_sd

This parameter controls the variability of the change points. When change points are modeled, EpiSewer will estimate a baseline standard deviation (see coef_sd_prior_mu and coef_sd_prior_sigma), and model change point values as independently distributed with mean equal to this baseline and standard deviation coef_sd_changepoint_sd.

Link function. Currently supported are inv_softplus (default) and scaled_logit. Both of these links are configured to behave approximately like the identity function around R=1, but become increasingly non-linear below (and in the case of scaled_logit also above) R=1.

R_max

If link=scaled_logit is used, a maximum reproduction number must be assumed. This should be higher than any realistic R value for the modeled pathogen. Default is 6.

modeldata

A modeldata object to which the above model specifications should be added. Default is an empty model given by modeldata_init(). Can also be an already partly specified model returned by other EpiSewer modeling functions.

Value

A modeldata object containing data and specifications of the model to be fitted. Can be passed on to other EpiSewer modeling functions to add further data and model specifications.

The modeldata object also includes information about parameter initialization (init), meta data (.metainfo), and checks to be performed before model fitting (.checks).

Details

EpiSewer uses a random walk on the B-spline coefficients for regularization. This allows to use small knot distances without obtaining extremely wiggly Rt estimates.

  • The prior on the random walk intercept should reflect your expectation of Rt at the beginning of the time series. If estimating from the start of an epidemic, you might want to use a prior with mean larger than 1 for the intercept.

  • The prior on the daily standard deviation should be interpreted in terms of daily additive changes (this is at least true around Rt=1, and becomes less true as Rt approaches 0 or its upper bound as defined by the link function). For example, a prior with mean=0 and sd=0.2 allows a daily standard deviation between 0 and 0.4. A daily standard deviation of 0.4 in turn roughly allows the spline coefficients to change by ±0.8 (using the 2 sigma rule) each day. The daily standard deviation is summed up over the days between two knots to get the actual standard deviation of the coefficients. This way, the prior is independent of the chosen knot_distance. For example, if knot_distance is 7 days, and a constant daily standard deviation of 0.4 is estimated, the coefficients of two adjacent splines can differ by up to 0.8*sqrt(knot_distance), i.e. ±2.1. Note however that this difference does not directly translate into a change of Rt by ±2.1, as Rt is always the weighted sum of several basis functions at any given point. It may therefore change much more gradually, depending on the distances between knots.

The smoothness of the Rt estimates is influenced both by the knot distance and by the daily standard deviation of the random walk on coefficients. The latter also influences the uncertainty of Rt estimates towards the present / date of estimation, when limited data signal is available. Absent sufficient data signal, Rt estimates will tend to stay at the current level (which corresponds to assuming unchanged transmission dynamics).

The priors of this component have the following functional form:

  • intercept of the random walk over spline coefficients: Normal

  • standard deviation of the random walk over spline coefficients: Truncated normal

See also