HomeArticlesEpidemiology

Epidemic Model: SIR, R0 and the Herd Immunity Threshold

Two equations that explain why epidemics peak, why R0 sets the fate of an outbreak, and why herd immunity is a threshold, not a wall.

mysimulator teamUpdated June 2026≈ 8 min read▶ Open the simulation

Three boxes and two rates

The SIR model, formalised by Kermack and McKendrick in 1927, splits a population into three compartments - Susceptible, Infected, Recovered (immune, in this simplest version permanently) - and tracks how people flow between them with two ordinary differential equations. It ignores age, location and social structure entirely, yet it captures the core shape of almost every epidemic curve ever recorded: growth, peak, decline.

live demo · SIR compartments evolving as an agent population mixes and infects● LIVE
dS/dt = -β·S·I/N
dI/dt =  β·S·I/N - γ·I
dR/dt =  γ·I

β = transmission rate (contacts × probability of infection per contact)
γ = recovery rate = 1 / (average infectious period)
N = S + I + R = total population (constant)

R0: the number that decides everything

The basic reproduction number R0 = beta / gamma is the average number of secondary infections one infected person causes in a fully susceptible population. It sets the epidemic's fate: dI/dt is positive - the epidemic grows - exactly when beta times S/N exceeds gamma, which at the very start (S approximately N) simplifies to R0 greater than 1. Below that threshold, the initial infections simply die out. Above it, infections climb until susceptibles are depleted enough to pull the effective reproduction number Re = R0 times (S/N) back down to 1, which is precisely the epidemic's peak - not when everyone is infected, but when the pool of new susceptibles to infect has shrunk enough to balance recovery.

Herd immunity: a threshold, not a wall

An epidemic stops growing once S/N is less than 1/R0, so the herd immunity threshold is HIT = 1 - 1/R0 - the fraction of the population that needs to be immune (through infection or vaccination) for Re to fall to 1 even before anyone new gets infected. For R0 = 3 (roughly the range estimated for early SARS-CoV-2 variants without interventions), HIT is about 67%; for measles, with R0 often quoted between 12 and 18 due to its extreme contagiousness, HIT climbs to 92-95%, which is why measles vaccination coverage below about 95% reliably permits local outbreaks.

HIT = 1 - 1/R0
R0 = 2  → HIT = 50%
R0 = 3  → HIT = 67%
R0 = 6  → HIT = 83%
R0 = 15 → HIT ≈ 93%   (measles-range)

Vaccination changes the equations, not just the headline number

Vaccinating a fraction v of the population before an outbreak effectively moves v times N people directly from S to R before t = 0 (for a perfectly effective vaccine; a leaky one scales v by the vaccine's efficacy). This is the same mathematics as natural herd immunity, only front-loaded and without anyone having to get sick first - which is precisely why the herd immunity threshold formula doubles as a vaccination target. Crucially, herd immunity protects people who cannot be vaccinated at all (infants, the severely immunocompromised) purely by starving the chain of transmission around them; it is a population-level effect, not an individual guarantee.

Where the simple model bends

Real epidemics diverge from textbook SIR in ways worth knowing: immunity can wane (moving the model toward SIRS, with a return flow from R back to S), incubation periods add an Exposed compartment (SEIR) before someone becomes infectious, contact patterns are not uniform mixing (school-age children and healthcare workers do not have average numbers of contacts), and R0 itself is not a fixed biological constant - it depends on behaviour, density and season, which is exactly why interventions like distancing or masking work: they lower the effective beta, not the virus's intrinsic biology, and can push Re below 1 even without any vaccination at all.

Frequently asked questions

What does R0 actually mean?

R0 (the basic reproduction number) is the average number of new infections one infectious person generates in a population that is entirely susceptible, with no immunity and no interventions. If R0 is greater than 1 an epidemic can grow; if R0 is less than 1 it dies out on its own.

Why does an epidemic peak and decline instead of infecting everyone?

As susceptibles get infected and move to the recovered/immune compartment, the pool of people left to infect shrinks. The epidemic peaks exactly when the effective reproduction number falls to 1, after which each infectious person on average infects fewer than one new person and the outbreak recedes even though susceptibles remain.

How does the herd immunity threshold formula relate to vaccination targets?

Herd immunity threshold HIT = 1 - 1/R0 gives the immune fraction needed to push the effective reproduction number below 1. Vaccinating people moves them from susceptible to effectively recovered before an outbreak starts, so public health targets for vaccination coverage are usually set at or above this same threshold, adjusted for real vaccine efficacy.

Try it live

Everything above runs in your browser — open Epidemic Model and change the parameters while it is running. Nothing is installed, nothing is uploaded, the whole model lives in one tab.

▶ Open Epidemic Model simulation

What did you find?

Add reproduction steps (optional)