Skip to contents

Calculate life table quantities. Function lifetab() returns an entire life table. Function lifeexp() returns life expectancy at birth. The inputs can be mortality rates (mx) or probabilities of dying (qx), though not both.

Usage

lifetab(
  data,
  mx = NULL,
  qx = NULL,
  age = age,
  sex = NULL,
  ax = NULL,
  by = NULL,
  infant = c("constant", "linear", "CD", "AK"),
  child = c("constant", "linear", "CD"),
  closed = c("constant", "linear"),
  open = "constant",
  radix = 1e+05,
  suffix = NULL
)

lifeexp(
  data,
  mx = NULL,
  qx = NULL,
  at = 0,
  age = age,
  sex = NULL,
  ax = NULL,
  by = NULL,
  infant = c("constant", "linear", "CD", "AK"),
  child = c("constant", "linear", "CD"),
  closed = c("constant", "linear"),
  open = "constant",
  suffix = NULL
)

Arguments

data

Data frame with mortality data.

mx

<tidyselect> Mortality rates, expressed as deaths per person-year lived. Possibly an rvec.

qx

<tidyselect> Probability of dying within age interval. An alternative to mx. Possibly an rvec.

age

<tidyselect> Age group labels. The labels must be interpretable by functions such as reformat_age() and age_group_type(). The first age group must start at age 0, and the last age group must be "open", with no upper limit.

sex

<tidyselect> Biological sex, with labels that can be interpreted by reformat_sex(). Needed only when infant is "CD" or "AK", or child is "CD".

ax

<tidyselect> Average age at death within age group. Optional. See Details.

by

<tidyselect> Separate life tables, or life expectancies, calculated for each combination the by variables. If a sex variable was specified, then that variable is automatically included among the by variables. If data is a grouped data frame, then the grouping variables take precedence over by.

infant

Method used to calculate life table values in age group "0". Ignored if age does not include age group "0". Default is "constant".

child

Method used to calculate life table values in age group "1-4". Ignored if age does not include age group "0". Default is "constant".

closed

Method used to calculate life table values in closed age intervals other than "0" and "1-4" (ie intervals such as "10-14" or "12"). Default is "constant".

open

Method used to calculate life table values in the final, open age group (eg "80+" or "110+"). Currently the only option is `"constant".

radix

Initial population for the lx column. Default is 100000.

suffix

Optional suffix added to new columns in result.

at

Age at which life expectancy is calculated (lifeexp() only). Default is 0`.

Value

A tibble.

Definitions of life table quantities

  • mx Deaths per person-year lived.

  • qx Probability of surviving from the start of age group 'x' to the end.

  • lx Number of people alive at the start of age group x.

  • dx Number of deaths in age group x

  • Lx Expected number of person years lived in age group x.

  • ex Life expectancy, calculated at the start of age group x.

Mortality rates mx are sometimes expressed as deaths per 1000 person-years lived, or per 100,000 person-years lived. lifetab() and lifeexp() assumed that they are expressed as deaths per person-year lived.

Calculation methods

lifetab() and lifeexp() implement several methods for calculating life table quantities from mortality rates. Each method makes different assumptions about the way that mortality rates vary within age intervals:

  • "constant" Mortality rates are constant within each interval.

  • "linear". Life table quantity lx is a straight line within each interval. Equivalently, deaths are distributed uniformly within each interval.

  • "CD". Used only with age groups "0" and "1-4". Mortality rates decline over the age interval, with the slope depending on the absolute level of infant mortality. The formulas were developed by Coale and Demeny (1983), and used in Preston et al (2001).

  • "AK". Used only with age group "0". Mortality rates decline over the age interval, with the slope depending on the absolute level of infant mortality. The formulas were formulas developed by Andreev and Kingkade (2015), and are used in the Human Mortality Database methods protocol.

For a detailed description of the methods, see the vignette for poputils.

ax

ax is the average number of years lived in an age interval by people who die in that interval. Demographers sometimes refer to it as the 'separation factor'. If a non-NA value of ax is supplied for an age group, then the results for that age group are based on the formula

$$m_x = d_x / (n_x l_x + a_x d_x)$$,

(where n_x is the width of the age interval), over-riding any methods specified via the infant, child, closed and open arguments.

Open age group when inputs are qx

The probability of dying, qx, is always 1 in the final (open) age group. qx therefore provides no direct information on mortality conditions within the final age group. lifetab() and lifeexp() use conditions in the second-to-final age group as a proxy for conditions in the final age group. When open is "constant" (which is currently the only option), and no value for ax in the final age group is provided, lifetab() and lifeexp() assume that \(m_A = m_{A-1}\), and set \(L_{A} = l_A / m_A\).

In practice, mortality is likely to be higher in the final age group than in the second-to-final age group, so the default procedure is likely to lead to inaccuracies. When the size of the final age group is very small, these inaccuracies will be inconsequential. But in other cases, it may be necessary to supply an explicit value for ax for the final age group, or to use mx rather than qx as inputs.

Using rvecs to represent uncertainty

An rvec is a 'random vector', holding multiple draws from a distribution. Using an rvec for the mx argument to lifetab() or lifeexp() is a way of representing uncertainty. This uncertainty is propagated through to the life table values, which will also be rvecs.

References

  • Preston SH, Heuveline P, and Guillot M. 2001. Demography: Measuring and Modeling Population Processes Oxford: Blackwell.

  • Coale AJ, Demeny P, and Vaughn B. 1983. Regional model life tables and stable populations New York: Academic Press.

  • Andreev, E.M. and Kingkade, W.W., 2015. Average age at death in infancy and infant mortality level: Reconsidering the Coale-Demeny formulas at current levels of low mortality. Demographic Research, 33, pp.363-390.

  • Human Mortality Database Methods Protocol.

  • Tools for Demographic Estimation.

See also

Examples

library(dplyr)

## life table for females based on 'level 1'
## mortality rates "West" model life table
west_lifetab |>
    filter(sex == "Female",
           level == 1) |>
    lifetab(mx = mx)
#> New names:
#>  `qx` -> `qx...5`
#>  `lx` -> `lx...6`
#>  `dx` -> `dx...7`
#>  `Lx` -> `Lx...8`
#>  `ex` -> `ex...9`
#>  `qx` -> `qx...10`
#>  `lx` -> `lx...11`
#>  `dx` -> `dx...12`
#>  `Lx` -> `Lx...13`
#>  `ex` -> `ex...14`
#> # A tibble: 21 × 14
#>    level sex    age      ax qx...5 lx...6 dx...7 Lx...8 ex...9 qx...10 lx...11
#>    <int> <chr>  <fct> <dbl>  <dbl>  <dbl>  <dbl>  <dbl>  <dbl>   <dbl>   <dbl>
#>  1     1 Female 0      0.35 0.366   1     0.366   0.762   20.0  0.381  100000 
#>  2     1 Female 1-4    1.36 0.262   0.634 0.166   2.10    30.3  0.271   61910.
#>  3     1 Female 5-9    2.25 0.0732  0.468 0.0343  2.25    36.6  0.0734  45117.
#>  4     1 Female 10-14  2.6  0.0572  0.434 0.0248  2.11    34.3  0.0571  41805.
#>  5     1 Female 15-19  2.6  0.0740  0.409 0.0303  1.97    31.2  0.0739  39416.
#>  6     1 Female 20-24  2.6  0.0919  0.379 0.0348  1.81    28.5  0.0917  36505.
#>  7     1 Female 25-29  2.6  0.103   0.344 0.0353  1.64    26.1  0.102   33159.
#>  8     1 Female 30-34  2.6  0.116   0.309 0.0357  1.46    23.8  0.115   29766.
#>  9     1 Female 35-39  2.6  0.126   0.273 0.0344  1.28    21.6  0.125   26337.
#> 10     1 Female 40-44  2.6  0.133   0.239 0.0318  1.12    19.3  0.133   23034.
#> # ℹ 11 more rows
#> # ℹ 3 more variables: dx...12 <dbl>, Lx...13 <dbl>, ex...14 <dbl>

## change method for infant and children from
## default ("constant") to "CD"
west_lifetab |>
    filter(sex == "Female",
           level == 1) |>
    lifetab(mx = mx,
            sex = sex,
            infant = "CD",
            child = "CD")
#> New names:
#>  `qx` -> `qx...5`
#>  `lx` -> `lx...6`
#>  `dx` -> `dx...7`
#>  `Lx` -> `Lx...8`
#>  `ex` -> `ex...9`
#>  `qx` -> `qx...10`
#>  `lx` -> `lx...11`
#>  `dx` -> `dx...12`
#>  `Lx` -> `Lx...13`
#>  `ex` -> `ex...14`
#> # A tibble: 21 × 14
#>    level sex    age      ax qx...5 lx...6 dx...7 Lx...8 ex...9 qx...10 lx...11
#>    <int> <chr>  <fct> <dbl>  <dbl>  <dbl>  <dbl>  <dbl>  <dbl>   <dbl>   <dbl>
#>  1     1 Female 0      0.35 0.366   1     0.366   0.762   20.0  0.366  100000 
#>  2     1 Female 1-4    1.36 0.262   0.634 0.166   2.10    30.3  0.262   63445.
#>  3     1 Female 5-9    2.25 0.0732  0.468 0.0343  2.25    36.6  0.0734  46836.
#>  4     1 Female 10-14  2.6  0.0572  0.434 0.0248  2.11    34.3  0.0571  43398.
#>  5     1 Female 15-19  2.6  0.0740  0.409 0.0303  1.97    31.2  0.0739  40918.
#>  6     1 Female 20-24  2.6  0.0919  0.379 0.0348  1.81    28.5  0.0917  37896.
#>  7     1 Female 25-29  2.6  0.103   0.344 0.0353  1.64    26.1  0.102   34422.
#>  8     1 Female 30-34  2.6  0.116   0.309 0.0357  1.46    23.8  0.115   30900.
#>  9     1 Female 35-39  2.6  0.126   0.273 0.0344  1.28    21.6  0.125   27340.
#> 10     1 Female 40-44  2.6  0.133   0.239 0.0318  1.12    19.3  0.133   23912.
#> # ℹ 11 more rows
#> # ℹ 3 more variables: dx...12 <dbl>, Lx...13 <dbl>, ex...14 <dbl>

## calculate life expectancies
## for all levels, using the 'by'
## argument to distinguish levels
west_lifetab |>
    lifeexp(mx = mx,
            sex = sex,
            infant = "CD",
            child = "CD",
            by = level)
#> # A tibble: 50 × 3
#>    level sex       ex
#>    <int> <chr>  <dbl>
#>  1     1 Female  20.0
#>  2     1 Male    18.0
#>  3     2 Female  22.5
#>  4     2 Male    20.4
#>  5     3 Female  25.0
#>  6     3 Male    22.8
#>  7     4 Female  27.5
#>  8     4 Male    25.2
#>  9     5 Female  30.0
#> 10     5 Male    27.6
#> # ℹ 40 more rows

## obtain the same result using
## 'group_by'
west_lifetab |>
  group_by(level) |>
  lifeexp(mx = mx,
          sex = sex,
          infant = "CD",
          child = "CD")
#> # A tibble: 50 × 3
#>    level sex       ex
#>    <int> <chr>  <dbl>
#>  1     1 Female  20.0
#>  2     1 Male    18.0
#>  3     2 Female  22.5
#>  4     2 Male    20.4
#>  5     3 Female  25.0
#>  6     3 Male    22.8
#>  7     4 Female  27.5
#>  8     4 Male    25.2
#>  9     5 Female  30.0
#> 10     5 Male    27.6
#> # ℹ 40 more rows

## calculations based on 'qx'
west_lifetab |>
  lifeexp(qx = qx,
          sex = sex,
          by = level)
#> # A tibble: 50 × 3
#>    level sex       ex
#>    <int> <chr>  <dbl>
#>  1     1 Female  20.1
#>  2     1 Male    18.1
#>  3     2 Female  22.5
#>  4     2 Male    20.5
#>  5     3 Female  25.0
#>  6     3 Male    22.9
#>  7     4 Female  27.5
#>  8     4 Male    25.3
#>  9     5 Female  30.0
#> 10     5 Male    27.7
#> # ℹ 40 more rows

## life expectancy at age 60
west_lifetab |>
  filter(level == 10) |>
  lifeexp(mx = mx,
          at = 60,
          sex = sex)
#> # A tibble: 2 × 2
#>   sex       ex
#>   <chr>  <dbl>
#> 1 Female  13.5
#> 2 Male    12.3