aSerfling | R Documentation |
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.
aSerfling(data, col_name, cycles)
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) |
Implements an iterative periodic regression for time series with at least 2 full cycles. Key features:
Dynamic Epidemic Filtering:
Automatically excludes outbreak points via iterative prediction-CI comparison
Terminates when adjusted R-squared stabilizes (maximized model fit)
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
Peak-Centric Alerting:
Flags peaks via optimized threshold (final model's 95% CI upper bound)
Avoids subjective epidemic-onset definitions
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
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.
## 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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.