Learn R Programming

MortalityLaws (version 2.2.0)

LifeTable: Compute Life Tables from Mortality Data

Description

Construct either a full (single-year age intervals) or an abridged (wider age intervals) life table from a variety of input data types. The function accepts:

  • Death counts and mid-interval population estimates (Dx, Ex)

  • Age-specific death rates (mx)

  • Death probabilities (qx)

  • Survivorship curve (lx)

  • Distribution of deaths (dx)

Only one of these input options needs to be provided; the others are ignored if present. The input can be a numeric vector, matrix, or data.frame. When a matrix or data.frame with multiple columns is supplied, the function computes one life table per column.

Usage

LifeTable(x, Dx = NULL, Ex = NULL,
             mx = NULL,
             qx = NULL,
             lx = NULL,
             dx = NULL,
             sex = NULL,
             lx0 = 1e5,
             ax  = NULL)

Value

An object of class "LifeTable" containing the following components:

lt

A data.frame with the complete life table, including columns for age interval (x.int), exact age (x), death rate (mx), death probability (qx), person-years lived by decedents (ax), survivorship (lx), death distribution (dx), person-years lived (Lx), total person-years remaining (Tx), and life expectancy (ex).

call

The matched function call.

process_date

Timestamp of when the life table was computed.

Arguments

x

Numeric vector of ages at the beginning of each age interval. For a full life table, use single-year ages (e.g., 0:110). For an abridged life table, use the lower bound of each interval (e.g., c(0, 1, 5, 10, ..., 110)).

Dx

Death counts. Each element represents the total number of deaths during the calendar year to persons aged x to x + n (where n is the length of the age interval). Must be provided together with Ex.

Ex

Exposure-to-risk in the period. This is usually approximated by the mid-year population aged x to x + n. Must be provided together with Dx.

mx

Age-specific death rate in the age interval [x, x+n). Defined as Dx / Ex.

qx

Probability of dying within the age interval [x, x+n).

lx

Probability of surviving to exact age x (if lx0 = 1), or the number of survivors at exact age x (if lx0 > 1). When lx is the sole input, the values are re-scaled to the chosen radix lx0.

dx

Number of deaths in the life-table population occurring in the age interval [x, x+n). When dx is the sole input, the values are re-scaled to sum to lx0.

sex

Sex of the population. Options are NULL (default), "male", "female", or "total". When specified, the first two entries of the ax column are adjusted using Coale-Demeny coefficients, producing more accurate life-table values at the youngest ages. The adjustment differs slightly between males and females.

lx0

Radix, the starting population (or probability scale) at age 0. Default is 100,000. All subsequent life-table columns (lx, dx, Lx, Tx) are scaled accordingly.

ax

Numeric vector representing the average number of person-years lived in the age interval by those who die in that interval. If NULL (the default), ax is estimated internally using a standard formula. You may supply a single value (applied to all intervals) or a vector of the same length as x. A common assumption is ax = 0.5, which places deaths at the midpoint of each interval.

Author

Marius D. Pascariu

Details

A life table (also called a mortality table or actuarial table) summarises the mortality experience of a population. For each age (or age interval) it reports:

  • Death rates (mx) and death probabilities (qx)

  • Survivorship (lx)

  • Distribution of deaths (dx)

  • Person-years lived (Lx) and total person-years remaining (Tx)

  • Life expectancy (ex)

The life table is constructed sequentially: from the input data the function derives mx, then qx, then lx, dx, Lx, Tx, and finally ex. The constant-force-of-mortality (CFM) assumption is used to convert between mx and qx. If the sex argument is supplied, the first two values of the ax column are adjusted using the Coale-Demeny method, which accounts for the different infant mortality patterns between males and females.

See Also

LawTable for generating life tables from a fitted parametric mortality law; convertFx for converting between mortality measures.

Examples

Run this code
# Example 1 --- Full life tables with different inputs ------------

y  <- 1900
x  <- as.numeric(rownames(ahmd$mx))
Dx <- ahmd$Dx[, paste(y)]
Ex <- ahmd$Ex[, paste(y)]

LT1 <- LifeTable(x, Dx = Dx, Ex = Ex)
LT2 <- LifeTable(x, mx = LT1$lt$mx)
LT3 <- LifeTable(x, qx = LT1$lt$qx)
LT4 <- LifeTable(x, lx = LT1$lt$lx)
LT5 <- LifeTable(x, dx = LT1$lt$dx)

LT1
LT5
ls(LT5)

# Example 2 --- Compute multiple life tables at once ------------

LTs <- LifeTable(x, mx = ahmd$mx)
LTs
# A warning is printed if the input contains missing values.
# Some of the missing values can be handled automatically.

# Example 3 --- Abridged life table -----------------------------

x  <- c(0, 1, seq(5, 110, by = 5))
mx <- c(.053, .005, .001, .0012, .0018, .002, .003, .004,
        .004, .005, .006, .0093, .0129, .019, .031, .049,
        .084, .129, .180, .2354, .3085, .390, .478, .551)
LT6 <- LifeTable(x, mx = mx, sex = "female")
LT6

# Example 4 --- Abridged life table using a custom 'ax' --------
# This example reuses the ages (x) and death rates (mx) from Example 3.
# Note that 'ax' must have the same length as 'x', otherwise an error
# will be returned.

my_ax <- c(0.1, 1.5, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
           2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1)

LT7 <- LifeTable(x = x, mx = mx, ax = my_ax)

Run the code above in your browser using DataLab