Basics of compartmental (SIR) models
Essentials
Compartmental models are mathematical models based on a set of ordinary differential equations (ODEs), where a population is divided into various groups corresponding to different states of infection. Commonly known as SIR models, individuals fall into three categories: Susceptible (S), where individuals are able to become infected; Infectious (I), where individuals are infected with a pathogen and are able to transmit it to others; and Recovered (R), where individuals are no longer infectious and cannot become infected (or have been "removed" from the population). The total population size is N and each letter represents the number of people included in the state at a particular time, N = S + I + R, and states can be represented as dynamic functions of time as S(t), I(t), and R(t).
Equations
In the ODEs for the SIR model, β is the infectious rate which determines the probability that a susceptible-infectious contact results in transmission, and γ is the recovery rate:
This simplified transmission model assumes that susceptible individuals become infected at a rate directly proportional to the relative number of susceptible and infectious individuals in the population. There are no spatial dynamics in the simplified SIR model, so individuals do not need to ‘contact’ an infected individual. Once an individual becomes infected, they are assumed to also be instantly infectious, and begin contributing to the rate at which other susceptible individuals become infected. Infectious individuals remain infectious, on average, 1/γ days until they ‘recover’ (or are removed from the population). Once recovered, they no longer contribute to transmission directly, but still count towards the total population.
Code
It's not necessary to understand this code to use it. The next steps will put it to work and plot the results.
Exploring disease dynamics
Every disease has basic properties that impact transmission dynamics. For an SIR model, these properties affect the rate at which individuals move to different states (e.g., susceptible, infectious, recovered). The following steps will exercise these properties.
Set the initial conditions
In a basic SIR model, the dynamics of transmission will be strongly influenced by the number of individuals who begin the simulation infected, as well as the number who can be infected, the susceptible individuals. In order for an epidemic to occur, there must be a large enough pool of both of these groups. As these are starting conditions, the number of recovered individuals should be 0.
5000 / 10000
2000 / 10000
3000 / 10000
Add disease complexity
While the basic SIR model is a powerful tool to understand the dynamics of numerous diseases, it cannot capture all the complexities present in pathogen transmission. In some cases, diseases have an extended latency period where individuals may be exposed to the pathogen (so they are infected), but not yet able to transmit the pathogen to others (they are not yet infectious). To account for this, the Exposed (E) state can be included in the compartmental model. Now, instead of SIR dynamics, the model experiences SEIR dynamics. Notice how outbreaks will take longer to occur with SEIR dynamics than with SIR dynamics. Set sigma (σ), the rate at which exposed individuals become infectious, to 0 for regular SIR dynamics, or to a value greater than 0 to create an SEIR model:
1000 / 10000
10 / 100
1 / 100
5 / 100
Considering immunity
For some diseases, recovery does not confer life-long immunity. Immunity can wane over time, such that an individual may move from the Recovered state back into the Susceptible state. Due to such waning immunity, the pool of susceptibles is replenished independently of birth rate, and diseases may persist over longer periods of time with individuals experiencing multiple infections. When waning immunity is incorporated into a transmission model, an SIR model becomes an SIRS model, an SEIR model becomes an SEIRS model, and an SI model becomes an SIS model.
The ODEs for the SEIR model can be written as follows:
Include control efforts
There can be multiple strategies for controlling disease outbreaks. One of the most common and successful methods is to use vaccination campaigns to reduce the pool of susceptibles. Vaccination not only confers immunity to the individual receiving the vaccine, but when a large enough proportion of the population is vaccinated, unvaccinated individuals receive protection through herd immunity. Herd immunity occurs when P > 1-(1/R0) where P = proportion vaccinated * vaccine efficacy.
25 / 100
Set the proportion vaccinated and the vaccine efficacy to achieve herd immunity. When vaccine efficacy is high, a smaller proportion of people may require vaccination in order for herd immunity to take effect. However, these numbers will also depend on how transmissible the pathogen is. For example, measles is extremely transmissible. So while vaccine efficacy is about 97%, the proportion of individuals requiring vaccination is 90-95% of the population.
Next steps
Further exercises
Explore the dynamics of disease transmission by manipulating the above parameters. See how the settings may be changed to either eradicate a disease (such that there are no infectious individuals) or to make a disease persist in a population. Pathogens will invade when the reproductive number, R0, is greater than 1. Recall that:
Infections will fade if there is not a large enough pool of susceptibles, as when S < γ/β.
To eradicate a disease, the proportion of susceptible must be reduced to 1/R0.