aSerfling: Adjusted Serfling

View source: R/aSerfling.R

aSerflingR Documentation

Adjusted Serfling

Description

Adjusted Serfling regression for periodic disease surveillance, automating epidemic baseline estimation through iterative threshold optimization. Enhances traditional Serfling models by objectively determining epidemic periods and improving peak detection accuracy.

Usage

aSerfling(data, col_name, cycles)

Arguments

data

A data frame containing the warning indicator columns, arranged in time-based order.

col_name

A column name for the warning indicator (character).

cycles

A numeric vector of disease cycles (e.g., c(52,26) for weekly annual + semi-annual patterns)

Details

Implements an iterative periodic regression for time series with at least 2 full cycles. Key features:

  1. Dynamic Epidemic Filtering:

    • Automatically excludes outbreak points via iterative prediction-CI comparison

    • Terminates when adjusted R-squared stabilizes (maximized model fit)

  2. Flexible Seasonality Modeling:

    Y = \beta_0 + \beta_1 t + \beta_2 t^2 + \sum_{k=1}^K \left[\gamma_k \sin\left(\frac{2\pi t}{C_k}\right) + \delta_k \cos\left(\frac{2\pi t}{C_k}\right)\right] + \epsilon

    • Supports multiple cycles via cycles parameter (e.g., c(52,26) for weekly annual + semi-annual patterns)

    • Self-adapts to pathogen seasonality shifts

  3. Peak-Centric Alerting:

    • Flags peaks via optimized threshold (final model's 95% CI upper bound)

    • Avoids subjective epidemic-onset definitions

Value

A list containing:

  • output: Full dataset with warning flags (1=alert, 0=normal)

  • best_fit: Final lm model object

  • fit_times: Iteration count for convergence

  • cycles: Input cycle parameters

References

Wang X, Wu S, MacIntyre CR, et al. Using an adjusted Serfling regression model to improve the early warning at the arrival of peak timing of influenza in Beijing. PLoS One, 2015,10(3):e0119923.

Examples

## modeling
data(sample_ili)
sf <- aSerfling(data = sample_ili, 'case', cycles = c(52, 26))
sf

## visualize alerts
output <- sf$output
plot(output$date, output$case, type = "l")
points(output$date[output$warning == 1],
       output$case[output$warning == 1], col = "red")


WarnEpi documentation built on Aug. 27, 2025, 9:10 a.m.