TL;DR
This lesson is an explanation of a mathematical model. It is not medical advice.
A compartmental model divides a population into groups, called compartments, according to their disease state. The classic version uses susceptible (S), infected (I) and recovered (R) people. It then writes a differential equation for how fast people flow from one compartment to the next, so the whole outbreak becomes a small system of equations that can be solved or simulated. The model is simple on purpose: it captures the feedback between how many people can be infected and how many are infected, and little else.
Where you'll see it: forecasting how an outbreak might grow, comparing vaccination strategies, and estimating the basic reproduction number that many public health analyses start from.
Intuition
Buckets and flows
Picture the population as three buckets of water. The first bucket holds the people who can still catch the disease. The second holds the people currently sick and able to pass it on. The third holds the people who have recovered and are protected for now. Infection moves water from the first bucket to the second. Recovery moves it from the second to the third. Nothing else changes the totals, so the three buckets always add up to the population.
The rates of flow depend on the state of the buckets. The more people are infected, the faster new infections happen, because each infected person meets susceptible people. That feedback is what makes an outbreak rise and fall, and it is the reason a differential equation is the natural description. A model with constant rates of change cannot produce a peak.
Why compartments at all
Tracking every person and every contact is impossible for a whole country, and most of the detail does not change the big picture. Grouping people by state turns a huge problem into a handful of numbers. Each compartment is an average, and the model answers questions about averages: how large the peak is, when it arrives, and how much faster it moves if the transmission rate drops. The price is that the model assumes people in a compartment are alike, which is only roughly true.
The flow
flowchart LR S[Susceptible] -->|infection| I[Infected] I -->|recovery| R[Recovered]
The math
Let be the total population, and let , and be the numbers of susceptible, infected and recovered people at time in days. Then at all times. Two rates describe the flow. The transmission rate is the number of new infections per infected person per day when everyone is susceptible. The recovery rate is the fraction of infected people who recover each day, so an average infection lasts days.
The equations are
The term is the rate of new infections. It is proportional to the number of susceptible people times the number of infected people, divided by , because the chance that a given contact is with an infected person is . These are ordinary differential equations (see Ordinary Differential Equation), with the three compartments as the unknowns.
Checking the equations add up
Add the three derivatives. The infection term appears once with a minus sign in and once with a plus sign in , so it cancels. The recovery term appears with a minus sign in and a plus sign in , so it cancels too. The sum is zero, which means stays constant. This is the conservation law that makes the model consistent.
The basic reproduction number
At the start of an outbreak almost everyone is susceptible, so . The infected group then grows at rate per day, from the equation for . The ratio
is the basic reproduction number. It is the average number of secondary infections caused by one infected person in a fully susceptible population, and it is the quantity that decides whether the outbreak grows. If , the infected count rises at the start. If , it falls from the start.
The herd immunity threshold
Infection grows only while is large enough. Setting with gives at the peak. The fraction of the population that must be immune for the outbreak to stop growing is therefore
This is the herd immunity threshold in this simple model. Real populations are not uniform and immunity is not perfect, so the threshold is an approximation.
Worked examples
Take a population of with one infected person, so , , and nobody has recovered yet. Use per day and per day, so . Use a one-day Euler step, which replaces each derivative by its value at the start of the day. This is crude, but it is easy to follow.
- Compute the new infections. .
- Compute the recoveries. .
- Update the compartments. , , and .
- Check the total. , so the population is conserved.
Interpretation: the infected count grew from 1 to about 1.2 in one day. The per-day growth factor at the start is , which matches through . A finer step would give a more accurate curve, but the first step already shows the feedback: the new infections depend on the number of infected people at that moment.
Keep from the last example and ask what fraction must be immune.
- Use the threshold formula. .
- Convert to a number of people. In a population of 1000 this is immune people.
- Compare with a smaller . If , then , and only 500 immune people are needed.
- Consider a larger . If , then , so five people in six must be immune.
Interpretation: the threshold rises steeply as grows, because each extra infection per case makes the outbreak harder to stop. Diseases with a large , such as measles, need very high immunity, which is why estimates of matter so much. The model gives the threshold; it does not say how a real campaign should be designed.
Tradeoffs and failure modes
The SIR model is useful because it is small enough to solve, understand and fit. Its assumptions also set its limits.
| Situation | What goes wrong | Better choice |
|---|---|---|
| People are not mixing uniformly | A single hides differences between age groups, places and contact patterns | Age-structured or network models |
| Infection has a long incubation period | The model assumes infected people transmit at once, so it misses the lag | Add an exposed compartment, giving an SEIR model |
| People lose immunity | Recovered people never return to susceptible in the basic model, so long-run predictions are too optimistic | Add a return flow, giving an SIRS model |
| and change over time | Constant rates miss behaviour changes and interventions | Time-varying rates, fitted to data |
| Small populations | The equations describe averages, but chance dominates when counts are small | Stochastic compartmental models |
Estimates of are sensitive to these assumptions. Two studies of the same disease can give different values because they use different contact structures or different definitions of the infectious period. A large difference in therefore does not always mean a large difference in the disease itself.
History
The model was introduced in 1927 by William Ogilvy Kermack and Anderson Gray McKendrick, who studied the Bombay plague epidemic and other outbreaks. They wrote down the susceptible, infected and recovered groups and showed that an epidemic only grows when enough susceptible people are available. Their result is the threshold idea behind and herd immunity.
Later work extended it with exposed compartments, age structure and networks, and it became a standard tool in infectious disease planning. The basic equations have stayed the same in most of these extensions.
Check yourself
QuestionIn the SIR model, what does the term beta S I / N represent, and why does it depend on I?Show answer
It is the rate of new infections. It depends on I because each infected person makes contact with susceptible people at a rate that scales with how many infected people there are. More infected people means more transmission, which is the feedback that drives an outbreak.
QuestionA disease has beta = 0.5 per day and gamma = 0.25 per day. Compute R0 and the herd immunity threshold.Show answer
R0 = beta / gamma = 0.5 / 0.25 = 2. The threshold is 1 - 1/R0 = 1 - 1/2 = 0.5, so about half the population must be immune for the outbreak to stop growing in this model.
QuestionWhy does the sum S + I + R stay constant in the SIR equations?Show answer
Each flow appears once with a minus sign and once with a plus sign. The infection flow leaves S and enters I, and the recovery flow leaves I and enters R. Adding the three derivatives therefore cancels every flow, so the total does not change.
QuestionUsing the one-day Euler step with N = 1000, S = 999, I = 1, beta = 0.3 and gamma = 0.1, how many people are infected after one day under this model?Show answer
The new infections are 0.3 x 999 x 1 / 1000 = 0.2997, and the recoveries are 0.1 x 1 = 0.1. The infected count becomes 1 + 0.2997 - 0.1 = 1.1997, about 1.2.
QuestionA model with a long incubation period gives a much earlier peak than observed. Which assumption of the basic SIR model is most likely responsible, and what change would address it?Show answer
The basic model assumes that people become infectious as soon as they are infected, with no delay. A long incubation period means the real epidemic is slower to build, so the peak arrives later. Adding an exposed compartment, which gives an SEIR model, captures the delay before infected people can transmit.
Sources
- Wikipedia: Compartmental models in epidemiology
- Wikipedia: Herd immunity