Get startedGet started for free

The number of deaths

Cynthia's professor now asks her to explore the number of deaths in the life table. The deaths at age \(x\) are labeled \(d_x\). Can you picture the number of deaths \(d_x\) by age \(x\)?

Moreover, Cynthia learned that \(d_x\) is the expected number of people who die at age \(x\) out of a group of \(\ell_x\) survivors. You will generate binomial samples for the number of deaths at age \(x\) and compare simulated data with the registered \(d_x\).

The object life_table is preloaded in your R workspace as well as the extracted columns age, qx, lx and dx.

This exercise is part of the course

Life Insurance Products Valuation in R

View Course

Exercise instructions

  • Plot dx versus age to examine the number of deaths by age. Using type = "h" you obtain vertical lines instead of points.
  • Simulate the number of deaths at each age \(x\) based on the number of survivors lx and the mortality rates qx. Use rbinom() (docs) to generate in a vectorized way from a binomial distribution.
  • Plot the simulated number of deaths sims on top of the existing graph using points() (docs). Crosses are used as symbols by specifying pch = 4.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Plot the number of deaths dx by age
plot(___, ___, 
    type = "h", 
    pch = 20, 
    xlab = "Age x", 
    ylab = expression("d"[x]),
    main = "Number of deaths (Belgium, females, 1999)")

# Simulate the number of deaths using a binomial distribution
sims <- ___(n = ___, size = ___, prob = ___)
  
# Plot the simulated number of deaths on top of the previous graph
points(___, ___, 
    pch = 4, 
    col = "red")
Edit and Run Code