TW-SIR: time-window based SIR for COVID-19 forecasts

Zhifang Liao, Peng Lan, Zhining Liao, Yan Zhang, Shengzong Liu

Abstract

Since the outbreak of COVID-19, many COVID-19 research studies have proposed different models for predicting the trend of COVID-19. Among them, the prediction model based on mathematical epidemiology (SIR) is the most widely used, but most of these models are adapted in special situations based on various assumptions. In this study, a general adapted time-window based SIR prediction model is proposed, which is characterized by introducing a time window mechanism for dynamic data analysis and using machine learning method predicts the basic reproduction number and the exponential growth rate of the epidemic. We analyzed COVID-19 data from February to July 2020 in seven countries—China, South Korea, Italy, Spain, Brazil, Germany and France, and the numerical results showed that the framework can effectively measure the real-time changes of the parameters during the epidemic, and error rate of predicting the number of COVID-19 infections in a single day is within 5%.

Introduction

Epidemiological forecasting typically relies on either traditional mathematical models, such as the Susceptible-Infected-Removed (SIR) framework, or modern AI-based methods. Traditional SIR models often assume constant infection ($\beta$) and recovery ($\gamma$) rates, failing to account for dynamic shifts caused by social distancing or policy changes. Conversely, pure AI models often struggle with data scarcity during early pandemic stages and are prone to overfitting.

The TW-SIR model addresses this gap by integrating the interpretability of the SIR model with the adaptive flexibility of machine learning. By focusing on the most recent data trends through a sliding window, the model maintains structural integrity while adapting to real-time changes in epidemic dynamics.

Methods

The TW-SIR framework operates through three primary steps:

1. Numerical Solution

The model utilizes the fourth-order Runge-Kutta (RK4) method to provide high-precision numerical approximations of the SIR ordinary differential equations (ODEs). This allows for a day-to-day simulation of population shifts between susceptible, infected, and recovered states.

2. Dynamic Parameter Evaluation

Rather than analyzing the entire historical dataset, the model employs a sliding time window ($W$) to calculate optimal $\beta$ and $\gamma$ values for the current period using a least-squares approach. This mechanism allows the model to prioritize current trends over outdated data.

Evaluation of model parameters using a sliding time window.

3. Machine Learning Forecasting

To stabilize predictions, the authors forecast two composite metrics using polynomial regression: the Basic Reproduction Number ($R_0 = \beta/\gamma$) and the Exponential Growth Rate ($Ex = \beta - \gamma$). These metrics provide smoother signals than raw infection/recovery rates, making them better targets for machine learning algorithms.

Machine learning-based prediction of epidemic parameters.

Results and Discussion

The model was evaluated using COVID-19 data from China, South Korea, Italy, Spain, Brazil, Germany, and France, as well as historical SARS data from 2003.

Key findings include:

  • High Accuracy: Single-day infection prediction errors remained consistently within 5% across all tested countries.
  • Adaptability: The model successfully tracked "second wave" outbreaks in Europe, where static models typically fail once a curve flattens and then rises again.
  • Optimal Windowing: The study found that optimal window sizes vary by region (e.g., 7 days for China vs. 4 days for Italy), reflecting different rates of change in public health dynamics and reporting.
  • Comparative Virulence: Analysis showed COVID-19's early $R_0$ was nearly double that of the 2003 SARS virus, quantifying its significantly more violent spread.

Conclusion

TW-SIR represents a pragmatic middle ground in epidemic forecasting. While it currently relies on reported confirmed cases and does not explicitly model asymptomatic carriers, its ability to combine the physics of disease spread with adaptive data science makes it a robust tool for real-time public health monitoring. Future work will explore more complex machine learning architectures to further refine the prediction of $R_0$ and $Ex$.

Summary updated

Abstract

Since the outbreak of COVID-19, many COVID-19 research studies have proposed different models for predicting the trend of COVID-19. Among them, the prediction model based on mathematical epidemiology (SIR) is the most widely used, but most of these models are adapted in special situations based on various assumptions. In this study, a general adapted time-window based SIR prediction model is proposed, which is characterized by introducing a time window mechanism for dynamic data analysis and using machine learning method predicts the basic reproduction number and the exponential growth rate of the epidemic. We analyzed COVID-19 data from February to July 2020 in seven countries---China, South Korea, Italy, Spain, Brazil, Germany and France, and the numerical results showed that the framework can effectively measure the real-time changes of the parameters during the epidemic, and error rate of predicting the number of COVID-19 infections in a single day is within 5%.
BibTeX
@inproceedings{liao2020tw,
  author = {Zhifang Liao and Peng Lan and Zhining Liao and Yan Zhang and Shengzong Liu},
  title = {{TW-SIR: time-window based SIR for COVID-19 forecasts}},
  booktitle = {Scientific},
  year = {2020},
  doi = {10.1038/s41598-020-80007-8},
}
Figure