SIR Model Simulator: Understand Epidemic Dynamics

simulator beginner ~8 min
Loading simulation...
~80% total infected at R₀ = 2.5, 7-day recovery

With R₀ = 2.5 and a 7-day infectious period, the SIR model predicts about 80% of the population will eventually be infected. The epidemic peaks around day 45 with roughly 15% of the population simultaneously infected. The herd immunity threshold is 60% (1 - 1/2.5).

Formula

dS/dt = -β × S × I / N
dI/dt = β × S × I / N - γ × I
Herd immunity threshold: p_c = 1 - 1/R₀

Three Compartments, One Epidemic

The SIR model is the workhorse of mathematical epidemiology. It divides a population into three compartments: Susceptible individuals who can catch the disease, Infected individuals who can transmit it, and Recovered individuals who are immune. Two coupled differential equations govern the flow between compartments — the transmission rate β moves people from S to I, and the recovery rate γ moves them from I to R. From these simple rules, the characteristic epidemic curve emerges.

R₀ Controls Everything

The basic reproduction number R₀ = β/γ is the single most important parameter in epidemiology. It represents the average number of secondary infections caused by one infected individual in a fully susceptible population. When R₀ > 1, the infected compartment grows initially. When R₀ < 1, the outbreak decays. The epidemic peaks when enough people have recovered that the effective reproduction number R_t = R₀ × S/N drops below 1 — this is the herd immunity threshold, reached when a fraction 1 - 1/R₀ of the population is immune.

The Epidemic Curve

The SIR model produces the familiar bell-shaped epidemic curve for the I compartment. The curve's height (peak prevalence) and timing (peak day) depend on R₀, the recovery rate, and the initial number of infections. Higher R₀ produces taller, earlier peaks. Longer infectious periods stretch the curve out but also increase total infections. The S curve monotonically decreases while R monotonically increases, and their final values reveal the total epidemic size.

From Theory to Intervention

This simulation integrates the SIR equations in real time, drawing all three compartments as animated curves. Drag the R₀ slider to see how transmissibility reshapes the epidemic. Increase the infectious period to see the curve broaden. The peak infected readout shows when healthcare capacity would be most stressed — the central concern of pandemic planning and the motivation behind curve-flattening interventions.

FAQ

What is the SIR model?

The SIR model is a compartmental model that divides a population into three groups: Susceptible (S), Infected (I), and Recovered (R). People move from S to I at rate β×S×I/N (transmission) and from I to R at rate γ×I (recovery). The model was formulated by Kermack and McKendrick in 1927 and remains the foundation of mathematical epidemiology.

What does R₀ mean and why does it matter?

R₀ (R-naught) is the basic reproduction number — the average number of secondary infections caused by one infected person in a fully susceptible population. If R₀ > 1, an epidemic grows. If R₀ < 1, it fades. R₀ depends on the pathogen's infectivity, duration of infectiousness, and contact rate. COVID-19 had R₀ ≈ 2.5-3.5; measles has R₀ ≈ 12-18.

How does the SIR model predict epidemic size?

The final size equation states that the fraction of the population ultimately infected satisfies: R_final = 1 - exp(-R₀ × R_final). For R₀ = 2.5, about 89% get infected. The model assumes homogeneous mixing, no behavioral change, and permanent immunity — real epidemics are more complex but the SIR model captures the essential dynamics.

What are the limitations of the SIR model?

The basic SIR model assumes homogeneous mixing (everyone contacts everyone equally), permanent immunity, no births or deaths, no latent period, and no behavioral change during the epidemic. Extensions include SEIR (adding an Exposed compartment), SIRS (waning immunity), age-structured models, and network models that capture heterogeneous contact patterns.

Sources

Embed

<iframe src="https://homo-deus.com/lab/epidemiological-modeling/sir-model/embed" width="100%" height="400" frameborder="0"></iframe>
View source on GitHub