Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/chapters/chap08.ipynb
Views: 531
Printed and electronic copies of Modeling and Simulation in Python are available from No Starch Press and Bookshop.org and Amazon.
Projecting Population Growth
Modeling and Simulation in Python
Copyright 2021 Allen Downey
License: Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International
Here's the data from the previous chapters, one last time.
And here are the functions from the previous chapter.
In the previous chapter we developed a quadratic model of world population growth from 1950 to 2016. It is a simple model, but it fits the data well and the mechanisms it's based on are plausible.
In this chapter we'll use the quadratic model to generate projections of future growth, and compare our results to projections from actual demographers.
Generating Projections
Let's run the quadratic model, extending the results until 2100, and see how our projections compare to the professionals'.
Here's the quadratic growth function again.
And here are the system parameters.
With t_end=2100
, we can generate the projection by calling run_simulation
the usual way.
Here are the last few values in the results.
Here's what the results look like.
According to the model, population growth will slow gradually after 2020, approaching 12.6 billion by 2100.
I am using the word projection deliberately, rather than prediction, with the following distinction: "prediction" implies something like "this is what we expect to happen, at least approximately"; "projection" implies something like "if this model is a good description of the system, and if nothing in the future causes the system parameters to change, this is what would happen."
Using "projection" leaves open the possibility that there are important things in the real world that are not captured in the model. It also suggests that, even if the model is good, the parameters we estimate based on the past might be different in the future.
The quadratic model we've been working with is based on the assumption that population growth is limited by the availability of resources; in that scenario, as the population approaches carrying capacity, birth rates fall and death rates rise because resources become scarce.
If that assumption is valid, we might be able to use actual population growth to estimate carrying capacity, provided we observe the transition into the population range where the growth rate starts to fall.
But in the case of world population growth, those conditions don't apply. Over the last 50 years, the net growth rate has leveled off, but not yet started to fall, so we don't have enough data to make a credible estimate of carrying capacity. And resource limitations are probably not the primary reason growth has slowed. As evidence, consider:
First, the death rate is not increasing; rather, it has declined from 1.9% in 1950 to 0.8% now (see http://modsimpy.com/mortality). So the decrease in net growth is due entirely to declining birth rates.
Second, the relationship between resources and birth rate is the opposite of what the model assumes; as nations develop and people become more wealthy, birth rates tend to fall.
We should not take too seriously the idea that this model can estimate carrying capacity. But the predictions of a model can be credible even if the assumptions of the model are not strictly true. For example, population growth might behave as if it is resource limited, even if the actual mechanism is something else.
In fact, demographers who study population growth often use models similar to ours. In the next section, we'll compare our projections to theirs.
Comparing Projections
From the same Wikipedia page where we got the past population estimates, we'll read table3
, which contains projections for population growth over the next 50-100 years, generated by the U.S. Census, U.N. DESA, and the Population Reference Bureau.
The column names are long strings; for convenience, I'll replace them with abbreviations.
Here are the first few rows:
Some values are NaN
, which indicates missing data, because some organizations did not publish projections for some years. The following function plots projections from the U.N. DESA and U.S. Census. It uses dropna
to remove the NaN
values from each series before plotting it.
Here are the professional projections compared to the results of the quadratic model.
The U.N. DESA expects the world population to reach 11 billion around 2100, and then level off. Projections by U.S. Census are a little lower, and they only go until 2050.
Summary
In this chapter we use the quadratic growth model to project world population growth between now and 2100.
Real demographers expect world population to grow more slowly than our model, probably because their models are broken down by region and country, where conditions are different, and they take into account expected economic development.
Nevertheless, their projections are qualitatively similar to ours, and theirs differ from each other almost as much as they differ from ours. So the results from the model, simple as it is, are not entirely unreasonable.
If you are interested in some of the factors that go into the professional projections, you might like this video by Hans Rosling about the demographic changes we expect this century: https://www.youtube.com/watch?v=ezVk1ahRF78.
Exercises
This chapter is available as a Jupyter notebook where you can read the text, run the code, and work on the exercises. You can access the notebooks at https://allendowney.github.io/ModSimPy/.
Exercise 1
The net growth rate of world population has been declining for several decades. That observation suggests one more way to generate more realistic projections, by extrapolating observed changes in growth rate.
To compute past growth rates, we'll use a function called diff
, which computes the difference between successive elements in a Series
. For example, here are the changes from one year to the next in census
:
The first element is NaN
because we don't have the data for 1949, so we can't compute the first difference.
If we divide these differences by the populations, the result is an estimate of the growth rate during each year:
The following function computes and plots the growth rates for the census
and un
estimates:
It uses style='.'
to plot each data point with a small circle. And here's what it looks like.
Other than a bump around 1990, the net growth rate has been declining roughly linearly since 1970.
We can model the decline by fitting a line to this data and extrapolating into the future. Here's a function that takes a time stamp and computes a line that roughly fits the growth rates since 1970.
To see what it looks like, I'll create an array of time stamps from 1960 to 2020 and use alpha_func
to compute the corresponding growth rates.
Here's what it looks like, compared to the data.
If you don't like the slope
and intercept
I chose, feel free to adjust them.
Now, as an exercise, you can use this function to project world population until 2100.
Create a
System
object that includesalpha_func
as a system parameter.Define a growth function that uses
alpha_func
to compute the net growth rate at the given timet
.Run a simulation from 1960 to 2100 with your growth function, and plot the results.
Compare your projections with those from the US Census and UN.