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 |
ageFirst |
Numerical vector of ages at first detection (i.e., truncation). If |
departType |
Character string vector for the type of departure (i.e., last detection), with values “ |
dx |
Age interval size, default set at 1 (see |
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:
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 byN_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 beforex
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 asq_x = D_x / N_x
. -
px
: the age-specific survival probability, given byp_x = 1 - q_x
. -
lx
: the life table survival calculated asl_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 bya_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 byL_x = l_x (1 - a_x q_x)
-
Tx
: The total number of individual years lived after agex
, given byT_x = \sum_{j = x}^{\infty} L_j \Delta x
-
ex
: the remaining life expectancy at the beginning of each age interval, calculated ase_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.
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 |
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, “ |
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)