top of page

How To Model The Coronavirus Part 2

Introduction


Hello and welcome to another post on modelling the Coronavirus outbreak. This is the second part of the modelling series and, so, if you haven't yet read the first part then please do! If you remember, in the last post, we set up our system of differential equations and explored how the 'R0' value comes from this system of equations. In this post, we are going to begin the actual modelling and we will draw on the previous knowledge that we have obtained.


Setting Up our Variables


We are now able to begin constructing our model. Personally, I am using Google Sheets to create it as it works very similar to Microsoft Excel but is free to use. Initially, I created a table with all the variables that will impact our model. I have included an image of this below (ignore the values of each variable for now!):

A table showing the initial variables of the program.
An image of the initial variables.

We have discussed the variables a, b, and c previously, and I will explain how to calculate the value of each variable later. The chance of death simply refers to the average proportion of individuals who die upon catching COVID-19. I took this to be 2% as several sources suggested that this is within the ballpark of the actual value within the United Kingdom. Obviously, no one, and certainly not me, can be certain as there are a lot of unreported cases (not everyone with COVID-19 is tested) but 2% is a fairly accurate estimate


Next, we have the 'incubation period'; this refers to how long it takes for COVID-19 symptoms to show and how long it takes for the individual to then begin self-isolation. Upon doing some research, I concluded that a reasonable estimate is 7 days. Keep in mind that these variables will outline the behaviour of the model before any lockdown restrictions are to be put in place and thus individuals may not be self-isolating already or practising strict social distancing. Subsequently, the next variable is essentially the wordy explanation of what the 'R' value is. We have met this variable in great detail in Part 1 and so I will not comment further on what it statistically means. I chose to take the value of R as 3 after reading the conclusions of several scientific studies, as well as what the WHO (World Health Organisation) has published.


The final four variables (SIRD) are very straightforward. I have assumed that everyone is susceptible for the virus, and, so, I took the initial value of S to be 56 million (the population of England). Moreover, I decided to begin the virus pandemic from only one infected individual and thus the value of I is initially 1. As no one has yet recovered or died from the virus, the initial values for R and D are 0 respectively.


Calculating The Value Of The Constants


This is the part of the model that is arguably the most important. Unlike before, I cannot really give a very detailed account on how to calculate these values as I simply used trial and error in order to find respective formulas that give values for a, b, and c, which result in values that agree with observation.


To calculate 'a', I divided the value of R by the incubation period, and then divided this value by the initial number of susceptibles. This is understandable as the infection rate depends on the number of individuals who are still susceptible to the disease as well as how long people take to realise that they have COVID-19 (i.e. how long it takes symptoms to develop) and thus begin self-isolation. In other words, I looked online for the typical 'R' value for the Coronavirus. I then calculated 'a' such that one initial person would infect 'R' number of people for the given period that they are infectious in their given population. Using google sheets, I created a function that calculates this for me and have included an image of this below:

An image showing how to calculate the constant 'a'.
Function to calculate 'a'.

Ignore the 'iferror' as this is just to ensure that the program continues to operate even if there is an error value (if you want to understand what it does in greater detail a simple google search is sufficient). Cell C8 refers to the value of R, C7 refers to the incubation period, and cell C9 refers to the number of susceptibles. The dollar signs, $, are used to ensure that the cells, C7 and C9, are always referenced.


Moving onto the recovery rate, 'b', we sustract the the chance of death from 1 and divide this by the incubation period. As aforementioned, I cannot give an extremely detailed reason why this works as it does as my method was slightly arbitrary, however I subtracted the chance of death (C6) from 1 and subsequently divided it by the incubation period (C7). This works on the basis that I know that, say 2% of people who catch the virus die from it, 98% of people must therefore recover. So if a person gets infected and they are infectious to others for 7 days (cell C7), then after 7 days 0.98 people should have recovered and 0.02 people should have died. I have included the formula for this below (this again uses an 'iferror'):

An image showing the formula to calculation 'b'.
Formula to calculate 'b'.

Finally, I used the same reasoning and methodology to calculate the value of 'c' and have included the formula for this below:

An image showing how to calculate 'c'.
Function to calculate 'c'.

You will know if you have computed the variables correctly as the value of each variable should be as seen in the image below:

This is an image showing the value of the initial variables.
An image of the initial variables and their values.

Setting Up The Table of Values


We can now begin working on our dataset as we have calculated the three fundamental constants for our system of differential equations. In addition to this, we have fully calculated the values for our initial variables. I would recommend using the exact same columns and rows as me as, this way, it will be easier to follow along with the creation of our model. I have included an image on the empty table that I will use throughout the construction of the model below (for reference the top-left cell is G1):

An image of the empty table of values that I will be using.
An image showing the empty table of values that I will be using.

Before we begin to fill up the table of values, we must remind ourselves of the system of differential equations that we will be utilising. If you have forgotten the mathematical theory behind this system of equations, please go back and read 'Part 1' of this series of post as a concrete understanding of what these equations do is key to creating an effective model.

Reminder of the differential equations that we will be using.
Reminder of the differential equations that we will be using.

Moreover, we will also use a set of iterative formulas for each of our variables. This is due to the fact that the new value of each respective variable (S, I, R, and D) depends on the current value (e.g. the number of infections at day 5) rather than the initial value for each variable (such as the number of infections at day 1). In order to incorporate this, we just need to add the current value of each variable to the current rate of change with respect to time of each said variable. This sounds complicated when using words to explain it; however, it is must easier to understand by looking at the formulas mathematically, which I have included in an image below:

An image showing the iterative formulae that we will use.
An image showing the iterative formulae that we will use.

Now, since we have reminded ourselves of the system of differential equations that we will be using and have understood the iterative formulas shown above, we can begin filling up the table with some values. Starting at cell G2, we can begin by filling up the days column as this is the most straightforward. Note, however, that cell G2 should be filled with a 0, denoting day 0 as the initial state of the model, rather than day 1. Bring this cell down until day 19 (I will explain why to stop at this particular point in time later). You should therefore have 20 cells filled in with the numbers 0 to 19.


Subsequently, we can turn our attention to the dS/dt column, starting at cell H2. We know that, from our differential equation for dS/dt, it is equivalent to -a * S * I. Thus, we can select cell H2 and enter the following function:

An image showing the function for dS/dt.
Function for dS/dt.

The dollar signs for cell C3 are essential as otherwise the formula will no longer refer to the value of the infection rate found in cell C3. Cells L2 and M2 will automatically change into cells L3 and M3 (and so on) once you drag cell H2 down and so the formula always considers the number of infected and susceptible individuals at that given day.


From here, we can now turn our attention to cell I2 and calculate the values for dI/dt. From our aforementioned system of differential equations, we know that the value of dI/dt is 'simply' aSI - bI - cI. We can also write this as -dS/dt - dR/dt - dD/dt. This will make the calculation for dI/dt a lot easier as we can just reference the cells for each respective differential equation, rather than having to recalculate the values in our formula. This can be neatly done using the formula below:

An image showing the formula to calculate dI/dt.
Function for dI/dt.

Once we have done that, we can go onto creating a formula for dR/dt. Remember that dR/dt is equal to b*I. Cell C4, which refers to the recovery rate 'b', will require dollar signs as we want the formula to refer to the constant value 'b'. We don't need any dollars signs for the cell that references the current number of infections (M2, in this case) as we want this value to change depending on the day that the function is considering. I have included an image of the formula below:

An image showing how to calculate dR/dt.
Formula for dR/dt.

The fourth, and final, differential equation is fairly simple to calculate. dD/dt is almost identical to dR/dt, but instead of the constant being 'b' it is 'c', which refers to the death rate. The function for dD/dt is as shown below:

An image showing how to calculate dD/dt.
Formula for dD/dt.

For each differential equation, you can just drag the cells down to Day 19. Now, we can focus on creating the respective formulas for each of our variables.


Focusing on Cells L2-O2, we can manually add in the values for each variable. The number of Susceptibles, which will be located in L2, is 56 million (5.60E+07). The initial number of infected people, as will be entered in M2, will simply be 1. The other two cells, referring to the number of recovered individuals and dead individuals, will be 0 respectively. If you are confused, have a look at the image below:

An image showing the values of the initial variables.
The values of our initial variables.

After manually adding the initial values for each variable, we can now create a formula that will automatically update the values of each variable according to the iterative formulas that we saw earlier. This is very easy to do as we have already created functions that calculate the value of each differential equation.


I will use the variable of 'S' as an example, and hopefully you will be able to figure out the reasoning behind the functions for each other variable - we will be working in Cell L3. From the iterative formulas, we can see that the new value of 'S' is simply the previous value of 'S' plus the previous value of dS/dt. Cell L2 refers to the previous value of the 'S' variable, and cell H2 refers to the value of dS/dt on the previous day. Therefore, we can just simply add these two cells together to get our new value of the variable 'S'. If we then drag this cell down to Cell L21 (the value of S on day 19), the formula will automatically update for each cell. Instead of constantly referring to, say, Cell L2, the formula will just refer to the value of S in the previous cell (for example, Cell L20 when we are working out the value of S on day 21) as well as the previous value of dS/dt. I have included an image of the formula below (remember to put this into Cell L3!):

An image showing the formula for the variable S.
Formula for the variable S.

I have also included below the formulas for the other three variables: I, R, and D. These are to be added into Cells M3, N3, and O3 respectively.

An image showing the formula for the variable I.
Formula for the variable I.

An image showing the formula for the variable R.
Formula for the variable R.

An image showing the formula for the variable D.
Formula for the variable D.

After filling in the formulas for each respective variable, drag the cell down to row 21 to calculate the value of each variable until, and including, day 19. For now, we will ignore the 'Infections' column. This column refers to the total number of infections since day 0, whereas the 'I' column refers to the current number of infections at that given point in time.


In order to check whether you have inputted the correct formulas, please have a look at my table of values for the first 19 days of the epidemic below:


An image showing the data for the first 19 days of the Coronavirus model (no infections column).
This is what your table should look like!

If you haven't got the exact same values, then you have made a mistake; please go through this post again, attempting to locate your error. If you are still stuck, don't hesitate to comment down below and I will be able to help you out as soon as possible.


Looking at the data, the number of infections has slowly risen to approximately 119, whereas the number of deaths has only reached 1 person. Keep in mind that this is only an approximation and is more for us to understand the process behind the mathematical modelling of epidemics. The 'R' value has been assumed to stay constant at 3 the entire time. However, in order to make things interesting, this model is going to assume that the country, in this case England, has imposed a lockdown as of Day 20. This is what we are going to look at in Part 3, as well as continuing our model even further.


I hope that you have enjoyed reading this post. Feel free to comment down below any questions that you may have and please share the post with your friends. Thank you very much and see you in Part 3!









343 views0 comments

Comments


bottom of page