Compartmental models are a mathematical framework used to simulate how populations move between different states or "compartments". While widely applied in various fields, they have become particularly fundamental to the mathematical modelling of infectious diseases. In these models, the population is divided into compartments labeled with shorthand notation – most commonly S, I, and R, representing Susceptible, Infectious, and Recovered individuals. The sequence of letters typically indicates the flow patterns between compartments; for example, an SEIS model represents progression from susceptible to exposed to infectious and then back to susceptible again.
These models originated in the early 20th century through pioneering epidemiological work by several mathematicians. Key developments include Hamer's work in 1906, Ross's contributions in 1916, collaborative work by Ross and Hudson in 1917, the seminal Kermack and McKendrick model in 1927, and Kendall's work in 1956. The historically significant Reed–Frost model, though often overlooked, also substantially influenced modern epidemiological modeling approaches.
Most implementations of compartmental models use ordinary differential equations (ODEs), providing deterministic results that are mathematically tractable. However, they can also be formulated within stochastic frameworks that incorporate randomness, offering more realistic representations of population dynamics at the cost of greater analytical complexity.
Epidemiologists and public health officials use these models for several critical purposes: analyzing disease transmission dynamics, projecting the total number of infections and recoveries over time, estimating key epidemiological parameters such as the basic reproduction number (R0) or effective reproduction number (Rt), evaluating potential impacts of different public health interventions before implementation, and informing evidence-based policy decisions during disease outbreaks. Beyond infectious disease modeling, the approach has been adapted for applications in population ecology, pharmacokinetics, chemical kinetics, and other fields requiring the study of transitions between defined states. For such investigations and to consult decision makers, often more complex models are used.
SIR model
The SIR model is one of the simplest compartmental models, and many models are derivatives of this basic form. The model consists of three compartments: S: The number of susceptible individuals. When a susceptible and an infectious individual come into "infectious contact", the susceptible individual contracts the disease and transitions to the infectious compartment. I: The number of infectious individuals. These are individuals who have been infected and are capable of infecting susceptible individuals. R for the number of removed (and immune) or deceased individuals. These are individuals who have been infected and have either recovered from the disease and entered the removed compartment, or died. It is assumed that the number of deaths is negligible with respect to the total population. This compartment may also be called "recovered" or "resistant".
This model is reasonably predictive for infectious diseases that are transmitted from human to human, and where recovery confers lasting resistance, such as measles, mumps, and rubella.
These variables (S, I, and R) represent the number of people in each compartment at a particular time. To represent that the number of susceptible, infectious, and removed individuals may vary over time (even if the total population size remains constant), we make the precise numbers a function of t (time): S(t), I(t), and R(t). For a specific disease in a specific population, these functions may be worked out in order to predict possible outbreaks and bring them under control. Note that in the SIR model, and are different quantities – the former describes the number of recovered at t = 0 whereas the latter describes the ratio between the frequency of contacts to the frequency of recovery.
As implied by the variable function of t, the model is dynamic in that the numbers in each compartment may fluctuate over time. The importance of this dynamic aspect is most obvious in an endemic disease with a short infectious period, such as measles in the UK prior to the introduction of a vaccine in 1968. Such diseases tend to occur in cycles of outbreaks due to the variation in number of susceptibles (S(t)) over time. During an epidemic, the number of susceptible individuals falls rapidly as more of them are infected and thus enter the infectious and removed compartments. The disease cannot break out again until the number of susceptibles has built back up, e.g. as a result of offspring being born into the susceptible compartment.
Each member of the population typically progresses from susceptible to infectious to recovered. This can be shown as a flow diagram in which the boxes represent the different compartments and the arrows the transition between compartments (see diagram).
Transition rates For the full specification of the model, the arrows should be labeled with the transition rates between compartments. Between S and I, the transition rate is assumed to be , where is the total population, is the average number of contacts per person per time, multiplied by the probability of disease transmission in a contact between a susceptible and an infectious subject, and is the fraction of all possible contacts that involves an infectious and susceptible individual. (This is mathematically similar to the law of mass action in chemistry in which random collisions between molecules result in a chemical reaction and the fractional rate is proportional to the concentration of the two reactants.)
Between I and R, the transition rate is assumed to be proportional to the number of infectious individuals which is . If an individual is infectious for an average time period , then . This is also equivalent to the assumption that the length of time spent by an individual in the infectious state is a random variable with an exponential distribution. The "classical" SIR model may be modified by using more complex and realistic distributions for the I-R transition rate (e.g. the Erlang distribution).
For the special case in which there is no removal from the infectious compartment (), the SIR model reduces to a very simple SI model, which has a logistic solution, in which every individual eventually becomes infected.
The SIR model without birth and death
The dynamics of an epidemic, for example, the flu, are often much faster than the dynamics of birth and death, therefore, birth and death are often omitted in simple compartmental models. The SIR system without so-called vital dynamics (birth and death, sometimes called demography) described above can be expressed by the following system of ordinary differential equations:
where is the stock of susceptible population in unit number of people, is the stock of infected in unit number of people, is the stock of removed population (either by death or recovery) in unit number of people, and is the sum of these three in unit number of people. is the infection rate constant in the unit number of people infected per day per infected person, and is the recovery rate constant in the unit fraction of a person recovered per day per infected person, when time is in unit day.
This model was for the first time proposed by William Ogilvy Kermack and Anderson Gray McKendrick as a special case of what we now call Kermack–McKendrick theory, and followed work McKendrick had done with Ronald Ross.
This system is non-linear, however it is possible to derive its analytic solution in implicit form. Firstly note that from:
it follows that:
expressing in mathematical terms the constancy of population . Note that the above relationship implies that one need only study the equation for two of the three variables.
Secondly, we note that the dynamics of the infectious class depends on the following ratio:
the so-called basic reproduction number (also called basic reproduction ratio). This ratio is derived as the expected number of new infections (these new infections are sometimes called secondary infections) from a single infection in a population where all subjects are susceptible. This idea can probably be more readily seen if we say that the typical time between contacts is , and the typical time until removal is . From here it follows that, on average, the number of contacts by an infectious individual with others before the infectious has been removed is:
By dividing the first differential equation by the third, separating the variables and integrating we get
where and are the initial numbers of, respectively, susceptible and removed subjects. Writing for the initial proportion of susceptible individuals, and and for the proportion of susceptible and removed individuals respectively in the limit one has
(note that the infectious compartment empties in this limit). This transcendental equation has a solution in terms of the Lambert function, namely
This shows that at the end of an epidemic that conforms to the simple assumptions of the SIR model, unless , not all individuals of the population have been removed, so some must remain susceptible. A driving force leading to the end of an epidemic is a decline in the number of infectious individuals. The epidemic does not typically end because of a complete lack of susceptible individuals.
The role of both the basic reproduction number and the initial susceptibility are extremely important. In fact, upon rewriting the equation for infectious individuals as follows:
it yields that if:
then:
i.e., there will be a proper epidemic outbreak with an increase of the number of the infectious (which can reach a considerable fraction of the population). On the contrary, if
then
i.e., independently from the initial size of the susceptible population the disease can never cause a proper epidemic outbreak. As a consequence, it is clear that both the basic reproduction number and the initial susceptibility are extremely important.
The force of infection
Note that in the above model the function:
models the transition rate from the compartment of susceptible individuals to the compartment of infectious individuals, so that it is called the force of infection. However, for large classes of communicable diseases it is more realistic to consider a force of infection that does not depend on the absolute number of infectious subjects, but on their fraction (with respect to the total constant population ):
Capasso and, afterwards, other authors have proposed nonlinear forces of infection to model more realistically the contagion process.
Exact analytical solutions to the SIR model In 2014, Harko and coauthors derived an exact so-called analytical solution (involving an integral that can only be calculated numerically) to the SIR model. In the case without vital dynamics setup, for , etc., it corresponds to the following time parametrization
for
with initial conditions
where satisfies . By the transcendental equation for above, it follows that , if and .
An equivalent so-called analytical solution (involving an integral that can only be calculated numerically) found by Miller yields
Here can be interpreted as the expected number of transmissions an individual has received by time . The two solutions are related by .
Effectively the same result can be found in the original work by Kermack and McKendrick.