CalcLifeTable {paramDemo}R Documentation

Calculating a Life Table from Data.

Description

CalcLifeTable uses non-parametric methods to calculate life tables and confidence intervals.

Usage

CalcLifeTable(ageLast, ageFirst = NULL, departType, dx = 1, 
                          calcCIs = FALSE, nboot = 1000, alpha = 0.05)

Arguments

ageLast

Numerical vector with the ages at last detection (i.e., death and censoring) (see details)

ageFirst

Numerical vector of ages at first detection (i.e., truncation). If NULL then all values are set to 0 (see details).

departType

Character string vector for the type of departure (i.e., last detection), with values “D” for death and “C” for censoring (see details).

dx

Age interval size, default set at 1 (see details)

calcCIs

Logical indicating whether confidence intervals should be calculated

nboot

Number of bootstrap iterations

alpha

Alpha level. Default is 0.05 for 95% CIs

Details

1) Data structure:

CalcLifeTable allows to construct life tables for data that includes the following types of records:

The data required are the ages at last detection (i.e., uncensored or right-censored) passed through argument “ageLast”, the type of departure via argument “departType”, which takes two values, namely “D” for death, and “C” for censored (i.e., right-censored).

In addition, if there is left-truncation, it takes the ages at entry to the study by means of argument “ageFirst”. If all the individuals were born during the study, the value of “ageFirst” can be left as NULL, which will make them all equal to 0.

2) Computing life tables

To calculate life tables, the function uses conventional formal demgraphic methods as depicted by Preston et al. (2001). Argument “ageLast” provides a vector of ages at last detection, \bold{x}^{\top} = [x_1, x_2, \dots, x_n], while argument “ageFirst” provides a vector of ages at first detection \bold{y}^{\top} = [y_1, y_2, \dots, y_n]. From argument “departType” the function produces an indicator vector for censoring \bold{v} = \{v_i\}_{i \in \mathbb{N}_n} where v_i = 1 if individual i is censored and 0 otherwise.

The function creates a partition of the interval of ages between 0 and \max(x), for age intervals [x, x + \Delta x) where \Delta x is specified by argument “dx”. As default dx = 1. At each age interval, the function calculates the following variables:

3) Calculating confidence intervals If argument “calcCIs” is set to TRUE, the function uses a non-parametric bootstrap by sampling with replacement the data. Argument nboot specifies the number of bootstrap steps, with default nboot = 2000. From each re-sampled dataset, it uses function CalcLifeTable to construct the corresponding life table and stores the values of $l_x$, $q_x$, $p_x$, and $e_x$ from each iteration. From these, it calculates quantiles at the given alpha level.

Value

CalcLifeTable returns an object of class “paramDemoLT” with output consisting of a list with the life table and, if indicated by the user, with the confidence interval information. The life table in matrix format includes the following columns:

Ages

Ages with increments given by dx

Nx

Number of individuals entering the interval, does not need to be an integer since it considers truncation

Dx

Number of individuals that died within the age interval

lx

Survival (i.e., cumulative survival)

px

Age-specific survival probability

qx

Age-specific mortality probability

Lx

Number of individual years lived within the interval

Tx

Number of individual years lived after age x

ex

Remaining life expectancy at each age

If argument calcCIs = TRUE, the function also returns a list containing the following components:

lx

Matrix with Ages and mean and upper and lower CIs for the life table survival

qx

Matrix with Ages and mean and upper and lower CIs for the age-specific mortality probability

px

Matrix with Ages and mean and upper and lower CIs for the age-specific survival probability

ex

Matrix with Ages and mean and upper and lower CIs for the remaining life expectancy

Settings

Numerical vector including whether CIs were calculated, the number of bootstrap iterations, “nboot” and the alpha level “alpha

Author(s)

Fernando Colchero fernando_colchero@eva.mpg.de

References

Preston, S.H., Heuveline, P. and Guillot, M. (2001) Demography: Measuring and Modeling Population Processes. Blackwell, Oxford.

See Also

CalcProductLimitEst to calculate product limit estimators.

Examples

# Simulate age at death data from Gompertz model:
ages <- SampleRandAge(n = 100, theta = c(b0 = -5, b1 = 0.1))

# Calculate life table:
lt <- CalcLifeTable(ageLast = ages, departType = rep("D", 100))

# Calculate life table with 95% CIs:
ltCIs <- CalcLifeTable(ageLast = ages, departType = rep("D", 100), 
                       calcCIs = TRUE, nboot = 100)


[Package paramDemo version 1.0.1 Index]