Computational Modeling of Coronavirus

COVID-19 Questions

When will the coronavirus pandemic end? How many people will get sick? How effective are plane flight and quarantine restrictions? Many of these questions can be addressed with computational modeling. Let’s look at a few computational models, each of which builds on the previous, to see how such models are made and what we can and cannot learn from them.

SIR Model

A standard approach to modeling disease like COVID-19 is what is called the SIR model. Here, S stands for the number of susceptibles; that is, the number of people who can get the disease. For a disease like COVID-19 it is believed that most of us can get it. Why? Because this virus appears to be new in humans, we have not had the chance to build up any immunity yet. So, we are all S. The I stands for infectious, and these are the people who are transmitting the disease to the S and making them an I. Finally, the R are the recovered. These are the people who had the disease and are now immune to it. Models like the SIR are sometimes called “compartmental models” because we assign each person in the population into one of the S, I or R compartments where they are otherwise treated equally. More on that later.

The mathematical approach most often used for the SIR model is a differential equation model. Differential equations are useful for modeling things that are changing, which is exactly what we want to do. The SIR is expressed as


where there are two parameters that describe the infectivity (beta) and the recovery rate (gamma). Note the terms that depend on the product of S and I; it is that term that describes an I encountering an S and making them sick, perhaps through a cough or a sneeze.  If we knew the two parameters in this SIR model for COVID-19, we could solve these equations and have a prediction for how the pandemic will play out. Before we do that, let’s see if there are any insights we can get just from the general structure of the model.

The numerical solution of these equations always has a form that looks like this:


The details depend on the two parameters beta and gamma, of course, but overall we see that well people (S) get sick: the blue curve drops over time. The number of ill people I increases over time until there are no S remaining to get sick and they eventually recover. The green curve tracks how many people are recovering over time. In this example, there are 100,000 people in the community when a single sick person arrives; after about a month and a half the disease has worked its way through the community. The parameters were chosen here arbitrarily, but we could estimate them from real COVID-19 data.

Exponential Growth

One of the questions we want to know about the pandemic is the rate of growth of sick people (the people in the I compartment). Let’s suppose that the number of susceptibles S is not changing much; this is a good approximation because a very small percentage of people are getting sick at the moment. In this case, let’s write S(0) as the constant number of initial (that’s the 0) susceptibles. We then see that the equation for the sick (infectious) people has a simpler form of


The solution is given in the second line, and this shows that the growth of infectious people is exponential. Why is this important? It is widely believed that us humans are not very good at being able to intuitively understand exponential growth: what we see today feels a lot like what we expect tomorrow, with perhaps some increase. For exponential growth, the opposite is true: the number of I(t) will feel almost constant until we are hit with a tidal wave of sick people. This is exactly what happened in countries like Italy where it was fairly quiet and nearly overnight the health care system was completely overwhelmed beyond capacity. The SIR model gives a nice prediction of that aspect of this pandemic.  If we don’t do anything, we can expect the same thing to happen here in the United States.

Let’s check the numerical solution of the equations to see if we really do see exponential growth. This is the same result as shown above, but now with a logarithmic scale on the population axis. Note that the time only goes to 20 now to show better the early time behavior.


Note that the orange I curve looks like a line. When you see a line on a logarithmic graph, it means that curve is exponential; and, in this case, increasing exponentally. When COVID-19 hits your community, it is likely to feel that it happened quite suddenly, which is why people are preparing in advance.

Now, I hope that you are skeptical: the SIR is pretty simple! It certainly captures the basic idea of a pandemic and it is used all of the time for these kinds of simple estimates. But, what does the actual data look like also plotted in the same way?covid_data.pngThis plot (from here) shows exactly the same behavior: linear growth (on a logarithmic scale) versus time, eventually rolling over to a more constant value. Most countries, other than Japan and Singapore, have growth rates suggesting a doubling of the number of sick people every two to three days.

What does this look like in your community? Today, maybe there is only one sick person, and you may not yet know about it. In a week, you will have eight people and it’ll start making the news. A week later you are approaching a hundred sick people. Wait another week and you are well over a thousand and perhaps starting to run out of space in your local hospital. (It won’t just be people sick with COVID-19 showing up, but anyone who remotely feels sick with anything or simply wants a test just in case.) That’s what exponential growth looks like: from nothing to an overwhelmed health care system in a three weeks.

Social Distancing

What can we do to prevent this exponential growth? Until we have a vaccine, there is little we can do to change the infectivity and recovery rate parameters. Luckily, our model tells us something more important: the total rate of new infections is through the nonlinear term that contains the product SI. What if we could keep the I away from the S? If we could do that, the S would not be converted to an I. This strategy is called “social distancing” because we use social measures to distance the S from the I. A simple example used by more and more countries everyday is: stay home. Here at Michigan State University we now have all of our courses online and have encouraged students to go home (for those who can do that).

How can we include social distancing in our model? Because the parameter beta includes how often we run into each other, the people who have quarantined themselves will have a smaller value of beta. People who do not quarantine will have the original, larger value. Thus, there are really two populations of susceptible and we need another compartment. The model is a bit more complicated and looks like


where there are now two values of beta with subscripts for high (h) and low(l) and two populations of S with similar subscripts. The Sl are people who have quarantined themselves and they get sick at a much lower rate. Note that we have the same number of people so Sh + Sl = S. Thus, if we could get everyone to self quarantine, the disease would progress at a rate given by the lower of the two values of beta. If you can reduce the number of contacts you make, that changes the (exponential) growth rate by perhaps a factor of two or greater. I just flew through four airports and that was doing exactly the opposite – whoops! Now that am at home, my infectivity might be 100 times as small as it was when I was on travel.

Flattening the Curve

One of the phrases we are hearing a lot recently is “flattening the curve”. What does this mean? The curve referred to is the I curve shown above: the curve of infectious versus time. The flattening of the curve refers to the idea that we should make the curve less peaked, which we can do if we slow the pandemic down through social distancing.

What if we all practiced social distancing and reduced our infectivity to about a third of what it was? When would people get sick? How many? In the extreme case that all of us do this, the modified SIR reduces to the first one, jsut with a lower infectivty. Here are just the I curves for this scenario.


The important feature to notice is that the curve (green) with social distancing is pushed farther into the future, which gives us much more time to prepare (we can all buy enough toilet paper!). But, much more importantly, the peak of the curve is much lower – here the peak is a bit less than half. This means our health care systems can better manage the pandemic – more of us can get high quality care.

Let’s revist the plot above that shows the actual data. What we know today is that most of those countries are using quite agressive social distancing, especially countries like China and Singapore. Their curves are therefore likley flattening not because the pandemic is ending there, but because of quarantine: it appears to be working. To the degree that this model captures the true situation, we can plan to be in this for the next few months.


I hope this simple description of a pandemic using the SIR model gave you some insights into what is happening and what might happen. Of course, there are a vast number of details omitted here, all of which can be explored with embellishments of this simple starting point. Most important is to include geography and travel with our parameters chosen from real data.