by Kevin Simler
March 16, 2020
at The Washington Post recently published a very
elegant simulation of how a disease like COVID-19 spreads. If you haven't already, I highly recommend checking it out
Today I want to follow up with something I've been working on: playable simulations of a disease outbreak. "Playable" means you'll get to tweak parameters (like transmission and mortality rates) and watch how the epidemic unfolds.
By the end of this article, I hope you'll have a better understanding — perhaps better intuition — for what it takes to contain this thing. But first!...
AN IMPORTANT WARNING:
This is not an attempt to model COVID-19.
What follows is a simplified model of a disease process. The goal is to learn how epidemics unfold in general.
: I'm not an epidemiologist! I defer to infectious disease experts (and so should you). I have almost certainly made mistakes in this article, but I'll correct them as quickly as I can. If you see any problems, please get in touch
Let's do this.
A grid of people
We're going to build our model up slowly, one piece at a time.
The first thing a disease needs is a population, i.e., the set of people who can potentially catch the disease. Ours will live in neat rows and columns, like the 9x9 grid you see here:
Each square represents a single person. The poor soul at the center, as you may have guessed, is
Infected. Meanwhile, everyone else is
Now let's incorporate time into our model.
The "Step" button (below) moves the simulation forward 1 day per click. Or you can press the ▷ button to watch things happen on their own:
Oh no. It looks like everyone sneezed on their immediate neighbors — north, east, south, west — and the whole world got sick.
But people don't stay sick forever. Let's see what happens when they get better after 2 steps (i.e., 2 days):
Great, now people can transition from
Here's a handy legend:
For purposes of our simulation, once someone is
Recovered, they can't get reinfected. This is hopefully (and probably) true for COVID-19, but not certain.
In discussions of COVID-19, you may have heard that the disease has a long incubation period. This is the time between when a person initially contracts the disease and the onset of first symptoms.
With COVID-19, it seems that patients are contagious during the incubation period. They may not even realize they're sick, but they're still able to infect others.
We will replicate this feature in our disease model. (But remember, we're not trying to model COVID-19 precisely!)
Here's what an incubation period looks like:
The way I've chosen to model this disease, there's no important distinction between the pink and red states. As far as the virus is concerned, both states behave the same.
Nevertheless, I wanted to include the incubation period as a (visual) reminder that carriers of COVID-19 are lurking among us, hidden from the official statistics, totally unaware that they're infected.
... unaware that they're spreading the disease to others.
Even as you read this,
you may be such a person.
- Infected (incubation period, no symptoms)
- Infected (with symptoms)
Real diseases don't spread outward with 100 percent certainty. They spread probabilistically.
So let's introduce a new parameter: the transmission rate. This controls the chance that an infection gets passed from person to person.
Can you find a value for the transmission rate that keeps the disease from spreading to the entire population?
👆 Pro-tip: You can adjust sliders while the simulation is running.
Q: What's the largest transmission rate where the disease doesn't seem capable of spreading forever (e.g., reaching all four edges of the grid)?
In my experiments, it seems to be around 0.35, maybe 0.34. Below that, I've seen the infection fizzle out every time. Above, it generally infects most of the grid.
Here's how transmission works in our disease model.
Every day, each person has a fixed number of encounters with the people nearby.
Thus far, we've allowed people to interact only with their immediate neighbors, for a total of 4 encounters per day. We'll vary these assumptions below.
During each encounter, the transmission rate determines the probability that an
Infected person will give the disease to a
Susceptible person. The higher the transmission rate, the more likely the disease gets passed along.
In reality, there are many different types of encounters. You might brush past someone on the sidewalk. Or sit next to them on a bus. Perhaps you'll share an ice cream cone. Each of these encounters would result in a different probability of transmitting the infection. But in our model, for simplicity, all encounters share the same transmission rate.
As you continue playing with these simulations (above and below) and thinking about their relevance to coronavirus/COVID-19, here's something to keep in mind:
Transmission rate is partly a function of the disease itself (how naturally infectious it is), but also a function of the environment that the disease lives in. This includes both the physical environment (e.g., air temperature and humidity) as well as the social environment (e.g., people's behaviors).
For example, when people wash their hands and wear masks to contain coughs, the transmission rate per encounter goes down — even if the virus itself doesn't change.
Now, for any viral-growth process, it's possible to find a transmission rate low enough to completely stop the spread. This is called the "critical threshold," and you can learn more about it here
But COVID-19 is so infectious, it's hard to get below the critical transmission rate. We can only wash our hands so many times a day. Even wearing masks out in public won't be enough enough to bring transmission down far enough (though every inch is helpful).
We could all wear hazmat suits every time we leave the house; technically that would solve the transmission problem (without changing our patterns of social interaction). But since that's, uh, impractical, let's consider other ways to keep this disease from consuming us.
Here's another unrealistic assumption we've been making: we've been allowing people to interact only with their immediate neighbors.
What happens when we let people travel farther afield? (We're still assuming 4 encounters per day, a parameter we'll expose in the next section.)
As you pull the travel radius slider below, you'll see a sample of the encounters that the center person will have on any given day. (We can't draw everyone's encounters because it would get too crowded. You'll just have to use your imagination.) Note that in our model, unlike in real life, each day brings a new (random) set of encounters.
Note that if you restrict travel from the beginning (e.g., to a radius of 2 units), you can slow the infection down a great deal.
But what happens when you start with unrestricted travel, let the infection spread pretty much everywhere, and only restrict travel later?
In other words, how early in the infection curve do you have to curtail travel in order for it to meaningful slow the outbreak?
Go ahead, try it. Start with a travel radius of 25. Then play the simulation, pausing when you get to about 10 percent infected. Then reduce the travel radius to 2 and play it out. What happens?
Takeaway: travel restrictions are most useful when they're applied early, at least for the purpose of flattening the curve. (So let's get them in place!)
But travel restrictions can help even in the later stages of an outbreak, for at least two reasons:
- Buses, trains, and airports are places where people gather together in cramped quarters. When people stop using these modes of transport, they reduce the number of encounters they have with potentially infected people. (We'll explore this more below.)
- Reducing travel is critical in concert with regional containment measures. If one region gets the outbreak under control, but neighboring regions are still on fire, you have to protect the controlled region. (We're not going to explore containment measures in this article, but they may be important soon, and if you're interested, you might start here.)
Number of encounters
Alright, let's really open this thing up.
In the simulation below, you can vary the encounters per day.
Let's start at 20. What's the minimum value we need to keep the outbreak contained?
As you can see, reducing encounters per day has a dramatic effect on the outbreak. It easily flattens the curve, and even has the potential (when taken very seriously) to completely quench an outbreak.
This is the effect we're hoping for when we call for "social distance." This is why so many people are pleading with their officials to stop the parades and close the schools, and why all of us should stay away from bars and coffee shops and restaurants, and work from home as much as possible.
The NBA did their fans a tremendous service by canceling the rest of the season. Now we need to follow suit and cancel everything.
In my understanding (again, not an expert), this is the single most important lever we have for fighting this thing.
Not every patient recovers from a disease. Many end up
Enter the fatality rate.
In our simulation, fatality rate is the probability that a patient who gets infected will ultimately die of the infection, assuming they get normal/adequate medical care.
(Update: an earlier version of this article made a distinction between case fatality rate and mortality rate, but failed to define the terms correctly. Collapsing this distinction and using the term "fatality rate" instead.)
The fatality rate for COVID-19 has been estimated between 1 percent and 6 percent
. It might turn out to be lower than 1 percent, if there are a lot of undiagnosed cases. It's definitely higher when the medical system is overburdened (more on that in a minute).
We'll start at a 3 percent fatality rate for our disease model, but you can vary the parameter below:
Those scattered black dots may not look like much. But remember, each is a human life lost to the disease.
Below you'll find one last new slider. It controls hospital capacity.
This is the number of patients (expressed as a percentage of the population) that can be treated by our medical system at any one time.
Why does hospital capacity matter?
When there are more patients than the system can handle, they can’t get the treatment they need. And as a result, they have significantly worse outcomes. As we've seen in Italy, some may be left to die in the hallways.
I've heard people speak of hospital capacity as the “number of beds,” or “number of ICU beds.” My take is that mere "beds" can be set up in a gymnasium on very short notice. I think the real bottleneck is medical equipment — specifically ventilators. But I'm not sure. Maybe it’s medical personnel.
In reality, this matters a lot. We need to identify what the bottleneck is, and do our best to alleviate pressure there. But for a simulation, we can just wave our hands and assume there's limited capacity somewhere in the system. Remember, we're not trying to model reality too carefully.
In our disease model, here's how the medical system breaks:
When there are more infections than hospital capacity, the fatality rate doubles.
Give it a try. Pay special attention to the input fatality rate (the value on the slider), which defines how often people die even in the best circumstances, vs. the actual death rate (highlighted below the chart), which tells us how the system behaves under strain.
"Flatten the curve"
You've heard this before. You know why it's important. But now you're about to get a feel for it.
This is your final test today.
The input fatality rate is fixed at 3 percent. Hospital capacity is fixed at 5 percent.
Play out the simulation and note the actual death rate: 6 percent. Then try to bring that number down.
In other words, flatten the curve:
However this worked out for you in simulation, reality is going to be so much harder. Real people don't respond like sliders in a UI.
And here's the kicker: even if we manage to "flatten the curve" enough to meaningfully space out the case load, we're still positioned to lose millions and millions of lives.
Maybe we won't lose as many as a worst-case scenario; maybe we won't lose them in hospital hallways. But as long as the virus continues to spread — which it shows every sign of doing — there's an unthinkable amount of suffering in our future.
Unless we do the right things today.
Stop traveling. Stop going out. Stop visiting your parents and your friends. Stop eating at restaurants. Pause everything you possibly can. If you're in charge of things, cancel them. Lock. It. All. Down.
Please: take decisive action now.
COVID-19 is coming for us, and it won't be stopped by half-measures.
— no rights reserved. You're free to use this work however you see fit, including copying it, modifying it, and distributing it on your own site.
The full model, with all sliders exposed, can be found at the very bottom of the page.
- Coronavirus: Why You Must Act Now — Tomas Pueyo explains why we've been systematically underestimating this thing, and why that needs to change. Just read it.
- Don’t "Flatten the Curve," Stop It! — Joscha Bach does some calculations on hospital capacity and concludes that "flattening the curve" won't be enough; we have to completely stop the outbreak.
- The Washington Post's excellent simulation — brilliant use of billiard balls to show transmission and social distancing.
- Going Critical — my previous exploration of diffusion and viral growth processes, including the nuclear reactions and the growth of knowledge.
Originally published March 16, 2020.
(Thanks to Jason Legate
for suggesting and coding this addition to the disease model.)
In the simulation below, you can vary the self-quarantine rate, i.e., the chance that a patient will choose to isolate themselves once they become symptomatic. Patients who become
Self-quarantined will be drawn in blue instead of red.
Additionally, you can vary how strict they are with the self-quarantine strictness parameters. At 100 percent strictness, patients who are isolating themselves have 0 encounters with other people. At 0 percent strictness, they have their normal number of encounters. And it varies linearly in between.
Let's start the self-quarantine rate at 25 percent and the strictness also at 25 percent. What does it take to keep the outbreak contained?
Self-quarantine strictness 25%
As you can see, if people voluntarily self-quarantine (once they show symptoms) and are strict about isolating themselves, the spread can be mitigated. Unfortunately, because patients are contagious during the incubation period (before they have a chance to notice their own symptoms), it's hard to stop the spread entirely.
For most diseases, self-quarantine won't solve the problem on its own. Rather, it's one tool among many (including better hygiene, social distances, travel restrictions, etc.) that all together can bring an outbreak under control. A big lesson here is that every strategy complements every other strategy.
Self-quarantine strictness 90%