**free range statistics - R**, and kindly contributed to R-bloggers)

## Motivation

A couple of weeks back, Branko Milanovic asked on Twitter :

“Does anyone know a link to a calculation on how many people were born … in the entire 20th century?”

Somewhat surprisingly, no-one did. However, there was a calculation by the Population Research Bureau that about 108 billion people had walked the earth since 50,000 years ago. I gave myself the detective job of tracking done the data to make the estimates for just the twentieth century.

The necessary data is crude birth rates and total population numbers. Back to about 1950 there is excellent data available from the UN, but before that it is surprisingly hard to find from official sources.

## Kremer’s long range global population estimates

The first useful thing I found was an interesting article in *The Quarterly Jorunal of Economics* by Michael Kremer on Population Growth and Technological Change: One Million B.C. to 1990

That got me this dramatic-looking set of numbers:

The vertical axes in those charts is on a logarithmic scale, so the growth rates in population there are truly astonishing. Humanity has exploded on this planet in a very short period of time, in the scale of things.

Here are just the growth rates:

Some interesting things here include:

- the dip into negative territory in the thirteenth century, with Mongol wars and the Black Death;
- another bad time in the early seventeenth century with the 30 years war destroying Germany, and the collapse of the Ming dynasty in China;
- a dip around 1850 which I think is probably associated with the Taiping Rebellion in China. Despite its massive scale we saw a decline in growth but nowhere near down to negative territory;
- a final dip associated with World War I and subsequent influenza pandemic (years between 1900 and 1920);
- maximum growth rate in 1960 with rapid decline since.

There would be better sources now of the recent years, showing the steep decline continuing. For the record, the world population on current trends in declining growth rates will reach a maximum level of around 11 billion in 2100.

I typed out Kremer’s numbers rather than muck around trying to read them electronically. Note that there seems to be an error in the third growth rate in his Table I on page 683; while all his other growth rates exactly match my calculations based on his population levels, for that particular number he has 0.000031 and I get 0.00012. I don’t think it matters much for the substance of his interesting arguments in that paper.

Here’s the R code to create those charts with Kremer’s numbers:

## Gapminder’s country-level birth rate and population estimates

That was all very interesting and gave me at least some benchmark population values covering the whole twentieth century (not just the post-WWII period covered in the official sources), but I also need crude birth rates – how many people born per 1,000 people living. This is the only practical way of getting estimates of the number of births; just growth rates alone won’t do it because the same growth rate could mean quite different birth rates, depending on death rates.

Eventually I realised that Gapminder publish estimates of many variables, including basic demographic data, back to 1800 at the country level. Gapminder Foundation is the Swedish NGO founded by the recently deceased and much missed Hans Rosling and friends and family, promoting increased understanding of development issues in a historical context. It’s possible to combine these to get global estimates by summing up population numbers, and creating population-weighted averages for birth rates.

This process gives me this plausible-looking set of estimates of the world’s crude birth rate over the last 200 years or so:

These numbers are close enough (for my purposes) to the UN’s figures for the overlapping period from 1950 onwards.

I also quite like this representation of the population and the birth rate together as a connected scatter plot:

Obviously, once we have crude birth rates and population numbers, we just need to multiply them together to get an estimated number of births per year:

What’s with that jump in the 1980s? Well, the decline in crude birth rate stalled at around 27 or 28 for 15 years or so, and with the massive increase in population coming from rising living standards post-WWII that was enough for a major increase in number of babies being born. By the 1990s, crude birth rates resumed a precipitous decline. There also might be a story here about demographic collapse in post-Soviet Union countries; or there might be a quirk in the data arising from how I aggregated up the country level data.

Here’s the code to get the data from Gapminder and draw those charts:

### Checking against a more definitive source for more recent years

I was a bit worried about that bump in the 1980s, so I thought I should have a look at a more definitive data source for recent decades rather than relying on my population-weighted average of Gapminder’s country level data. I grabbed the World crude birth rate from the World Development Indicators for 1960 onwards:

Unsurprisingly it’s a bit flaky in the early years, but I decided the two were close enough that I could stick to using my Gapminder estimates. Here’s how I got that World Bank data:

## Cumulative births

Finally, the answer to the question, which turns out to be about 9.75 billion:

The Gapminder data doesn’t have values for every year, but it’s straightforward to interpolate them and get the estimated number of births. That was the final bit of calculating to do.

I saved the birth numbers from 1800 onwards as a CSV in case anyone is interested in them.

Here’s the code for the final step:

**leave a comment**for the author, please follow the link and comment on their blog:

**free range statistics - R**.

R-bloggers.com offers

**daily e-mail updates**about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...