An interactive simulation that demonstrates how important it is to keep COVID-19's reproduction number (Rt) below 1.
I think most folks understand how dangerous it would be if each infected person spread the virus to 2 more people, but I imagine many would be surprised at how quickly cases rise if each person with COVID "only" infects an average of 1.1 people.
The simulation also allows the user to choose a U.S. state to fill its current Rt estimate (sourced from Rt Live) and average daily cases, so they can see their own state's current outlook.
I adapted my simulation model from Rt Live's model as they lay out in their tutorial notebook. It accounts for the fact that it takes a few days for an infected person to pass on the virus by incorporating that delay (called the generation time) as a log-normal probability distribution with a mean of 4.7 days and standard deviation 2.9 days. Then, the number of newly infected people on a given day (yt) is a sum that looks at all previous days, weighing the number of newly infected people i days ago (yt - i) by the generation time probability (gi) for that number of days and the effective reproduction number (which for the purposes of this simulation is being kept constant at Re). More succinctly,
Simulations run from today's date to four months in the future, and they treat every day prior to the start date as having a number of new infections equal to the "Initial daily infections" setting below the chart.
For the "Pick a U.S. state" dropdown, current Rt estimates and average daily cases are fetched directly from Rt Live, and they source their case count data from The COVID Tracking Project. These real-time Rt estimates have an inherent degree of uncertainty, so each estimate includes an 80% confidence interval, which essentially means that we can be 80% sure that the actual Rt value lies somewhere between those upper and lower bounds. You'll notice if you visit Rt Live's homepage that as you look further back in time, these confidence intervals become smaller with the benefit of more data.
These are the primary tools I used in this project:
- Data visualization: Vega-Lite
- Statistics package: jStat
- Data fetching: SWR
- Data wrangling: Data-Forge
- Math typesetting: KaTeX via react-katex
- Web framework: Next.js
- Web design library: Bootstrap via React Bootstrap
Also, I have to say, while the focus of this project was the data visualization, not the web development, this project contains the most beautiful React code I've ever written. ⚛️