Hannah H.
Hannah H.

Reputation: 276

How to test if mortality rate is correct

This question is related to a question I asked some time ago.

I am trying to create a population in NetLogo. Therefore, I am trying to start with the mortality rate. However, I am not sure how to test if my code works. The age of the oldest dying turtles seems to be fine, however when I print the mean death-ages it is way too high and I don't know how to solve that.

The model is available here.

The problem might be the calculation of the probability of dying which I did as follows:

  if (gender = "female") [
    let die-val mortality-female age ; mortality prob included for the age of the turtle
    if (die-val >= random-float 1)[
       set prob-die? true
    ]
  ]

Upvotes: 0

Views: 229

Answers (1)

Luke C
Luke C

Reputation: 10301

It looks like your code is working fine, but your implementation may be unrealistic.Your turtles all eventually die, and because your mortality likelihoods increase as age increases, your older turtles contribute far more to the death-ages list than the younger turtles. For example, after running go until all turtles were 90, there were still 52 turtles alive- so all of those (over half) would contribute their old age to the death-ages list. So, your death-ages list is strongly left-skewed, something like:

enter image description here

Where your average death-age over 100 replicates is around 90.5 years. I think this is due to your aging process- try only having your turtle age increase by 1 instead of 5- see if that gives output more like you're expecting. It immediately changes the distribution to look more normal, where your mean death-age for 100 reps is around 81.2 years:

enter image description here

Edit:

You can quickly set up a histogram using a plot widget with settings like this:

enter image description here

Note that the code

if length death-ages > 0 [
   set-plot-x-range ( min death-ages - 5 ) ( max death-ages + 5)
]

is included because auto-scaling does not work for the x-scale of histograms. You can exclude that code in the "Plot update commands" field and manually set your x min and max if you'd like, but you'll miss any turtles that die after whatever x max value that you choose.

You also need to change your pen settings from line to bar- click the pencil icon at the right of the pen field to open the menu below and select "Bar" from the "Mode" drop-down menu. Note as well that I've set my "Interval" to 5 to get the plots as shown above.

enter image description here

Upvotes: 1

Related Questions