# the Susceptible-Infected-Recovered model

At the time of writing, it seems reasonable to say that mathematical modelling of disease spread has never been as topical or well-known amongst the general public. Many modellers and scientists have been contributing to our understanding of the Covid-19 pandemic, from research being conducted and published, to directly advising government policy, to public engagement and information. In the next few chapters we will cover the fundamentals of the mathematical models that are the basis of most of this modelling work. The models that have been used to advise governments are of course rather more detailed than those you will see here (and we’ll discuss some extensions as we go along), but there is a common engine behind them all.

Our first few models focussed on the dynamics of ecological populations. As part of this we have assumed that every individual within each population is identical. Such a generalisation has the benefit of reducing our model to a low number of variables. But often certain individuals within a population are fundamentally distinct from one another. In this case, we might want to divide our population up in to different compartments. The choice of how to divide our population is often dictated by the biological question we are seeking to address. For example we may wish to have an age-structured model, with adults and juveniles, or perhaps individuals with different roles in a population such as foragers or workers.

For the next few chapters we will focus on epidemic models, where we will need to use such a compartment model. Broadly, we will think about disease dynamics within populations of humans, animals or plants that act as hosts for diseases such as viruses or bacteria, often termed parasites or pathogens. We will initially assume we are interested in infectious diseases of human populations, and this will guide our model design. When thinking about the spread of disease through a population, while we might have some interest in the total population at any time, it is more likely that we want to know about individuals’ infection status – are they currently infected, for example. This will be the basis of our compartment model. Let’s draw a schematic diagram to picture this process:

Before a disease emerges, all individuals in the population are susceptible. Once exposed to the disease, individuals may then become infected (and also infectious). Finally, individuals will eventually fight off the disease to become recovered and immune.

This is the ‘SIR’ model (i.e. Susceptible, Infected, Recovered), and has been central to our understanding of disease dynamics in human populations since it was first proposed in the 1920s. Disease is transmitted by ‘direct contact’ between infected and susceptible hosts and is a ‘mass action’ process, meaning we do not take any account of contact networks and the risk of infection is proportional to the total density of infection in the population. When hosts have recovered, they gain immunity and cannot be infected again (this is a key aspect of vertebrate – and especially human – immune systems, but is not necessarily true of invertebrates, plants, etc. We will consider models more appropriate for such populations later). $\beta$ controls the rate at which contacts between $S$ and $I$ hosts cause infection, and $\gamma$ is the rate of recovery. A small personal pet peeve – $\beta$ itself is not a rate; it has the wrong units. In this initial example we have not included any birth or death processes, as we assume that infection happens at a much faster timescale than demography. By considering our schematic diagram above we can write down the dynamics of our system as a set of ODEs:

\begin{align} &\frac{dS}{dt} = -\beta SI\\ &\frac{dI}{dt} = \beta SI - \gamma I\\ &\frac{dR}{dt} = \gamma I \end{align}

with the total population, $N=S+I+R$. There are some useful definitions it is worth making at this point:

• $\beta I$ is often called the force of infection (this really is the rate of infection);
• $I/N$ gives the prevalence of infection;
• $1/\gamma$ is the infectious period.

One thing to spot is that $dN/dt = dS/dt+dI/dt+dR/dt=0$. This means that the total population stays at a constant size (if we stop and think for a moment you might realise that this was built into our model all along since we have no births, deaths or migration). We can argue that this is a reasonable assumption for a short epidemic outbreak in long-lived human populations. An advantage of this assumption is that we can eliminate one variable, with $R=N-(S+I)$ and ignore the $dR/dt$ equation. This is because since the total population is always $N$, once we’ve worked out the densities of $S$ and $I$ we can immediately calculate the remaining density who must be $R$. We therefore can write down the simplified model as,

\begin{align} &\frac{dS}{dt} = -\beta SI \\ &\frac{dI}{dt} = \beta SI - \gamma I \end{align}

# Analysis

Once again we have what looks to be a fairly simple set of ODEs (two variables and two parameters), but there exists no explicit solution due to the non-linear term $\beta SI$. However, we can again explore the qualitative behaviour of the model by identifying equilibria of the system, assessing their stability and sketching phase portraits.

First let’s look for equilibria. The only way both ODEs can be 0 simultaneously is if $I=0$ (and $S$ may take any value less than $N$). This means we have a line of non-isolated equilibria where there are no infected individuals in the population. This is another special case for stability as we would find that one of the eigenvalues is always zero. We will consider quite what is going on here when we sketch the phase portraits.

Before we do that, let us think a bit more about the general behaviour of the model. It is often the case with emerging diseases that they will eventually burn out, as we seem to be predicting here. But it is still important for us to know whether there can be an epidemic, when an initially small amount of infection causes a large outbreak of disease in the population (even if it eventually tends to zero). Taking this definition, for an epidemic to occur we need to have $dI/dt \gt 0$ initially. Before an outbreak, the initial densities are $S(0)\approx N,I(0)\approx0$. This gives,

$\begin{equation} \frac{dI}{dt}\approx(\beta N-\gamma)I \end{equation}$

This gives us a condition for an epidemic:

• $\beta N-\gamma\lt 0$ $\implies$ disease dies out.
• $\beta N-\gamma\gt 0$ $\implies$ epidemic.

So even though the ultimate dynamic is for the disease to die out, we can have an epidemic if the initial amount of infection outstrips the rate of recovery.

Let’s now draw phase portraits of our SIR model for the two scenarios we have found above. To find the nullclines we take,

\begin{align} &\frac{dS}{dt} = 0 \implies S=0, I=0\\ &\frac{dI}{dt} =0 \implies S=\frac{\gamma}{\beta},I=0 \end{align}

Exercises

Draw the two qualitatively different phase portraits for this system, one where $\gamma/\beta\gt N$ and one where $\gamma/\beta\lt N$.
Click for solution

The two plots are sketched below. The first thing to notice is that in both plots only a triangular region bounded by the axes and $I=N-S$ is feasible. That is because if we took other positive values of $S$ and $I$ we would have $S+I\gt N$ which would not be possible given our fixed population size. In both diagrams we can quickly see that $S$ should be decreasing everywhere (since $dS/dt\lt0$). In the first diagram we only have one region to worry about the qualitative direction of flow of $I$, since the vertical nullcline at $S=\gamma/\beta$ is outside the feasible region. In the second diagram we have two regions, towards the right $I$ increases and towards the left it decreases. Phase portraits of the SIR model. The blue lines give the infected nullclines and the red line the susceptible nullclines. The black line marks the region of biological feasibility, and the curves example trajectories.

Remember where two (different) nullclines intersect is necessarily an equilibrium. Since both ODEs give a nullcline at $I=0$ we reinforce the fact that we have a continuum of equilibria along the line $I=0$. Using our equations we can then find out in what regions $S$ and $I$ will be increasing or decreasing. Again, note it doesn’t matter that we can’t say precisely the direction of a trajectory anywhere on our plot; knowing the qualitative direction of travel gives us all the information that we need.

In the first case, the vertical nullcline at $S=\gamma/\beta$ does not appear in the feasible region, so actually has no impact on the dynamics. In fact we will always just drop down towards $I=0$ and the disease dying out. In the second case, the phase portrait is divided into two regions. If we start in a region to the right of the nullcline, the infected density initially increases – we have an epidemic – before crossing the vertical nullcline and approaching $I=0$ again. Therefore the equilibria where $S\lt\gamma/\beta$ appear to be locally stable (which it turns out is equivalent to the second eigenvalue being negative).

The divide between these two cases is whether $N\gt \gamma/\beta$ or not. We can rearrange this to the condition $\beta N/\gamma\gt 1$. This ration is known as $R_0$, so we have the if $R_0\gt1$ we get an epidemic but if $R_0\lt1$ the disease dies out.

# The basic reproductive ratio, $R_0$

There is a very strong chance you have heard the terms $R_t$ or $R_0$ in discussions about the speed of spread of Covid-19. We define $R_0=\beta N/\gamma$ as the basic reproductive ratio of the disease: ‘The average number of secondary infections caused by one infected host in an otherwise disease-free population.’ Note that $\beta N$ gives the total infections caused in a disease-free population, and $1/\gamma$ is the infectious period. So $R_0$ gives the number of infections caused by an individual in the time that it’s infected near the start of an epidemic. The more general term, $R_t=\beta S/\gamma$ gives the number of new infections per case later in the epidemic when many individuals have already been infected and/or recovered. Because $R_0$ has this rather intuititve definition, it is a value that can often be estimated or measured. A number of estimates for $R_0$ of different diseases are given below. Remember, this figure tells you (roughly) how many new people an infected person will infect.

Disease $R_0$
Flu 1-3
Covid-19 2-5
SARS 2-5
HIV 2-5
Smallpox 5-7
TB 8-10
Measles 12-18

Estimates of $R_0$ for some important human diseases.

# The epidemic curve

The phase portraits demonstrate again that an epidemic should always burn out and the population return to being disease-free. Interestingly the phase portraits also suggest that not all of the population will get infected during an epidemic, since we usually do not end with $S=0$ and $I=0$ (which would mean $R=N$). As we have already said, due to the non-linearity of the system we are unable to find an exact solution and therefore cannot say precisely what the dynamics should look like. However, it is useful to understand what the epidemic curve – the number of people infected over time – looks like. With some approximations it is possible to express this as a mathematical formula, but we shall just look at some numerical output as shown in the left-hand side of the figure. This gives a characteristic bell-shaped curve. This is in fact the sort of curve we see from data from many real-world epidemics, suggesting that even our simple model is capturing something fundamental about disease spread. In the right-hand side we show how the reproductive ratio $R_t$ changes during the epidemic. Notice that the peak of the epidemic is precisely at $R_t=1$. This will be important later when we discuss the idea of herd immunity. An epidemic curve based on a populaion of $N$=500,000 and $R_0=3$ and how the value of $R_t$ changes during the epidemic. The dashed line marks the peak of the epidemic, which is exactly when $R_t=1$.

Explore the model

Use the Python code below to explore the SIR model. In particular, this code will take an alternative approach by presenting the output from a stochastic simulation algorithm.

When using differential equations – as we are focussing on in this course – the models are deterministic meaning for the same parameter values and initial conditions you get the exact same dynamcis every time. In a stochastic model we account for variation in the parameters – for example in the ODE model a recovery rate of $\gamma=1/7$ is effectively interpreted as saying everyone recovers after exactly 7 days, whereas in a stochastic model we instead assume the recovery rate of each individual  is drawn from a distribution where 1/7 is the mean. This means we get slightly different time-courses every time we run the model.

The code below will run 20 stochastic simulations as well as the deterministic equivalent. How good an approximation is the deterministic model to the stochastic one? Can you think of ways you might communicate the variation in the time-courses to policy makers or the public? Try changing the value of $R_0$ to see how the behaviour and differences change.

Click for code

`# Import the necessary libraries`
`import numpy as np`
`import matplotlib.pyplot as plt`
`from scipy.integrate import solve_ivp`
`# Options to make the plot the right size`
`plt.rcParams['figure.figsize'] = [8, 4]`
`plt.rcParams.update({'font.size': 16})`
`#Parameter values`
`N=1000           `
`GAMMA=1/14`
`R0=2.5`
`BETA=R0*GAMMA/N`
```REPS=20 # Number of times to run the stochastic model ```
```I0=2 # Starting number of infected individuals ```
`# STOHASTIC MODEL CODE`
`# Function to count numbers in each compartment`
`def count_type(type):`
`    current_type=0;`
`    for i in range(0,N):`
`        for j in range(0,N):`
`            if grid[i,j]==type:`
`                current_type=current_type+1`
`    return current_type`
`# Function to check the current scale`
`def findscale():`
`    S=susceptibles[-1]`
`    I=infecteds[-1]`
`    #Set relative parameter values`
`    scale=GAMMA*I+BETA*S*I  `
`    return scale`
`# Main function`
`for reps in range(0,REPS):`
`    # Set initial conditions`
`    tsteps=`
`    infecteds=[I0]`
`    susceptibles=[N-I0]`
`    current_t=0`
`    # Main run of stochastic model`
`    while current_t<180:`
`        # Find time step`
`        scale=findscale()`
`        dt = -np.log(np.random.rand()) / scale`
`        current_t=tsteps[-1]`
`        tsteps.append(dt+current_t)`
`        #Find which event happens`
`        if np.random.rand()<GAMMA*infecteds[-1]/scale: #Event is recovery  `
`            infecteds.append(infecteds[-1]-1)`
`            susceptibles.append(susceptibles[-1])`
`        else: #Event is transmission`
`            infecteds.append(infecteds[-1]+1)`
`            susceptibles.append(susceptibles[-1]-1)`
`        if infecteds[-1]==0:`
`            break`
`    # Plot latest run `
`    if reps==0:`
`        plt.plot(tsteps,infecteds,':',color='blue',alpha=0.5,label='Stochastic model')`
`    else:`
`        plt.plot(tsteps,infecteds,':',color='blue',alpha=0.5)`
`# ODE MODEL`
`# Function to run model called 'disease'`
`def disease(t,x):`
`    sdot=-BETA*x*x`
`    idot=BETA*x*x-GAMMA*x`
`    return sdot, idot `
`# Time points to use in ODE model`
`ts=np.linspace(0,180,2000)`
`# Run ODE model using 'solve_ivp'`
`xx1=solve_ivp(disease,[ts,ts[-1]],[N-I0,I0],t_eval=ts) `
`# Plotting commands`
`plt.plot(ts,(xx1.y),'k',label='ODE model')    `
`plt.legend()`
`plt.xlabel('Time')`
`plt.ylabel ('No. Infected')`
`plt.xlim(0,180)`

Key Takeaways

• We can model diseases using a compartment framework called the SIR model.
• An epidemic will occur when $dI/dt$ is initially positive, but in the simplest model will always reach an equilibrium where $I=0$.
• We can measure how quickly a disease initially spreads using $R_0$, and this tells us with there will be an epidemic or not.

## Licence 