Callysto.ca Banner

Open in Callysto

Bubonic Plage - SIR Model

Grade 11 Social Studies

We are interested in modelling a bubonic plague outbreak. We part from the assumption that the total population can be subdivided into a set of classes, each of which depends on the state of the infection. The SIR Model is the simplest one and, as its name suggests, it divides the population into three classes.

Outcomes:

  • Examine and visualize concepts and examples related to the bubonic plague.

  • Examine the timeline/map of the Black Death.

  • Visualize mathematical model that shows the recovery, infection, and removal rates.

The SIR Outbreak Model

Population Parameters

In this model, the total population is divided into three groups:

  • Susceptible: individuals that can become infected but haven’t been yet

  • Infected: individuals that are infected

  • Removed: individuals that are either dead or recovered

We are looking at the changes, over the course of an outbreak, of the numbers of these individuals, represented by \(S\), \(I\), and \(R\). In other words we want to understand how, as time passes, the number of individuals in each group changes.

Having a realistic model might be useful for predicting the long-term outcome of an outbreak and informing public health interventions.

If we can predict that the number of removed people will stay low and the number of infected people will quickly go down to zero, then there is no need to intervene and we can let the outbreak end by itself while only providing medical attention to the infected people.

Conversely if we predict a large increase of the numbers of infected and removed individuals, then the outbreak needs a quick intervention before it results in a large number of casualties. In a plague outbreak this intervention would, for example, be to make sure there is no contact between infected and susceptible people.

We now describe the SIR (Susceptible, Infected, Removed) mathematical model of an outbreak over time (for example every week). We write \(S_t, I_t, R_t\) to denote the number of susceptible, infected, and removed individuals at time point \(t\). \(t=1\) is the first recorded time point, \(t=2\) is the second and so on. We call time unit the time elapsed between two time points, for example a day or a week.

In this model, we assume that the total population is constant (so births and deaths are ignored) for the duration of the model simulation. We represent the total population size by \(N\), and so at any time point \(t\) we have $\(N=S_t + I_t + R_t\)$

Modelling the disease progression

We assume that transmission requires contact between an infected individual and a susceptible individual. We also assume that the disease takes a constant amount of time to progress within an infected individual until they are removed (die or recover). We need to define these two processes (infection and removal) and model how they impact the transition from the time \(t = (S_t,I_t,R_t)\) to the next state \(t + 1 = (S_{t+1},I_{t+1},R_{t+1})\).

SIR_1

The occurrences of new infections of is modelled using a parameter \(\beta\), that gives the proportion of contacts between susceptible people and infected people, during one time unit, that results in infection. Then we can describe the number of newly infected people as \(\dfrac{\beta S_t I_t}{N}\), where the term \(S_t I_t\) represents the set of all possible contacts between susceptible and infected individuals. We discuss this term later.

The occurrence of removals of infected people is modelled using a parameter denoted by \(\gamma\). It is defined to be proportion of infected individuals that die or recover between two time points. If we are given that the duration of an infection is \(T\) (i.e. how many time points it takes for an individual between infection and removal), then \(\gamma = \dfrac{1}{T}\).

SIR_2

Taking into account the rate of contact \(\beta\) and rate of removal \(\gamma\), then each group population changes within one unit of time as follows

\[\begin{split} \begin{align} S_{t+1} &= S_t - \dfrac{{\beta} S_t I_t}{N}\\ I_{t+1} &= I_t + \dfrac{{\beta} S_t I_t}{N} - \gamma I_t \\ R_{t+1} &= R_t + \gamma I_t\\ N&=S_t + I_t + R_t \end{align} \end{split}\]

These equations form the SIR model. They allow, from knowing the parameters of the model (\(\beta\) and \(\gamma\)) and the current state (\(S_t,I_t,R_t\)) of a population to predict the next states of the population for later time points. Such models are critical in our days for monitoring and controlling infectious diseases outbreaks.

Technical remarks.

First, note that the SIR model does not enforce that the values \(S_t,I_t,R_t\) at a given time point are integers. As \(\beta\) and \(\gamma\) are actually floating numbers, these values are actually most of the time not integers. This is fine as the SIR model is an approximate model and aims mostly at predicting the general dynamics of an outbreak, not the precise values for the number of susceptible, infected, and removed individuals.

Next, one can ask how to find the values of the parameters \(\beta\) and \(\gamma\) that are necessary to have a full SIR model.

As discussed above, the parameter \(\gamma\) is relatively easy to find from knowing how the disease progress in a patient, as it is mostly the inverse of the average time a patient is sick.

The parameter \(\beta\) is less easy to obtain. Reading the equations we can see that during a time point, out of the \(S_t\) susceptible individuals, the number that get infected is \((\dfrac{{\beta}}{N}) S_t I_t\). As mentioned above, the product \(S_t I_t\) can be interpreted as the set of all possible contacts between the \(S_t\) susceptible individuals and the \(I_t\) infected individuals and is often a large number, much larger than \(S_t\) and in the order of \(N^2\). The division by \(N\) aims to lower this number, mostly to normalize it by the total population, to make sure it is in order of \(N\) and not quadratic in \(N\). So in order for the number of newly infected individuals during a time unit to be reasonable, \(\beta\) is generally a small number between \(0\) and \(1\). But formally, if we pick a value for \(\beta\) that is too large, then the SIR model will predict value for \(S_t\) that can be negative, which is inconsistent with the modelled phenomenon. So choosing the value of \(\beta\) is the crucial step in modelling an outbreak.

# This function takes as input a vector y holding all initial values,
#    t: the number of time points (e.g. days)
#    beta: proportion of contacts that result in infections
#    gamma: proportion of infected that are removed
#    S1,I1,R1 = initial population sizes

def discrete_SIR(S1,I1,R1,t,beta,gamma):
    # Empy arrays for each class
    S = [] # susceptible population
    I = [] # infected population
    R = [] # removed population
    N = S1+I1+R1 # the total population
    
    # Append initial values
    S.append(S1)
    I.append(I1)
    R.append(R1)
    
    # apply SIR model: iterate over the total number of days - 1
    for i in range(t-1):
        S_next = S[i] - (beta/N)*((S[i]*I[i]))
        S.append(S_next)
        
        I_next = I[i] + (beta/N)*((S[i]*I[i])) - gamma*I[i]
        I.append(I_next)
        
        R_next = R[i] + gamma * I[i]
        R.append(R_next)
    
    # return arrays S,I,R whose entries are various values for susceptible, infected, removed 
    return((S,I,R))

Simulating a Disease Outbreak

To conclude we will use the widgets below to simulate a disease outbreak using the SIR model. You can choose the values of all the elements of the model (sizes of the compartments of the population at the beginning of the outbreak, parameters \(\gamma\) and \(\beta\), and duration in time units (days) of the outbreak. The default parameters are the ones from the Eyam plague outbreak.

The result is a series of three graphs that shows how the three components of the population change during the outbreak. It allows you to see the impact of changes in the parameters \(\gamma\) and \(\beta\), such as increasing \(\beta\) (making the outbreak progress faster) or reducing \(\gamma\) (decreasing the removal rate).

You can use this interactive tool to try to fit the SIR model to match the observed data.

import matplotlib.pyplot as plt
import numpy as np
from math import ceil

# This function takes as input initial values of susceptible, infected and removed, number of days, beta and gamma
# it plots the SIR model with the above conditions
def plot_SIR(S1,I1,R1,n,beta,gamma):
    
    # Initialize figure
    fig = plt.figure(facecolor='w',figsize=(17,5))
    ax  = fig.add_subplot(111,facecolor = '#ffffff')
    
    # Compute SIR values for our initial data and parameters
    (S_f,I_f,R_f) = discrete_SIR(S1,I1,R1,n,beta,gamma)    
    
    # Set x axis
    x = [i for i in range(n)]
   
    # Scatter plot of evolution of susceptible over the course of x days
    plt.scatter(x,S_f,c= 'b',label='Susceptible')
    
    # Scatter plot of evolution of infected over the course of x days
    plt.scatter(x,I_f,c='r',label='Infected')
    
    # Scatter plot of evolution of removed over the course of x days
    plt.scatter(x,R_f,c='g',label='Removed')

    # Make the plot pretty
    plt.xlabel('Time (days)')
    plt.ylabel('Number of individuals')
    plt.title('Simulation of a Disease Outbreak Using the SIR Model')
    legend = ax.legend()
    plt.show()
    
    # Print messages to aid student understand and interpret what is happening in the plot
    print("SIMULATION DATA\n")
    print("Beta: " + str(beta))
    print("Gamma: " + str(gamma))
    print("\n")
    print("Initial Conditions:")
    print("Total number of Susceptible: "  + str(ceil(S_f[0])))
    print("Total number of Infected: "  + str(ceil(I_f[0])))
    print("Total number of Removed: "  + str(ceil(R_f[0])))
    print("\n")
    print("After " + str(n) + " days:")
    print("Total number of Susceptible: "  + str(ceil(S_f[n-1])))
    print("Total number of Infected: "  + str(ceil(I_f[n-1])) )
    print("Total number of Removed: "  + str(ceil(R_f[n-1])))

# Tweaking initial Values
from ipywidgets import widgets, interact, interact_manual

# Set function above so that the user can set all parameters and manually start simulation
s = {'description_width': 'initial'}
interact(plot_SIR,
        S1 = widgets.IntSlider(value=254, min=200, max=1000, step=1, style=s, description="Susceptible Initial", 
                               disabled=False, orientation='horizontal', readout=True),
        I1 = widgets.IntSlider(value=7, min=0, max=500, step=1, style=s, description="Infected Initial",
                               disabled=False, orientation='horizontal', readout=True),
        R1 = widgets.IntSlider(value=0, min=0, max=500, step=1, style=s, description="Removed Initial",
                               disabled=False, orientation='horizontal', readout=True),
        n = widgets.IntSlider(value=112, min=0, max=500, step=1, style=s, description="Time (days)",
                              disabled=False, orientation='horizontal', readout=True),
        beta = widgets.FloatText(value=1.50, description=r'$ \beta$ parameter',
                                 disabled=False, style = s, step=0.01),
        gamma = widgets.FloatText(value=1.50, description= r'$ \gamma$ parameter',
                                  disabled=False, style=s, step=0.01)
        );

Answer 1

Since we are assuming the population is constant, and since \(S_1 = 254, I_1 = 7, R_1 = 0\), then \(S_1 + I_1 + R_1 = 254 + 7 + 0 = 261\).

Answer 2

We know that, on average, an individual will remain infected for approximately 11 days. This means that one individual moves to the removed class for every 11 days, and the rate of removal is \(\gamma = \frac{1}{11} = 0.0909...\).

Answer 3

The best value is approximately \(\beta = 0.14909440503418078\).

Conclusion

In this notebook we learned about the SIR discrete model to model an outbreak. We learned that this model is one of the simplest ones and that it separates the total population \(N\) (a constant) into three categories: Infected, Susceptible and Removed. We learned about rates of infection and removal and how this affects the number of individuals in each class.

We also ran a basic but realistic simulation of a bubonic plague outbreak of the Great Plague of London that took place in the village Eyam in 1665 and learned about the devastating effect this had on the population.

Callysto.ca License