Toolyard

SIR and SEIR Epidemic Models: R₀, Herd Immunity and Flattening the Curve

Compartment models

In 1927 William Kermack and Anderson McKendrick described an epidemic by sorting everyone into a few groups and following how people move between them. In the SIR model everyone is susceptible (S), infectious (I) or recovered (R) and immune. The SEIR model adds an exposed group (E) for people who have caught the infection but cannot pass it on yet. For a town of N people:

dS/dt = −βSI ÷ N,   dE/dt = βSI ÷ N − σE,   dI/dt = σE − γI,   dR/dt = γI

  • β is the number of infectious contacts an infectious person makes a day. A contact with a susceptible person, a share S ÷ N of the town, passes the infection on.
  • σ is 1 ÷ the incubation (latent) period. In SIR there is no E and new cases are infectious at once.
  • γ is 1 ÷ the infectious period.

R₀ and the effective reproduction number

The basic reproduction number R₀ is the number of people one case infects, on average, when everyone else is susceptible. In these models R₀ = β ÷ γ: contacts a day times days infectious. Above 1 the outbreak can grow; below 1 every chain of infection dies out.

As people recover and become immune, each case finds fewer people to infect. The effective reproduction number is R_t = R₀ × S ÷ N. The epidemic peaks at the moment R_t falls to 1, when a share 1 ÷ R₀ of the town is still susceptible, and shrinks after that. Measures that cut contacts lower R_t further.

Herd immunity

If a share p of the population is immune before an outbreak starts, R_t starts at R₀ × (1 − p). The outbreak cannot grow if that is below 1, so the herd immunity threshold is

p = 1 − 1 ÷ R₀

Half the population for R₀ = 2, two thirds for R₀ = 3, and about 92% to 95% for measles, whose R₀ is about 12 to 18. Immune people protect the others by breaking chains of infection.

The final size

An outbreak does not stop at the herd immunity threshold: at the peak many people are still infectious and go on infecting others, so it overshoots. The share s that is never infected satisfies the final size equation

ln(1 ÷ s) = R₀ × (1 − s)

for a fully susceptible town. It has no algebraic solution, but it can be solved step by step. The answer is the same for SIR and SEIR: the incubation period changes when the cases come, not how many there are.

A worked example

The simulation starts with R₀ = 3, an incubation period of 3 days and an infectious period of 7 days, in a town of 1,000 with 5 infectious people.

  1. γ = 1 ÷ 7 = 0.143 per day, so β = R₀ × γ = 0.429 infectious contacts per day.
  2. Herd immunity threshold: 1 − 1 ÷ 3 = 0.667, or 667 people.
  3. Final size: try s = 0.06: ln(1 ÷ 0.06) = 2.81 and 3 × 0.94 = 2.82, close enough. About 94% of the town catches it, far more than the 67% threshold.
  4. Early growth in SIR: cases rise at β − γ = 0.286 per day, doubling every ln 2 ÷ 0.286 = 2.4 days. The incubation period slows this down.
  5. In the equations the SIR outbreak peaks on about day 21; with the 3-day incubation period, about day 36.

Vaccinate half the town first and R_t starts at 1.5: about 30% of the town is infected. Vaccinate 70%, above the threshold, and the outbreak fizzles out after a few dozen cases.

Flattening the curve

Distancing cuts β, and quarantine stops a share of cases from infecting anyone. Both lower the effective R₀. With contacts halved, R₀ = 3 becomes 1.5: the peak is far lower and later, and the final size falls from 94% to about 59%, because the outbreak overshoots the lower threshold by less. Keeping the peak low matters for hospitals, which can only treat so many people at once.

Using the simulation

In the Epidemic Spread Simulator: SIR and SEIR, things to try:

  • Run the defaults and compare the town, in solid lines, with the equations, dashed. Note the day R_t drops below 1 and compare it with the peak.
  • Set the incubation period to 0 for SIR: the outbreak comes sooner and faster, but the final size is the same.
  • Vaccinate 60%, then 70%: the threshold for R₀ = 3 lies between.
  • Put 50% of cases in quarantine and compare with 50% distancing: both halve R₀.
  • Set R₀ to 1.2 and the town to 200 people with one case: some runs die out at once, some spread.

What the model assumes

  • Homogeneous mixing: every infectious person is equally likely to meet anyone in the town; no households, schools or networks.
  • Everyone is alike: the same susceptibility, the same contacts, the same infectious period.
  • Exponential waiting times: each exposed or infectious person has the same chance of moving on each day, so some recover in a day and some take weeks, with the right average.
  • Lasting immunity: recovered and vaccinated people never catch it again, and vaccination is perfect.
  • A closed town: no births, deaths, travel or deaths from the disease, over a single outbreak.
  • Quarantine catches a fixed share of cases the moment they become infectious and holds them until they recover; distancing cuts every contact by the same share.

Edge cases

  • R₀ below 1: each chain of infection dies out, on average after 1 ÷ (1 − R₀) cases: ten for R₀ = 0.9, two for R₀ = 0.5.
  • R₀ just above 1: in a small town many outbreaks die out by chance before they take off, even though the equations predict an epidemic. With one case and R₀ = 1.2, most runs die out early.
  • Vaccination above the threshold: R_t starts below 1, so the outbreak cannot grow, though some unvaccinated people may still be infected.
  • Very high R₀: for R₀ = 12, nearly everyone not immune is infected.
  • Incubation period of 0: SEIR becomes SIR.
  • Everyone in quarantine: no one can infect anyone, and the outbreak ends with the first cases.

Where the model stops being right

  • Superspreading. For many diseases a few cases cause most infections and most cause none. Outbreaks then die out by chance more often, but the ones that survive can explode.
  • Structure. People meet household members and coworkers repeatedly. Clustered contacts slow the spread and lower the final size compared with random mixing, and age groups mix in very different ways.
  • Behavior changes. People cut their contacts when cases rise and relax when they fall, so R_t does not follow the model's simple path.
  • Immunity wanes for flu, the common cold and COVID-19, and viruses evolve to escape it; outbreaks then return in waves, which needs an SIRS model.
  • Waiting times are not exponential. Real incubation and infectious periods cluster around their averages. That changes the timing and the peak, but not the final size.
  • Asymptomatic and presymptomatic spread. Quarantine only works on cases that are found; spread before symptoms makes it far less effective than this model suggests.
  • R₀ is not a fixed property of a germ. It depends on how people live and meet, so estimates vary between places and studies.

Related tools

The early rise of an epidemic is exponential, like the growth in the Bacterial Growth Simulator; the Cell Doubling Time Calculator finds its doubling time, as in How to Calculate Cell Doubling Time. The Percentage Calculator turns case counts into shares of a population. The Predator and Prey Population Simulator uses the same mass-action idea for foxes catching rabbits.

Tools in this guide

More guides