Showing posts with label covid-19. Show all posts
Showing posts with label covid-19. Show all posts

Saturday, October 3, 2020

Looking at the Numbers Part 4: Follow-up on Previous Pandemic Insights

 I've been wanting to go back an evaluate my previous posts on the Pandemic:

Looking at the Numbers: COVID-19 New Cases

Looking at the Numbers Part 2: COVID-19 Cases in the U.S.

Looking at the Numbers Part 3: Insight into the COV-19 Pandemic using a simulation

TL;DR

  • Claim: the pandemic was following a log-normal distribution
    • While the log-normal is useful, the pandemic resembles a more complicated superposition of multiple log-normal distributions.
  • Claim: the future can be predicted using log-normal distribution and/or percentage of population
    • Partially true
      • I predicted total cases for CA, FL, TX would be much larger than expected at the time (actual numbers have exceeded my prediction).
      • Log-Normal cannot predict future outbreaks (Example: Italy, Russian, Japan and Spain)
  • My original claim that many populous countries were just starting to "blow" up and poorer countries will most likely do worse.  This is proven false in the case of Bangladesh and India with lower death rates than the U.S.
  • Claim: Re-opening will most likely result in a rise of cases
    • True

Log-Normal Distribution

Claim: A Log-Normal distribution appears to be a surprising good fit to the number of new cases in various countries

The claim seems to be mostly true if a country or state doesn't make major changes to their response to COVID.

For example, Brazil seems to be following a Log-Normal distribution for COVID-19 cases.  Below are the best fit cumulative and distributions.
Most other countries, however show a resurgence of cases.  Only the distribution function is shown.  For these cases, it appears that the distributions appear as a superposition of two or more log-normal curves. 





Predicting the Future

Claims: 
  • The log-normal is able to predict the future growth of the virus assuming no later waves
  • The trend shows that the maximum expected total cases will be about 2% of the population
  • Several populous states have a ways to go

The problem with this claim is that in all cases, there is a later wave.  Still, I believe that the log-normal can help provide an expectation of how a current outbreak in a locale will play out.  Some examples:

Second Outbreaks

On May 9, 2020, I predicted that Italy would have 246k cases.  It hit this number at the end of July (as predicted) however a month later, the cases started climbing again.  It retrospect, I remember looking at the regions of Italy that had been infected and I noticed there were many other populous areas with low infection rates.  So I am not surprised in the later rise, but I also had no way to predict when it would start nor how large it will be.
Other countries that have had secondary outbreaks (Japan, Russian, Spain).






Populous States

On May 24, 2020, I predicted that California, Texas and Florida would have significantly more cases based on the assumption that peak cases would be about 2% of the population.  This assumption of 2% ended up being too low for many states (Florida and Arizona are both over 3% of the population infected).

StatePopulationTotal Cases to DateEstimate from May 24Actual Oct. 3
CA39,144,81888,226694,670826,624
TX27,469,11452,268497,114766,559
FL20,271,27248,675356,750711,804


California's continually changing policies (partial shutdown, full shutdown, partial reopening, etc.) have resulted in a distribution that cannot be fit to a log-normal.


Populous Countries


On May 9, 2020, I noted that some of the most populous countries were just starting to see the pandemic: 
 India, Russia, Brazil, Mexico, Indonesia, Bangladesh, Pakistan, Nigeria.  Though I wrote in my post that  "It's too early to tell how this will play out worldwide", I alluded to my hypothesis that they would experience a more severe pandemic.  The table below does not support this hypothesis.  

CountryMay 9Oct 3Death Rate for those infected
United States1,283,9297,332,2852.8%
Brazil145,3284,880,5233.0%
India59,6626,473,5441.6%
Russia187,8591,194,6431.8%
Mexico31,522753,09010.4%
Bangladesh13,134366,3831.4%
Indonesia13,112295,4993.7%
Pakistan27,474313,9842.1%



Two cases stand out: India and Bangladesh.  India is quickly approaching the U.S. in number of cases but has a death rate nearly half of the U.S.  Bangladesh has an even lower death rate and the total number of cases are very small (0.2% of the population infected compared to the U.S. at 2.2%). And it appears that cases in Bangladesh are on a steady decline.

Re-opening will most likely result in a rise of cases

Here is my prediction using a scale-free model.  The total cases, time scale, relative size and time of peaks could not be accurately modeled.



Here is what happened in the U.S. after many states relaxed the rules around May or June.




Sunday, May 31, 2020

Looking at the Numbers Part 3: Insight into the COV-19 Pandemic using a simulation

This is the third in the series of analyzing the growth of cases for the current pandemic.  In my previous posts here and here, I showed how many countries and states resemble a log-normal distribution. In this post I describe a model that I developed for the pandemic.

TL;DR
  • I verified my hypothesis that the pandemic can be modeled as a scale-free network starting at patient zero and nearest neighbors being infected each cycle.
  • Luck plays a role: where the infection starts in the pandemic makes a big difference in how fast it spreads.
  • Re-opening will most likely result in a rise of cases.

Scale-Free Networks

I first learned about scale-free networks from the book Linked by Albert-László Barabási.  A scale-free network starts with two nodes connected together.  One node is added at a time, preferentially connected to nodes with more connections.  These networks describe the topology (organization) of networks as varied as the Internet and the proteins in our cells.  It also describes social networks and how disease spread.

I decided to see if by using a scale-free network, I could demonstrate the same log-normal pattern of COVID-19 case growth over time (as observed in my earlier posts).  I found a Python module, networkx, that has a function, not surprisingly called "barabasi_albert_graph", that can construct the network.  A "graph" is a mathematical term for networks.

City-County-State-Country-World

A scale-free network can describe the social connections in your city.  Some people have friends and family in other cities so that a county also resembles a scale-free network.  Similarly, counties are connected to form states; states are connected to form countries; and countries are connected to represent the worlds population.

The Scale-Free Network Pandemic Model

Using the scale-free graph, I created a model that I could use to simulate the spread of the disease.  Starting with one person, the disease is spread to nearest neighbors, who spread to their nearest neighbors, etc.  The model includes policies to reduce the spread (using probability of an infection and limiting "group-size").  For a person with a large personal network, this can radically slow down or "flatten" the curve.

Below is an animation of a scale-free network of 1,000 nodes (I used a software tool call Gephi to plot the graph).  Uninfected nodes are gray, infected nodes are red.  The animation loops.  You can see how it starts slowly, then as it hits hubs (nodes with many connections) it speeds up.  It slows again as it infects loosely connected outliers.


A Scale-Free Network results in a Log-Normal Distribution

When I ran my model with 2.5 million nodes, it fit very well a log-normal distribution.  In the plot below, the orange "Fit" curve is the Log-Normal and it almost covers the blue "Total Cases" generated from the simulation.  I also ran the simulation in "flattened" mode with a group-size of 5 (simulating households of 5 people under stay-at-home orders).

Q: What Exactly Does the Network Represent? A: Only Infected People

My initial thinking was that I would produce a graph with 7.7 billion nodes, and experiment with it.  Unfortunately my computer isn't powerful enough (It started complaining when I ran more than a couple million nodes).  What I realized is that if you consider the complete graph of a population, and then only infected around 2% of the nodes, the infected nodes also resemble a scale-free graph.  So I found it most useful to consider the graph as only the people that got infected in a large network.

Luck and Patient Zero

When the current pandemic started, I naturally asked "why is this happening?" and "how can I protect myself?".  I started using coping mechanisms.  "It mostly kills people with preexisting conditions, so I'll be fine".  When Italy was one of the first countries to get hit the hardest, I blamed their culture thinking "It's all of the kissing and hugging Italians do".

With this simulation that produces results similar to real world data, I could play around with it.  My first goal was to see if I could find a relationship between the log-normal parameters and the simulation parameters.  I varied network size, probability of infection, group-size limits.  The resulting fitted log-normal parameters (sigma, scale and offset) showed no correlation. 

I then decided to examine the effect of different patient zeros (the person from which the disease originated).  I re-ran the model with 10 randomly selected starting nodes for a network of 500,000.  In the plot below, you can see that the starting node does make a difference.


I then decided that 10 nodes was too small a sample, so I decided to run for 500 randomly selected starting nodes.  Each simulation was run until half of the network was infected.  Below is a histogram showing the distribution of these 500 runs.  I also wanted to see the dependence on size of the network, so I ran for networks with 1,000, 10k, 20k, 50k, 100k and 500k nodes.


Making Sense of the Variation

This last graph showed that for a network of size of 500k, the disease would most likely take 3-14 weeks to infect half of the population; but it could also take up to 66 weeks!  How could this be?

Let's consider two people from Wuhan, China that have been infected:
  1. A rich businessman goes to the Alps on a Ski trip
  2. A grandma goes to visit her family in a small town outside of China.

Case 1: Rich Businessman goes skiing

The rich businessman is in the ski lodge with some wealthy Italian young men.  They get infected and go back to Italy.  They are very socially active (hubs) and infect hundreds of people at a club they go to.  Those people are also active and spread to their networks.  In a matter of weeks, thousands of people are infected.

Case 2: Grandma visits her grand-kids

Grandma stays with her daughter in a small town.  Her only interaction is with their family, husband, wife, and 2 kids.  The husband works from home and the daughter takes care of the kids.  Once a month, they have dinner with some friends.  They infect their friends, who are also socially isolated.   Slowly the disease makes its way to a hub, where it spreads more rapidly. It takes months to infect 100 people.

Re-opening

I tried simulating what would happen if the stay-at-home orders were removed, by removing the group-size limit part way through the simulation.  The reality is that the rise in cases will probably not be as dramatic since over-all the population has changed it's behavior (wearing masks, washing hands, etc.)


Conclusion

As public policies change in how we respond to the current pandemic, I knew I needed a model where I could simulate changes over time.  The scale-free network has proved to be an interesting model to experiment with as it fits the early log-normal distributions of cases over time.  The model reveals that there are some things out of our control (who patient zero is), while there are other things we can do to make a big difference (avoid infections via hubs).

Sunday, May 24, 2020

Looking at the Numbers Part 2: COVID-19 Cases in the U.S.

A week ago I posted analysis of COVID-19 cases for various countries here.

In this post, I use some of the same methods (Python, pandas, scipy, matplotlib) to look at a dataset for U.S. counties http://usafacts.org.  This data is used to look at growth for states.

TL;DR

  • COVID-19 cases in the U.S. also fit a log-normal distribution
  • Several U.S. states are close (90-95%) to the maximum expected total cases
  • The trend shows that the maximum expected total cases will be about 2% of the population
  • Several populous states have a ways to go

Overview

I focus on the 3 most populous states that I have good curve fits for (NY, NJ, MA) and the 3 most populous states that I don't have good curve fits for (CA, TX, FL).  

For this post, I'm using the log-normal cumulative distribution function (CDF) since the underlying data set was total cases (cumulative cases).

Note that the data used only reported numbers and that it is plausible that the actual number of cases is much higher.

Plots

The plots of NY, NJ and MA include the estimated log-normal CDF curve fit.  The legend includes the estimated total number of cases.  Based on the current total number of cases, the percentage complete is: NY (95%), NJ (89%), MA (89%).

I was not able to fit the CA and TX data.  FL has an estimate, but I don't consider it a reliable fit because it is too early (see my previous post on reliability).


Expected Percentage of the Population to Get COVID-19

Two metrics are compared to determine what percentage of the population will get COVID-19.  
  • Estimated % Complete - calculated by dividing the current number of cases by estimated number of total cases.  The higher the percentage, the more reliable the estimate.
  • % of the Population at Estimated Peak - this is the estimated number of total cases divided by the population.
The chart shows that the trend is towards 2% of the population getting infected.  Only the most reliable estimates were included (where the estimated % complete was greater than 50%).


If we assume that 2% of the population will get reported as having COVID-19, then several states have a long ways to go.

State
 Population 
 Total Cases to Date 
 Estimate Remaining Cases to Reach 2 % 
CA
   39,144,818
                            88,226
                                     694,670
TX
   27,469,114
                            52,268
                                     497,114
FL
   20,271,272
                            48,675
                                     356,750