lifetab {poputils}R Documentation

Calculate Life Tables or Life Expectancies

Description

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,
  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.

Value

A tibble.

Definitions of life table quantities

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:

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

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)

## 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")

## 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)

## obtain the same result using
## 'group_by'
west_lifetab |>
  group_by(level) |>
  lifeexp(mx = mx,
          sex = sex,
          infant = "CD",
          child = "CD")

## calculations based on 'qx'
west_lifetab |>
  lifeexp(qx = qx,
          sex = sex,
          by = level)

[Package poputils version 0.3.1 Index]