<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/number-of-births-in-the-twentieth-century-by-ellis2013nz/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://freerangestats.info/blog/2018/12/01/number-births"> free range statistics - R</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<h2>Motivation</h2>
<p>A couple of weeks back, <a rel="nofollow" href="https://twitter.com/ellis2013nz/status/1064276290146955264" target="_blank">Branko Milanovic asked on Twitter </a>:</p>
<blockquote>
<p>“Does anyone know a link to a calculation on how many people were born … in the entire 20th century?”</p>
</blockquote>
<p>Somewhat surprisingly, no-one did. However, there was a <a rel="nofollow" href="https://www.prb.org/howmanypeoplehaveeverlivedonearth/" target="_blank">calculation by the Population Research Bureau</a> 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.</p>
<p>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.</p>
<h2>Kremer’s long range global population estimates</h2>
<p>The first useful thing I found was an interesting article in <em>The Quarterly Jorunal of Economics</em> by Michael Kremer on <a rel="nofollow" href="http://faculty.econ.ucdavis.edu/faculty/gclark/210a/readings/kremer1993.pdf" target="_blank">Population Growth and Technological Change: One Million B.C. to 1990</a></p>
<p>That got me this dramatic-looking set of numbers:</p>
<p><img width="100%" src="http://freerangestats.info/img/0141-global-numbers.svg"></p>
<p>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.</p>
<p>Here are just the growth rates:</p>
<p><img width="100%" src="http://freerangestats.info/img/0141-global-growth.svg"></p>
<p>Some interesting things here include:</p>
<ul>
<li>the dip into negative territory in the thirteenth century, with Mongol wars and the Black Death;</li>
<li>another bad time in the early seventeenth century with the 30 years war destroying Germany, and the collapse of the Ming dynasty in China;</li>
<li>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;</li>
<li>a final dip associated with World War I and subsequent influenza pandemic (years between 1900 and 1920);</li>
<li>maximum growth rate in 1960 with rapid decline since.</li>
</ul>
<p>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 <a rel="nofollow" href="https://www.un.org/development/desa/en/news/population/world-population-prospects-2017.html" target="_blank">around 11 billion in 2100</a>.</p>
<p>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.</p>
<p>Here’s the R code to create those charts with Kremer’s numbers:</p>
<figure>
<pre><code data-lang="r"><span>library</span><span>(</span><span>tidyverse</span><span>)</span><span>
</span><span>library</span><span>(</span><span>viridis</span><span>)</span><span>
</span><span>library</span><span>(</span><span>gridExtra</span><span>)</span><span>
</span><span>library</span><span>(</span><span>ggrepel</span><span>)</span><span>
</span><span>library</span><span>(</span><span>readxl</span><span>)</span><span>
</span><span>library</span><span>(</span><span>testthat</span><span>)</span><span>
</span><span>set.seed</span><span>(</span><span>123</span><span>)</span><span>
</span><span>#-----------------total population size---------------
</span><span>
</span><span>kremer</span><span> </span><span>&lt;-</span><span> </span><span>data_frame</span><span>(</span><span>
</span><span>year</span><span> </span><span>=</span><span> </span><span>c</span><span>(</span><span>-1000000</span><span>,</span><span> </span><span>-300000</span><span>,</span><span> </span><span>-25000</span><span>,</span><span>
</span><span>-10000</span><span>,</span><span> </span><span>-</span><span>(</span><span>5</span><span>:</span><span>1</span><span>)</span><span>*</span><span>1000</span><span>,</span><span> </span><span>-500</span><span>,</span><span> </span><span>-200</span><span>,</span><span>
</span><span>1</span><span>,</span><span> </span><span>200</span><span>,</span><span> </span><span>400</span><span>,</span><span> </span><span>600</span><span>,</span><span> </span><span>800</span><span>,</span><span> </span><span>10</span><span>:</span><span>16</span><span> </span><span>*</span><span> </span><span>100</span><span>,</span><span>
</span><span>1650</span><span>,</span><span> </span><span>1700</span><span>,</span><span> </span><span>1750</span><span>,</span><span> </span><span>1800</span><span>,</span><span> </span><span>1850</span><span>,</span><span>
</span><span>1875</span><span>,</span><span> </span><span>1900</span><span>,</span><span> </span><span>192</span><span>:</span><span>199</span><span> </span><span>*</span><span> </span><span>10</span><span>),</span><span>
</span><span>pop</span><span> </span><span>=</span><span> </span><span>c</span><span>(</span><span>0.125</span><span>,</span><span>1</span><span>,</span><span>3.34</span><span>,</span><span>4</span><span>,</span><span>5</span><span>,</span><span>7</span><span>,</span><span>14</span><span>,</span><span>27</span><span>,</span><span>50</span><span>,</span><span>100</span><span>,</span><span>150</span><span>,</span><span>170</span><span>,</span><span>190</span><span>,</span><span>190</span><span>,</span><span>200</span><span>,</span><span>220</span><span>,</span><span>
</span><span>265</span><span>,</span><span>320</span><span>,</span><span>360</span><span>,</span><span>360</span><span>,</span><span>350</span><span>,</span><span>425</span><span>,</span><span>545</span><span>,</span><span>545</span><span>,</span><span>610</span><span>,</span><span>720</span><span>,</span><span>900</span><span>,</span><span>1200</span><span>,</span><span>1325</span><span>,</span><span>
</span><span>1625</span><span>,</span><span>1813</span><span>,</span><span>1987</span><span>,</span><span>2213</span><span>,</span><span>2516</span><span>,</span><span>3019</span><span>,</span><span>3693</span><span>,</span><span>4450</span><span>,</span><span>5333</span><span>)</span><span> </span><span>*</span><span> </span><span>1000000</span><span>
</span><span>)</span><span> </span><span>%>%</span><span>
</span><span>mutate</span><span>(</span><span>growth</span><span> </span><span>=</span><span> </span><span>lead</span><span>((</span><span>pop</span><span> </span><span>/</span><span> </span><span>lag</span><span>(</span><span>pop</span><span>))</span><span> </span><span>^</span><span> </span><span>(</span><span>1</span><span> </span><span>/</span><span> </span><span>(</span><span>year</span><span> </span><span>-</span><span> </span><span>lag</span><span>(</span><span>year</span><span>)))</span><span> </span><span>-</span><span> </span><span>1</span><span>))</span><span>
</span><span># note there's an error in Kremer's 3rd growth rate: 0.000031 should be 0.000012
</span><span>
</span><span># Global populations
</span><span>p</span><span>1</span><span> </span><span>&lt;-</span><span> </span><span>kremer</span><span> </span><span>%>%</span><span>
</span><span>ggplot</span><span>(</span><span>aes</span><span>(</span><span>x</span><span> </span><span>=</span><span> </span><span>year</span><span>,</span><span> </span><span>y</span><span> </span><span>=</span><span> </span><span>pop</span><span>))</span><span> </span><span>+</span><span>
</span><span>geom_line</span><span>()</span><span> </span><span>+</span><span>
</span><span>geom_point</span><span>()</span><span> </span><span>+</span><span>
</span><span>scale_y_log10</span><span>(</span><span>label</span><span> </span><span>=</span><span> </span><span>comma</span><span>,</span><span> </span><span>limits</span><span> </span><span>=</span><span> </span><span>c</span><span>(</span><span>1e5</span><span>,</span><span> </span><span>5e9</span><span>))</span><span> </span><span>+</span><span>
</span><span>scale_x_continuous</span><span>(</span><span>&quot;Year&quot;</span><span>)</span><span> </span><span>+</span><span>
</span><span>labs</span><span>(</span><span>caption</span><span> </span><span>=</span><span> </span><span>&quot; &quot;</span><span>)</span><span>
</span><span>p</span><span>2</span><span> </span><span>&lt;-</span><span> </span><span>p</span><span>1</span><span> </span><span>%+%</span><span> </span><span>filter</span><span>(</span><span>kremer</span><span>,</span><span> </span><span>year</span><span> </span><span>></span><span> </span><span>-2000</span><span>)</span><span>
</span><span>grid.arrange</span><span>(</span><span>p</span><span>1</span><span> </span><span>+</span><span> </span><span>labs</span><span>(</span><span>y</span><span> </span><span>=</span><span> </span><span>&quot;Global human population (logarithmic scale)&quot;</span><span>)</span><span> </span><span>+</span><span> </span><span>ggtitle</span><span>(</span><span>&quot;World population&quot;</span><span>,</span><span>
</span><span>&quot;1 million BC to 1999&quot;</span><span>),</span><span> </span><span>p</span><span>2</span><span> </span><span>+</span><span> </span><span>labs</span><span>(</span><span>y</span><span> </span><span>=</span><span> </span><span>&quot;&quot;</span><span>)</span><span> </span><span>+</span><span> </span><span>ggtitle</span><span>(</span><span>&quot;&quot;</span><span>,</span><span>
</span><span>&quot;1,000 BC to 1999&quot;</span><span>)</span><span> </span><span>+</span><span>
</span><span>labs</span><span>(</span><span>caption</span><span> </span><span>=</span><span> </span><span>&quot;Source: Kremer, 1993, 'Population Growth and Technological Change: One Million B.C. to 1990&quot;</span><span>),</span><span> </span><span>ncol</span><span> </span><span>=</span><span> </span><span>2</span><span>)</span><span>
</span><span># Global growth rates
</span><span>kremer</span><span> </span><span>%>%</span><span>
</span><span>filter</span><span>(</span><span>year</span><span> </span><span>></span><span> </span><span>-2000</span><span>)</span><span> </span><span>%>%</span><span>
</span><span>ggplot</span><span>(</span><span>aes</span><span>(</span><span>x</span><span> </span><span>=</span><span> </span><span>year</span><span>,</span><span> </span><span>y</span><span> </span><span>=</span><span> </span><span>growth</span><span>))</span><span> </span><span>+</span><span>
</span><span>geom_path</span><span>()</span><span> </span><span>+</span><span>
</span><span>geom_point</span><span>()</span><span> </span><span>+</span><span>
</span><span>geom_text_repel</span><span>(</span><span>aes</span><span>(</span><span>label</span><span> </span><span>=</span><span> </span><span>year</span><span>),</span><span> </span><span>colour</span><span> </span><span>=</span><span> </span><span>&quot;steelblue&quot;</span><span>)</span><span> </span><span>+</span><span>
</span><span>scale_y_continuous</span><span>(</span><span>&quot;Annual growth rate&quot;</span><span>,</span><span> </span><span>label</span><span> </span><span>=</span><span> </span><span>percent</span><span>)</span><span> </span><span>+</span><span>
</span><span>labs</span><span>(</span><span>caption</span><span> </span><span>=</span><span> </span><span>&quot;Source: Kremer, 1993&quot;</span><span>,</span><span>
</span><span>x</span><span> </span><span>=</span><span> </span><span>&quot;Year&quot;</span><span>)</span><span> </span><span>+</span><span>
</span><span>ggtitle</span><span>(</span><span>&quot;World population growth rates&quot;</span><span>,</span><span> </span><span>&quot;1000 BC to present&quot;</span><span>)</span></code></pre>
</figure>
<h2>Gapminder’s country-level birth rate and population estimates</h2>
<p>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.</p>
<p>Eventually I realised that <a rel="nofollow" href="https://www.gapminder.org/" target="_blank">Gapminder</a> 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.</p>
<p>This process gives me this plausible-looking set of estimates of the world’s crude birth rate over the last 200 years or so:</p>
<p><img width="100%" src="http://freerangestats.info/img/0141-birth-rate.svg"></p>
<p>These numbers are close enough (for my purposes) to the <a rel="nofollow" href="https://en.wikipedia.org/wiki/Birth_rate" target="_blank">UN’s figures</a> for the overlapping period from 1950 onwards.</p>
<p>I also quite like this representation of the population and the birth rate together as a connected scatter plot:</p>
<p><img width="100%" src="http://freerangestats.info/img/0141-birth-rate-csp.svg"></p>
<p>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:</p>
<p><img width="100%" src="http://freerangestats.info/img/0141-birth-numbers.svg"></p>
<p>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.</p>
<p>Here’s the code to get the data from Gapminder and draw those charts:</p>
<figure>
<pre><code data-lang="r"><span>#---------------birth rate---------------
# harder
# See https://ourworldindata.org/fertility-rate
# nothing before 1950
# The gapminder R package only has data for every 5 years, from 1952
# but the gapminder website has the full data
</span><span>
</span><span># crude birth rate per country per year
</span><span>if</span><span>(</span><span>!</span><span>file.exists</span><span>(</span><span>&quot;cbr.xlsx&quot;</span><span>)){</span><span>
</span><span>download.file</span><span>(</span><span>&quot;https://docs.google.com/spreadsheet/pub?key=tUSeGJOQhafugwUvHvY-wLA&amp;output=xlsx&quot;</span><span>,</span><span>
</span><span>destfile</span><span> </span><span>=</span><span> </span><span>&quot;cbr.xlsx&quot;</span><span>,</span><span> </span><span>mode</span><span> </span><span>=</span><span> </span><span>&quot;wb&quot;</span><span>)</span><span>
</span><span>}</span><span>
</span><span>cbr_orig</span><span> </span><span>&lt;-</span><span> </span><span>read_excel</span><span>(</span><span>&quot;cbr.xlsx&quot;</span><span>)</span><span> </span><span>names</span><span>(</span><span>cbr_orig</span><span>)[</span><span>1</span><span>]</span><span> </span><span>&lt;-</span><span> </span><span>&quot;country&quot;</span><span>
</span><span>cbr</span><span> </span><span>&lt;-</span><span> </span><span>cbr_orig</span><span> </span><span>%>%</span><span>
</span><span>gather</span><span>(</span><span>year</span><span>,</span><span> </span><span>birth_rate</span><span>,</span><span> </span><span>-</span><span>country</span><span>)</span><span> </span><span>%>%</span><span>
</span><span>mutate</span><span>(</span><span>year</span><span> </span><span>=</span><span> </span><span>as.integer</span><span>(</span><span>year</span><span>))</span><span>
</span><span># population per country per year
</span><span>if</span><span>(</span><span>!</span><span>file.exists</span><span>(</span><span>&quot;pop.xlsx&quot;</span><span>)){</span><span>
</span><span>download.file</span><span>(</span><span>&quot;https://docs.google.com/spreadsheet/pub?key=phAwcNAVuyj0XOoBL_n5tAQ&amp;output=xlsx&quot;</span><span>,</span><span>
</span><span>destfile</span><span> </span><span>=</span><span> </span><span>&quot;pop.xlsx&quot;</span><span>,</span><span> </span><span>mode</span><span> </span><span>=</span><span> </span><span>&quot;wb&quot;</span><span>)</span><span>
</span><span>}</span><span>
</span><span>pop_orig</span><span> </span><span>&lt;-</span><span> </span><span>read_excel</span><span>(</span><span>&quot;pop.xlsx&quot;</span><span>)</span><span>
</span><span>names</span><span>(</span><span>pop_orig</span><span>)[</span><span>1</span><span>]</span><span> </span><span>&lt;-</span><span> </span><span>&quot;country&quot;</span><span>
</span><span>pop</span><span> </span><span>&lt;-</span><span> </span><span>pop_orig</span><span> </span><span>%>%</span><span>
</span><span>gather</span><span>(</span><span>year</span><span>,</span><span> </span><span>total_population</span><span>,</span><span> </span><span>-</span><span>country</span><span>)</span><span> </span><span>%>%</span><span>
</span><span>mutate</span><span>(</span><span>year</span><span> </span><span>=</span><span> </span><span>as.integer</span><span>(</span><span>year</span><span>))</span><span>
</span><span>combined</span><span> </span><span>&lt;-</span><span> </span><span>cbr</span><span> </span><span>%>%</span><span>
</span><span>full_join</span><span>(</span><span>pop</span><span>,</span><span> </span><span>by</span><span> </span><span>=</span><span> </span><span>c</span><span>(</span><span>&quot;year&quot;</span><span>,</span><span> </span><span>&quot;country&quot;</span><span>))</span><span> </span><span>%>%</span><span>
</span><span>arrange</span><span>(</span><span>country</span><span>,</span><span> </span><span>year</span><span>)</span><span> </span><span>%>%</span><span>
</span><span>mutate</span><span>(</span><span>births</span><span> </span><span>=</span><span> </span><span>total_population</span><span> </span><span>*</span><span> </span><span>birth_rate</span><span> </span><span>/</span><span> </span><span>1000</span><span>)</span><span> </span><span>%>%</span><span>
</span><span>filter</span><span>(</span><span>!</span><span>is.na</span><span>(</span><span>total_population</span><span>))</span><span> </span><span>ave_br</span><span> </span><span>&lt;-</span><span> </span><span>combined</span><span> </span><span>%>%</span><span>
</span><span>filter</span><span>(</span><span>!</span><span>is.na</span><span>(</span><span>birth_rate</span><span>))</span><span> </span><span>%>%</span><span>
</span><span>group_by</span><span>(</span><span>year</span><span>)</span><span> </span><span>%>%</span><span>
</span><span>summarise</span><span>(</span><span>birth_rate</span><span> </span><span>=</span><span> </span><span>sum</span><span>(</span><span>birth_rate</span><span> </span><span>*</span><span> </span><span>total_population</span><span>)</span><span> </span><span>/</span><span> </span><span>sum</span><span>(</span><span>total_population</span><span>),</span><span>
</span><span>total_population</span><span> </span><span>=</span><span> </span><span>sum</span><span>(</span><span>total_population</span><span>))</span><span> </span><span>%>%</span><span>
</span><span>mutate</span><span>(</span><span>year_lab</span><span> </span><span>=</span><span> </span><span>ifelse</span><span>(</span><span>year</span><span> </span><span>%%</span><span> </span><span>50</span><span> </span><span>==</span><span> </span><span>0</span><span>,</span><span> </span><span>year</span><span>,</span><span> </span><span>&quot;&quot;</span><span>),</span><span>
</span><span>people_born</span><span> </span><span>=</span><span> </span><span>birth_rate</span><span> </span><span>*</span><span> </span><span>total_population</span><span> </span><span>/</span><span> </span><span>1000</span><span>)</span><span>
</span><span>set.seed</span><span>(</span><span>123</span><span>)</span><span>
</span><span>ave_br</span><span> </span><span>%>%</span><span>
</span><span>ggplot</span><span>(</span><span>aes</span><span>(</span><span>x</span><span> </span><span>=</span><span> </span><span>year</span><span>,</span><span> </span><span>y</span><span> </span><span>=</span><span> </span><span>birth_rate</span><span>))</span><span> </span><span>+</span><span>
</span><span>geom_line</span><span>()</span><span> </span><span>+</span><span>
</span><span>geom_point</span><span>()</span><span> </span><span>+</span><span>
</span><span>geom_text_repel</span><span>(</span><span>aes</span><span>(</span><span>label</span><span> </span><span>=</span><span> </span><span>year_lab</span><span>),</span><span> </span><span>colour</span><span> </span><span>=</span><span> </span><span>&quot;steelblue&quot;</span><span>)</span><span> </span><span>+</span><span>
</span><span>labs</span><span>(</span><span>caption</span><span> </span><span>=</span><span> </span><span>&quot;Source: Estimated from Gapminder country level data for crude birth rate and population&quot;</span><span>,</span><span>
</span><span>x</span><span> </span><span>=</span><span> </span><span>&quot;Year&quot;</span><span>,</span><span>
</span><span>y</span><span> </span><span>=</span><span> </span><span>&quot;Estimated global crude birth rate per 1,000 population&quot;</span><span>)</span><span> </span><span>+</span><span>
</span><span>ggtitle</span><span>(</span><span>&quot;Estimated global crude birth rate&quot;</span><span>,</span><span>
</span><span>&quot;1800 to present&quot;</span><span>)</span><span>
</span><span>ave_br</span><span> </span><span>%>%</span><span>
</span><span>ggplot</span><span>(</span><span>aes</span><span>(</span><span>x</span><span> </span><span>=</span><span> </span><span>total_population</span><span> </span><span>/</span><span> </span><span>1e6</span><span>,</span><span> </span><span>y</span><span> </span><span>=</span><span> </span><span>birth_rate</span><span>,</span><span> </span><span>label</span><span> </span><span>=</span><span> </span><span>year_lab</span><span>))</span><span> </span><span>+</span><span>
</span><span>geom_path</span><span>()</span><span> </span><span>+</span><span>
</span><span>geom_text_repel</span><span>(</span><span>colour</span><span> </span><span>=</span><span> </span><span>&quot;steelblue&quot;</span><span>)</span><span> </span><span>+</span><span>
</span><span>scale_x_continuous</span><span>(</span><span>&quot;Estimated global population&quot;</span><span>,</span><span> </span><span>label</span><span> </span><span>=</span><span> </span><span>comma_format</span><span>(</span><span>suffix</span><span> </span><span>=</span><span> </span><span>&quot;m&quot;</span><span>))</span><span> </span><span>+</span><span>
</span><span>labs</span><span>(</span><span>y</span><span> </span><span>=</span><span> </span><span>&quot;Estimated global crude birth rate per 1,000 population&quot;</span><span>,</span><span>
</span><span>caption</span><span> </span><span>=</span><span> </span><span>&quot;Source: Estimated from Gapminder country level data for crude birth rate and population&quot;</span><span>)</span><span> </span><span>+</span><span>
</span><span>ggtitle</span><span>(</span><span>&quot;Estimated global crude birth rate&quot;</span><span>,</span><span>
</span><span>&quot;1800 to present&quot;</span><span>)</span><span>
</span><span>ave_br</span><span> </span><span>%>%</span><span>
</span><span>ggplot</span><span>(</span><span>aes</span><span>(</span><span>x</span><span> </span><span>=</span><span> </span><span>year</span><span>,</span><span> </span><span>y</span><span> </span><span>=</span><span> </span><span>people_born</span><span> </span><span>/</span><span> </span><span>1e6</span><span>))</span><span> </span><span>+</span><span>
</span><span>geom_line</span><span>()</span><span> </span><span>+</span><span>
</span><span>scale_y_continuous</span><span>(</span><span>&quot;People born per year&quot;</span><span>,</span><span> </span><span>label</span><span> </span><span>=</span><span> </span><span>comma_format</span><span>(</span><span>suffix</span><span> </span><span>=</span><span> </span><span>&quot;m&quot;</span><span>))</span><span> </span><span>+</span><span>
</span><span>labs</span><span>(</span><span>caption</span><span> </span><span>=</span><span> </span><span>&quot;Source: Estimated from Gapminder country level data for crude birth rate and population&quot;</span><span>,</span><span>
</span><span>x</span><span> </span><span>=</span><span> </span><span>&quot;Year&quot;</span><span>)</span><span> </span><span>+</span><span>
</span><span>ggtitle</span><span>(</span><span>&quot;Estimated global births&quot;</span><span>,</span><span>
</span><span>&quot;1800 to present&quot;</span><span>)</span></code></pre>
</figure>
<h3>Checking against a more definitive source for more recent years</h3>
<p>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:</p>
<p><img width="100%" src="http://freerangestats.info/img/0141-compare.svg"></p>
<p>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:</p>
<figure>
<pre><code data-lang="r"><span>#------------------better source for more recent years----------
</span><span>library</span><span>(</span><span>WDI</span><span>)</span><span>
</span><span>wdi_cbr</span><span> </span><span>&lt;-</span><span> </span><span>WDI</span><span>(</span><span>country</span><span> </span><span>=</span><span> </span><span>&quot;1W&quot;</span><span>,</span><span> </span><span>indicator</span><span> </span><span>=</span><span> </span><span>&quot;SP.DYN.CBRT.IN&quot;</span><span>,</span><span> </span><span>start</span><span> </span><span>=</span><span> </span><span>1950</span><span>,</span><span> </span><span>end</span><span> </span><span>=</span><span> </span><span>2020</span><span>)</span><span>
</span><span>CairoSVG</span><span>(</span><span>&quot;..http://freerangestats.info/img/0141-compare.svg&quot;</span><span>,</span><span> </span><span>7</span><span>,</span><span> </span><span>6</span><span>)</span><span>
</span><span>wdi_cbr</span><span> </span><span>%>%</span><span>
</span><span>select</span><span>(</span><span>year</span><span>,</span><span> </span><span>SP.DYN.CBRT.IN</span><span>)</span><span> </span><span>%>%</span><span>
</span><span>rename</span><span>(</span><span>wdi</span><span> </span><span>=</span><span> </span><span>SP.DYN.CBRT.IN</span><span>)</span><span> </span><span>%>%</span><span>
</span><span>left_join</span><span>(</span><span>ave_br</span><span>,</span><span> </span><span>by</span><span> </span><span>=</span><span> </span><span>&quot;year&quot;</span><span>)</span><span> </span><span>%>%</span><span>
</span><span>mutate</span><span>(</span><span>year_lab</span><span> </span><span>=</span><span> </span><span>ifelse</span><span>(</span><span>year</span><span> </span><span>%%</span><span> </span><span>5</span><span> </span><span>==</span><span> </span><span>0</span><span>,</span><span> </span><span>year</span><span>,</span><span> </span><span>&quot;&quot;</span><span>))</span><span> </span><span>%>%</span><span>
</span><span>ggplot</span><span>(</span><span>aes</span><span>(</span><span>x</span><span> </span><span>=</span><span> </span><span>birth_rate</span><span>,</span><span> </span><span>y</span><span> </span><span>=</span><span> </span><span>wdi</span><span>,</span><span> </span><span>label</span><span> </span><span>=</span><span> </span><span>year_lab</span><span>))</span><span> </span><span>+</span><span>
</span><span>geom_abline</span><span>(</span><span>slope</span><span> </span><span>=</span><span> </span><span>1</span><span>,</span><span> </span><span>intercept</span><span> </span><span>=</span><span> </span><span>0</span><span>,</span><span> </span><span>colour</span><span> </span><span>=</span><span> </span><span>&quot;orange&quot;</span><span>)</span><span> </span><span>+</span><span>
</span><span>geom_path</span><span>()</span><span> </span><span>+</span><span>
</span><span>geom_text_repel</span><span>(</span><span>colour</span><span> </span><span>=</span><span> </span><span>&quot;steelblue&quot;</span><span>)</span><span> </span><span>+</span><span>
</span><span>labs</span><span>(</span><span>x</span><span> </span><span>=</span><span> </span><span>&quot;Population-weighted average of Gapminder country data&quot;</span><span>,</span><span>
</span><span>y</span><span> </span><span>=</span><span> </span><span>&quot;World Bank's World Development Indicators&quot;</span><span>)</span><span> </span><span>+</span><span>
</span><span>coord_equal</span><span>()</span><span> </span><span>+</span><span>
</span><span>ggtitle</span><span>(</span><span>&quot;Comparing two sources on global birth rates&quot;</span><span>)</span></code></pre>
</figure>
<h2>Cumulative births</h2>
<p>Finally, the answer to the question, which turns out to be about 9.75 billion:</p>
<p><img width="100%" src="http://freerangestats.info/img/0141-cumulative-births.svg"></p>
<p>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.</p>
<p>I saved the <a rel="nofollow" href="http://freerangestats.info/data/cumulative-births-1800-onwards.csv" target="_blank">birth numbers from 1800 onwards as a CSV</a> in case anyone is interested in them.</p>
<p>Here’s the code for the final step:</p>
<figure>
<pre><code data-lang="r"><span>#-----------cumulative births-------------
</span><span>twentieth_c</span><span> </span><span>&lt;-</span><span> </span><span>data_frame</span><span>(</span><span>
</span><span>year</span><span> </span><span>=</span><span> </span><span>1901</span><span>:</span><span>2000</span><span>,</span><span>
</span><span>births</span><span> </span><span>=</span><span> </span><span>approx</span><span>(</span><span>ave_br</span><span>$</span><span>year</span><span>,</span><span> </span><span>ave_br</span><span>$</span><span>people_born</span><span>,</span><span> </span><span>xout</span><span> </span><span>=</span><span> </span><span>1901</span><span>:</span><span>2000</span><span>)</span><span>$</span><span>y</span><span> </span><span>)</span><span> </span><span>%>%</span><span>
</span><span>mutate</span><span>(</span><span>cum_births</span><span> </span><span>=</span><span> </span><span>cumsum</span><span>(</span><span>births</span><span>))</span><span>
</span><span>twentieth_c</span><span> </span><span>%>%</span><span>
</span><span>ggplot</span><span>(</span><span>aes</span><span>(</span><span>x</span><span> </span><span>=</span><span> </span><span>year</span><span>,</span><span> </span><span>y</span><span> </span><span>=</span><span> </span><span>cum_births</span><span> </span><span>/</span><span> </span><span>1e6</span><span>))</span><span> </span><span>+</span><span>
</span><span>geom_line</span><span>()</span><span> </span><span>+</span><span>
</span><span>scale_y_continuous</span><span>(</span><span>&quot;Cumulative births in the twentieth century&quot;</span><span>,</span><span> </span><span>label</span><span> </span><span>=</span><span> </span><span>comma_format</span><span>(</span><span>suffix</span><span> </span><span>=</span><span> </span><span>&quot;m&quot;</span><span>))</span><span> </span><span>+</span><span>
</span><span>labs</span><span>(</span><span>x</span><span> </span><span>=</span><span> </span><span>&quot;Year&quot;</span><span>,</span><span>
</span><span>caption</span><span> </span><span>=</span><span> </span><span>&quot;Source: Estimates based on Gapminder country level data for crude birth rate and population&quot;</span><span>)</span><span> </span><span>+</span><span>
</span><span>ggtitle</span><span>(</span><span>&quot;How many people born in the twentieth century?&quot;</span><span>,</span><span>
</span><span>paste</span><span>(</span><span>&quot;An estimated&quot;</span><span>,</span><span> </span><span>format</span><span>(</span><span>round</span><span>(</span><span>sum</span><span>(</span><span>twentieth_c</span><span>$</span><span>births</span><span> </span><span>/</span><span> </span><span>1e6</span><span>)),</span><span> </span><span>big.mark</span><span> </span><span>=</span><span> </span><span>&quot;,&quot;</span><span>),</span><span> </span><span>&quot;million&quot;</span><span>))</span><span>
</span><span># Write a version from 1800 onwards in case people want it:
</span><span>published_data</span><span> </span><span>&lt;-</span><span> </span><span>data_frame</span><span>(</span><span>year</span><span> </span><span>=</span><span> </span><span>min</span><span>(</span><span>ave_br</span><span>$</span><span>year</span><span>)</span><span>:</span><span>max</span><span>(</span><span>ave_br</span><span>$</span><span>year</span><span>))</span><span> </span><span>%>%</span><span>
</span><span>mutate</span><span>(</span><span> </span><span>births</span><span> </span><span>=</span><span> </span><span>round</span><span>(</span><span>approx</span><span>(</span><span>ave_br</span><span>$</span><span>year</span><span>,</span><span> </span><span>ave_br</span><span>$</span><span>people_born</span><span>,</span><span> </span><span>xout</span><span> </span><span>=</span><span> </span><span>year</span><span>)</span><span>$</span><span>y</span><span>))</span><span> </span><span>%>%</span><span>
</span><span>mutate</span><span>(</span><span>cum_births</span><span> </span><span>=</span><span> </span><span>cumsum</span><span>(</span><span>births</span><span>))</span></code></pre>
</figure>
	<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="http://freerangestats.info/blog/2018/12/01/number-births"> free range statistics - R</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a rel="nofollow" href="https://www.r-project.org/" title="The R Project for Statistical Computing">R</a> news and <a rel="nofollow" href="https://www.r-bloggers.com/search/tutorial" title="R tutorials">tutorials</a> on topics such as: <a rel="nofollow" href="https://www.r-bloggers.com/search/data%20science" title="Data science">Data science</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data" title="Big Data">Big Data, <a rel="nofollow" href="https://www.r-users.com/" title="R jobs">R jobs</a>, visualization (<a rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2" title="ggplot and ggplot2 tutorials">ggplot2</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/boxplot" title="Boxplots using lattice and ggplot2 tutorials">Boxplots</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/map" title="Maps and gis">maps</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/animation" title="Animation in R">animation</a>), programming (<a rel="nofollow" href="https://www.r-bloggers.com/search/RStudio" title="RStudio IDE for R">RStudio</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/sweave" title="Sweave and literate programming">Sweave</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX" title="LaTeX in R">LaTeX</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/SQL" title="SQL and databases">SQL</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/eclipse" title="Eclipse IDE for R">Eclipse</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/git" title="git and github, Version Control System">git</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/hadoop" title="Large data in R using Hadoop">hadoop</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping" title="Web Scraping of google, facebook, yahoo, twitter and more using R">Web Scraping</a>) statistics (<a rel="nofollow" href="https://www.r-bloggers.com/search/regression" title="Regressions and ANOVA analysis tutorials">regression</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/PCA" title="principal component analysis tutorial">PCA</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/time+series" title="Time series">time series</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/trading" title="finance trading">trading</a>) and more...
<img width="1" alt="" src="http://feeds.feedburner.com/~r/RBloggers/~4/O8F4qYDLqaA" height="1"></a></div>