Human Population Dynamics (v2)

Human Population Dynamics (v2) preview image

1 collaborator

Default-person Connor Bain (Author)


(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by everyone
Model was written in NetLogo 5.0.4 • Viewed 27 times • Downloaded 0 times • Run 0 times
Download the 'Human Population Dynamics (v2)' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


This model simulates a human population over time given: -a total fertility rate (TFR): the average number of children a woman would have over her lifetime -an infant mortality rate: for every 1000 births, how many children die before their first birthday? -a life expectancy: the age for which a person has a 50% chance of dying before that age (ignoring infant mortality in this case)

The agents ("turtles") in the model represent humans, and are described by two properties: their sex and their age.


Every "tick" of the model represents one year. Every year the following happen:

  • Infant mortality: The model makes a list of all the agents with age 0. Each infant is assigned a random number, and if this is below a threshold set by the infant-mortality slider, the infant is killed. -Increment age: All turtles add 1 year to their age. -Death: Similar to the process for infant mortality, but instead of just infants, all agents draw a random number. This number is compared to the value of a function which provides the probability of death given a person's age and the value of life-expectancy. -Reproduction: A list of all females of child-bearing age is compiled. Again, a random number is selected for each and compared to a probability set by the total-fertility slider. For example, if the TFR is 3.0, on average a woman will have 3 children in her lifetime. If the length of time she can have children is 30 years, 3 children/30 years = 0.1 children per year, or a 10% chance of having a child in a given year. -Plots and outputs are updated with the latest information from that year.


Press the "Setup" button to load the model with an initial population. By default, this creates 500 people (set in the initial-pop box) with approximately equal numbers of males and females (blue and pink in the "world" box, respectively) with a random distribution of ages from 0 to 100. Note, this is NOT A REALISTIC SETUP for ages in the real world -- there are not as many 100 year-olds as babies. The model will start to correct this in the first few years of running, however.

The other parameters for the simulation are set by the sliders on the lefthand side. Their effects are described above in detail, but but broadly, total-fertility determines how many new babies are created, infant-mortality determines how many of them die before age 1, and life-expectancy determines how the probability of death increases with age.

Press "Go" to start the model running with the parameters set by the sliders. When adjusting the sliders, it's often easier to pause the model by clicking Go again and then continuing after making adjustments.

In the world box (center), the agents wander randomly on a green background. Their pink and blue colors are adjusted to start as a light tint when they're young and gradually shade darker as they age. Looking at the world can be useful sometimes, but when there are a lot of people it can cause the model to run slower. Unchecking the box labeled "view updates" at top center hides the world and can help it to run faster.

Of the three plots, the top left shows the total population with time. The top right is an age structure diagram, essentially a histogram of how many people in the model have ages within each 5 year range (0-4, 5-9, etc.). Females and males are plotted with bars extending up and down, respectively. The bottom graph shows a moving average of the crude birth and death rates. That is, every year the model counts how many births and deaths occurred and scales them to a standard population of 1000. Then the model averages these rates over the previous 10 years and plots this value. This reduces the amount of jitter in the rates, since we're looking at a relatively small population. Also note that in the first 10 years of the run, the rates are filled with 0 values, so this graph will also be unrealistic at the very beginning. The numberical outputs show the total population value, the year's crude birth and death rates, and the growth rate percent, calculated by (crude birth rate - crude death rate)/10.


How does the age structure diagram change with time? At what ages are most of the deaths occurring? How does this compare with the life-expectancy slider? Compare times when the total population is increasing or decreasing with the values of the crude birth rate and crude death rate.


Watch the age structure diagram for high and low values of TFR with high and low values of life expectancy. Simulate a baby boom by raising the TFR for a few years and then returning it to something lower. Look up real values for various countries in the CIA World Factbook ( for instance, and see how well you can model them. For a given life expectancy, can you find what values of TFR lead to an exponentially increasing population vs. a population that crashes to zero?


Try adapting to have different life expectancies for men and women. Mortality is modeled using a Gompertz Law function depending only on age, but it could have an age-independent component, too (Gompertz-Makeham). The model assumes population only changes through births and deaths -- immigration/emigration could be added to make it more realistic.


The NetLogo histogram function doesn't allow for downward-extending bars, so the age structure diagram required more coding by hand.


Adapted from the model in NetLogo Tutorial #3

Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

globals [nbirths ndeaths crude-birth crude-death growth-rate i x1 x2 birthrate-hist deathrate-hist birth-moving-avg death-moving-avg alpha]
breed [males male]
breed [females female]
turtles-own [age] ;; for keeping track of when the turtle is ready
                     ;; to reproduce and when it will die

to setup

to setup-patches
  ask patches [ set pcolor green ]

to setup-turtles
  ;create-turtles 1000    ;; uses the value of the number slider to create turtles
  create-males (initial-pop / 2) [set color blue set age random 100 set shape "person"]
  create-females (initial-pop / 2) [set color pink set age random 100 set shape "person"]
  ask turtles [ setxy random-xcor random-ycor ]

to go
  if count turtles = 0 [ stop ]  ;; stop after 500 ticks
  set ndeaths 0
  set nbirths 0

  ifelse count turtles != 0
  [set growth-rate  ((nbirths - ndeaths) / count turtles) * 100]
  [set growth-rate 0]

  ;ifelse count turtles != 0

to move-turtles
  ask turtles [
    right random 360
    forward 1

to inc-age
  ask turtles [
   set age age + 1
  ifelse age < 100
  [ask males[set color scale-color blue age 100 0]
    ask females [set color scale-color pink age 100 0]
  [set color black]

to reproduce
  if ticks = 0 [set birthrate-hist [0 0 0 0 0 0 0 0 0 0]]
  ask females with [age >= 15 and age <= 45]
  [if random 1000 < (total-fertility-rate / (45 - 15)) * 1000 [
    set nbirths nbirths + 1
    ifelse random 2 = 0
    [ hatch-females 1 [set age 0 set color white set shape "person"] ]
    [ hatch-males 1 [set age 0 set color white set shape "person"] ]
  ifelse count turtles  != 0
  [set crude-birth (nbirths / count turtles) * 1000]
  [set crude-birth 0]
  set birthrate-hist but-first birthrate-hist
  set birthrate-hist lput crude-birth birthrate-hist
  set birth-moving-avg mean birthrate-hist

to inf-mort
  ;print infant-mortality
  ;print count turtles with [age = 0]
  ask turtles with [ age = 0]
   if (random 1000 < infant-mortality)[
     set ndeaths ndeaths + 1

to check-death
  if ticks = 0 [set deathrate-hist [0 0 0 0 0 0 0 0 0 0]]
  set alpha (0.085 * 0.5 / (exp(0.085 * life-expectancy) - 1))
  ask turtles [
    ;Mapping life expectancy to probability of death through the 50% point on the Gompertz cummulative density function
     ;if random 1000 < ( 1 - exp(-(0.693) * (1 - exp(0.085 * age)) / (1 - exp(0.085 * life-expectancy)))) * 1000 [
      ;if random 1000 < ( 1 - ( exp ( ( 1 - exp(0.085 * age)) / ( 1 - exp(0.085 * life-expectancy)) * -0.693))) * 1000 [
      if random 1000 < (alpha * exp(0.085 * age)) * 1000 [
      set ndeaths ndeaths + 1
  ifelse count turtles  != 0
  [set crude-death (ndeaths / count turtles) * 1000]
  [set crude-death 0]
  set deathrate-hist but-first deathrate-hist
  set deathrate-hist lput crude-death deathrate-hist
  set death-moving-avg mean deathrate-hist

There is only one version of this model, created 4 months ago by Connor Bain.

Attached files

File Type Description Last updated
Human Population Dynamics (v2).png preview Preview for 'Human Population Dynamics (v2)' 4 months ago, by Connor Bain Download

This model does not have any ancestors.

This model does not have any descendants.