There are no nice photos for COVID-19, so here’s a sunrise instead. Photo by Christopher Belanger (CC BY-SA 4.0)

Interactive COVID-19 Simulation: The Effects of Physical Distancing on Transmission

Introduction

This interactive simulation lets you explore how different levels of physical distancing affect the transmission of COVID-19. Each month you choose the percentage of normal interactions people will have, ranging from 100% (business as usual) to 0% (no one interacts with anyone), then press the button to see what happens over the next 30 days. If you like, you can interpret your role as that of a policy-maker in February 2020 who must decide whether (and how much) to “lock down” society.

The Simulation

knitr::include_app(url = "https://chris31415926535.shinyapps.io/covid_seir/")

If the simulation isn’t working (which might happen if I hit my Shiiny usage limits), you can grab the code on GitHub here and run it locally to your heart’s content.

Take-Home Messages

I got three big things out of this:

  • It’s very easy for cases to spike out of control if we don’t limit our contacts! For context, on January 15, 2021 British Columbia had 4,604 known active cases–and in the “business as usual” scenario this model suggests we could see ten or a hundred (!!) times more cases all at once.
  • Interactions need to come down a lot for transmission rates to slow down: on this model, we need to eliminate roughly 40% of contacts to have an effect.
  • Consequently, every interaction matters! It’s not an exaggeration to say that you can save lives by staying home.

How does it work?

It’s based on the epidemiological model developed by Anderson et al. (2020) and presented in this paper, which is used by the Public Health Agency of Canada in its official reports (PHAC 2021, 9). The authors have created covidseir, a wonderful R package that you can download and install from GitHub!

The model is a variant of the epidemiological SEIR model of how diseases spread. Please see the paper for details, but at a high level it tracks how people move through six states over time:

  • \(S\) : Susceptible to the virus;
  • \(E_1\) : Exposed to the virus;
  • \(E_2\) : Exposed, pre-symptomatic, and able to infect others;
  • \(I\) : Symptomatic and able to infect others;
  • \(Q\) : quarantined; and
  • \(R\) Recovered or deceased.

There are also six variables for people practicing physical distancing: \(S_d\), \(E_{1d}\), \(E_{2d}\), \(I_d\), \(Q_d\), and \(R_d\). People are assumed to be immune once they enter state \(R\).

The model describes how these groups change over time with differential equations. I won’t repeat them here (you’re welcome), but I will link to the paper one more time so you can see them yourselves on pages 6 and 7!

In brief, people start out \(S\)usceptible, then get \(E_1\)xposed, then after a while they are both \(E_2\)xposed and able to infect others, then they become visibly \(I\)nfected and symptomatic, then either go straight to \(R\)ecovery, or into \(Q\)uarantine and then into \(R\)ecovery.

At the same time, people can either start or stop physical distancing when they’re in any of these states; the model assumes that there is some flow back and forth from distancing and not-distancing, but that in general more people start distancing than stop.

Cautionary notes about this simulation!

  • Lots of things are missing from this simulation: loss of life, long-term health effects of COVID-19, social unrest due to lockdowns or due to widespread sickness, the economic effects of lockdowns, the health effects of lockdowns, the distributions of those effects, which tend to fall on already-disadvantaged communities (Kantamneni 2020) … it would fascinating to build this into a fuller-fledged simulation, but right now this is just about physical distancing and disease transmission.
  • Policy changes in physical distancing happen right away: we assume society as a whole turns on a dime, responsive to your whim.
  • The simulation uses Anderson et al.’s (2020) initial conditions, which represent British Columbia.
  • The simulation solves the differential equations numerically (using the deSolve package) using a resolution of 0.1 days, and then keeps results for whole-numbered time-steps for plotting (Soetaert et al. 2020).
  • I’m not an epidemiologist and am not affiliated with Anderson et al. in any way. I just like differential equations.
  • This is for edutainment purposes only to learn about how physical distancing can affect COVID-19 prevalence on the population level.
    • It comes with no warranties, guarantees, or manatees!

For more robust COVID-19 simulations in R, check out covidseir

Anderson (2021) have made the wonderful covidseir package available on GitHub here. It’s a much more sophisticated implementation that is able to work with real data to make predictions. The only downside is that it’s not on CRAN, which is why I used a different package to solve the ODEs numerically in the Shiny app.

References

Anderson, Sean. 2021. “Seananderson/Covidseir.” https://github.com/seananderson/covidseir.

Anderson, Sean C., Andrew M. Edwards, Madi Yerlanov, Nicola Mulberry, Jessica E. Stockdale, Sarafa A. Iyaniwura, Rebeca C. Falcao, et al. 2020. “Estimating the Impact of COVID-19 Control Measures Using a Bayesian Model of Physical Distancing.” Preprint. Epidemiology. https://doi.org/10.1101/2020.04.17.20070086.

Kantamneni, Neeta. 2020. “The Impact of the COVID-19 Pandemic on Marginalized Populations in the United States: A Research Agenda.” Journal of Vocational Behavior 119 (May): 103439. https://doi.org/10.1016/j.jvb.2020.103439.

Soetaert, Karline, Thomas Petzoldt, R. Woodrow Setzer, Peter N. Brown, George D. Byrne, Ernst Hairer, Alan C. Hindmarsh, et al. 2020. “deSolve: Solvers for Initial Value Problems of Differential Equations (’ODE’, ’DAE’, ’DDE’).” https://CRAN.R-project.org/package=deSolve.

Christopher Belanger, PhD MBA
Christopher Belanger, PhD MBA
Data Scientist
Researcher
Policy Expert

My research interests include data science, marketing, and public policy, bridging the quantitative-qualitative divide.

comments powered by Disqus