Modeling Age‑Structured Populations with the Leslie Matrix in Python
This article explains the Leslie matrix model for age‑structured population forecasting, outlines its mathematical formulation, demonstrates how to build and solve it using Python code, and shows how to derive demographic indicators such as average age, lifespan, aging index, and dependency ratio.
The Malthus and logistic models describe total population size, but studying age‑related issues such as aging or labor force changes requires modeling the age distribution. The Leslie model, based on difference‑equation theory, provides a matrix formulation for age‑ and gender‑structured populations.
The Leslie model constructs a column vector of female population by age for a chosen initial year, builds a Leslie matrix from age‑specific fertility and survival rates, and multiplies the matrix by the vector to obtain the next period’s female population; total population is then derived using the sex ratio.
It is a discrete model that can predict population size and age structure for one or multiple regions over short‑ or long‑term horizons, reflecting future total population and structural characteristics.
The model incorporates gender groups, age‑specific fertility rates, age‑specific survival rates, and optionally migration vectors. When migration is ignored, the model simplifies to a basic Leslie matrix.
The key to solving the Leslie model is determining the fertility rates, survival rates, and migration vectors; once these parameters are set, the model can be iterated for any 5‑year interval to obtain female population by age, and male numbers are derived using the projected sex ratio.
Short‑term forecasts estimate fertility, mortality, and migration from historical data, while long‑term forecasts must consider total fertility control and national policies.
With the Leslie model’s age‑ and gender‑specific outputs, additional demographic indicators can be computed:
Total population
Average age
Average lifespan
Aging index (ratio of average age to average lifespan)
Dependency ratio (average number of dependents supported by each working‑age individual, with working ages defined as ages 4–13)
These indicators enable a more detailed analysis of population distribution, trends, and their impact on socioeconomic development.
As an example, a Leslie model for Heilongjiang province is built using 2010 census data. The following Python code implements the model (adapted from Matlab code in the reference):
<code>import numpy as
f0 = 0.9817*(1-0.5315) # female infant survival rate
r2010 = np.array([5.71,48.99,44.95,25.99,11.99,7.02,5.63])*5/1000 # fertility rates for women of child‑bearing ages
ds = np.array([153+140,103,111,205,404,419,569,1071,1978,2780,4269,6193,7726,9042,1278,11633,9123,4678])*5
fs = np.array([117104+537180,714639,81464,1107182,1655243,1396146,1498008,1919028,1938905,1795568,1493621,1351239,927440,601077,498540,295376,148500,57211])
dr = ds/fs
s = 1 - dr # survival rates for each age group
# generate Leslie matrix
L = np.zeros((19,19))
L[0,3:10] = f0*r2010
for i in range(1,19):
L[i,i-1] = s[i-1]
</code>Ignoring migration, the initial female population vector for 2010 is used to iterate the model, producing the 2015 and 2020 female age‑distribution vectors, and continuing for eight iterations to forecast up to 2050. Male numbers are obtained by forecasting the sex ratio (e.g., using a grey‑model fusion method) and applying it to each age group. The resulting forecasts allow calculation of average lifespan, aging index, dependency ratio, and other metrics.
Reference: Zhang Jingxin, Luo Zhikun, Zhou Qingxin et al., Mathematical Modeling Algorithms and Programming Implementation .
Model Perspective
Insights, knowledge, and enjoyment from a mathematical modeling researcher and educator. Hosted by Haihua Wang, a modeling instructor and author of "Clever Use of Chat for Mathematical Modeling", "Modeling: The Mathematics of Thinking", "Mathematical Modeling Practice: A Hands‑On Guide to Competitions", and co‑author of "Mathematical Modeling: Teaching Design and Cases".
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.