Understanding the SIR model calculator — concept and principle
This calculator runs the classic SIR epidemic model for a closed population from the basic reproduction number R₀, the infectious period and the starting numbers. It gives the size and timing of the peak, the final epidemic size, the herd-immunity threshold and the transmission and recovery rates. It is a teaching tool for epidemiology and mathematical modelling.
How it is calculated
dS/dt = −β S I; dI/dt = β S I − γ I; dR/dt = γ I
γ = 1 ÷ infectious period; β = R₀ × γ
Final size from S∞ = S₀ e^(−R₀(1 − S∞ − R₀,immune)), solved numerically
Herd-immunity threshold = 1 − 1 ÷ R₀
- Integrated with a 4th-order Runge–Kutta step of 0.05 day; S, I, R are population fractions.
The principle
Each infectious person infects susceptible people at a rate proportional to how many susceptibles remain, and recovers after an average infectious period. At the start almost everyone is susceptible, so each case causes about R₀ new cases and the epidemic grows. As susceptibles are used up, the effective reproduction number falls; when it drops below 1, cases start to decline. That happens once a fraction 1 − 1/R₀ is immune, but the epidemic overshoots this threshold, so the final size is larger.
Worked example
Default inputs: N = 1,000,000, 10 infectious, R₀ = 2.5, infectious period 7 days, no prior immunity, 365 days.
- γ = 1 ÷ 7 = 0.1429 per day; β = 2.5 × 0.1429 = 0.3571 per day.
- Peak: 233,488 infectious people (23.35%) on day 56.
- Final size: 89.3% of the population, 892,646 people; 10.7% never infected.
- Herd-immunity threshold = 1 − 1/2.5 = 60%; effective R at the start = 2.5.
| Basic reproduction number R₀ | Peak infectious at one time (people) |
|---|---|
| 0.625 | 10 |
| 1.25 | 21,493 |
| 1.88 | 131,414 |
| 2.5 | 233,488 |
| 3.12 | 315,384 |
| 3.75 | 380,866 |
| 5 | 478,108 |
How to read the result
The peak and final size show what an unmitigated epidemic would look like under the model's assumptions. Real epidemics are shaped by behaviour change, interventions, seasons and population structure, so actual outcomes differ, often a great deal. The model is useful for understanding thresholds and the effect of R₀, not for forecasting.
Common mistakes
- Treating the output as a forecast.
- Confusing R₀ with the effective reproduction number later in an outbreak.
- Assuming the final size equals the herd-immunity threshold.
Frequently asked questions
What is R₀?
The average number of people one case infects in a fully susceptible population.
Why does the epidemic overshoot the herd-immunity threshold?
Many people are still infectious when the threshold is reached, so infections continue.
What does the infectious period do?
It sets the recovery rate γ and, with R₀, the transmission rate β.
Can immunity at the start help?
Yes; enter the immune percentage to see a smaller and later peak.
Sources: W. O. Kermack and A. G. McKendrick, Proc. R. Soc. A 115, 700–721 (1927)