CalcLifeTable uses non-parametric methods to calculate life tables and confidence intervals.
CalcLifeTable(ageLast, ageFirst = NULL, departType, dx = 1,
calcCIs = FALSE, nboot = 1000, alpha = 0.05)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 with increments given by dx
Number of individuals entering the interval, does not need to be an integer since it considers truncation
Number of individuals that died within the age interval
Survival (i.e., cumulative survival)
Age-specific survival probability
Age-specific mortality probability
Number of individual years lived within the interval
Number of individual years lived after age x
Remaining life expectancy at each age
If argument calcCIs = TRUE, the function also returns a list containing the following components:
Matrix with Ages and mean and upper and lower CIs for the life table survival
Matrix with Ages and mean and upper and lower CIs for the age-specific mortality probability
Matrix with Ages and mean and upper and lower CIs for the age-specific survival probability
Matrix with Ages and mean and upper and lower CIs for the remaining life expectancy
Numerical vector including whether CIs were calculated, the number of bootstrap iterations, “nboot” and the alpha level “alpha”
Numerical vector with the ages at last detection (i.e., death and censoring) (see details)
Numerical vector of ages at first detection (i.e., truncation). If NULL then all values are set to 0 (see details).
Character string vector for the type of departure (i.e., last detection), with values “D” for death and “C” for censoring (see details).
Age interval size, default set at 1 (see details)
Logical indicating whether confidence intervals should be calculated
Number of bootstrap iterations
Alpha level. Default is 0.05 for 95% CIs
Fernando Colchero fernando_colchero@eva.mpg.de
1) Data structure:
CalcLifeTable allows to construct life tables for data that includes the following types of records:
Uncensored: individuals with known ages at death;
right-censored: individuals last seen alive;
left-truncated: individuals born before the start of the study and are truncated at the age of entry.
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:
Nx: which corresponds to number of individuals that entered the interval, but considering the proportion of time they were present within the interval as a function of left-truncation. It is given by
$$
N_x = \sum_{i \in I_x} \lambda_{i,x},
$$
where \(I_x\) is the subset of individuals recorded within the interval, and \(\lambda_{i, x}\) is the proportion of time during the age interval each individual was present in the study. For individuals that entered the study before \(x\) then \(\lambda_{i,x} = 1\), while for those that were truncated within the interval \(\lambda_{i,x} = (x + \Delta x - y_i) / \Delta x\).
Dx: the number of individuals dying in the interval.
qx: the age-specific mortality probability, calculated as \(q_x = D_x / N_x\).
px: the age-specific survival probability, given by \(p_x = 1 - q_x\).
lx: the life table survival calculated as
$$
l_x = \prod_{j = 0}^{x-1} p_j
$$
where \(l_0 = 1\).
ax: Proportion of the interval lived by those that died in the interval, given by
$$
a_x = \frac{\sum_{i\in J_{x}} \delta_{i,x}}{D_x}
$$
where \(J_{x}\) is the subset of individuals that died within the interval, and \(\delta_{i,x}\) is the proportion lived by those individuals from the start of the interval to their deaths, this is \(\delta_{i,x} = (x_i - x) / \Delta x\).
Lx: The number of individual years lived within the interval, given by
$$
L_x = l_x (1 - a_x q_x)
$$
Tx: The total number of individual years lived after age \(x\), given by \(T_x = \sum_{j = x}^{\infty} L_j \Delta x\)
ex: the remaining life expectancy at the beginning of each age interval, calculated as \(e_x = T_x / l_x\).
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.
Preston, S.H., Heuveline, P. and Guillot, M. (2001) Demography: Measuring and Modeling Population Processes. Blackwell, Oxford.
CalcProductLimitEst to calculate product limit estimators.
# 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)
Run the code above in your browser using DataLab