Codementor Events

How To Best Visualize Exponential Growth

Published Apr 04, 2020
How To Best Visualize Exponential Growth

The Exponential Growth of Covid-19

Regrettably, Covid-19 is blazing all over the world. News are constantly bringing information on the growth of confirmed cases, deaths and recovered patients. The information comes as numbers and graphs, and, alongside with them, the expression exponential growth.

Most graphs of the total number of confirmed cases usually start slow and curve up suddenly. Take for example the total number of cases from South Korea from the day of its first confirmed case until 74 days later.

Korea's total confirmed cases of Covid-19

This graph tells us that there were very few cases until day 31 or 32, where it began to curve up and grow at an increased rate. So simple, no? Maybe not.

There is more than meets the eye!

There are details that are being dwarfed by the sheer number of cases at later stages. To see them we must change the scale. But how?

Visualizing Exponential Growth

To see the details that are lost by the original scale we must go from a linear y-scale (the cases scale) to a logarithmic y-scale.

A linear y-scale increases by adding a constant value to each tick. For the graph above, the y-scale increases by 2500 cases every two horizontal lines. On the other hand, a logarithmic y-scale increases by multiplying each tick by a constant factor. Usually this factor is 10, so you'll see ticks at 10, 100, 1000, 10000, all of them equally spaced.

If we change the linear y-scale to a logarithmic y-scale we get:

Logarithmic y-scale

So, there really are relevant details at lower values of confirmed cases. What seemed to be constant or slow it is now an odd behaviour. But a behaviour we can analyze.

Exponential Function

Before we extract more insights from this new plot, let me tell you briefly about the exponential function.

y=AeBxy = A*e^{B*x}

This function when plotted in a linear y-scale grows slow and curves up at larger values of x. But if this function is plotted in a logarithmic y-scale it will show up as a straight line!

Don't beleive me? Take the logarithm on both sides: ln(y)=Bx+ln(A)ln(y) = B*x + ln(A) which has the form of the straight line equation z=mx+bz = m*x+b

Exponential fits

Let's go back to the last graph and ask ourselves the following question: Is there a group of consecutive points that follow some straight line? It seems that there are!

There are 6 data points starting from day 30 that are aligned. And with some imagination (and a lot of spread) we could aslo consider the points for the first 15 days.

To these two group of points, different exponential functions were fitted. To be fitted means:

  1. Use the equation (with base 2):
    cases=C02t/Dcases = C_0*2^{t/D}
  2. Find the parameters C0C_0 and DD that minimize the distance from the real value to the calculated.
  3. Draw the estimated values over the real points.

This equation links the number of confirmed cases (cases) to the time ( t ) with parameters C0C_0 and DD. Parameter C0C_0 represents the number of cases at time 0, and DD are how many days are needed to double the number of cases.

The Final Analysis

We now plot the data with the best exponential fits for the two subset of points.
Korea_02.jpeg

But, what happened on day 30?

Patient 31 happened!

The Covid-19 was growing exponentially and on day 15 was beign tracked and controlled. On day 30, a new outbreak started, doubling faster than the initial outbreak. Maybe by lack of cooperation and the proximity of the diseased to other persons.

Takeaways

A logarithmic y-scale allows us to:

  • explore data that spans several orders of magnitude (from ones to tens of thousands),
  • identify data that may be growing exponentially. They appear to follow a straight line
  • any exponential function appears as a straight line
  • compare different growth speeds from the slope

Everything was done with R in RStudio and the World Health Organization's data on Covid-19.

Stay safe!

Discover and read more posts from Ricardo Schifini Gladchtein
get started
post commentsBe the first to share your opinion
Show more replies