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, , while argument “
ageFirst
” provides a vector of ages at first detection . From argument “
departType
” the function produces an indicator vector for censoring where
if individual
is censored and 0 otherwise.
The function creates a partition of the interval of ages between 0 and , for age intervals
where
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 bywhere
is the subset of individuals recorded within the interval, and
is the proportion of time during the age interval each individual was present in the study. For individuals that entered the study before
then
, while for those that were truncated within the interval
.
-
Dx
: the number of individuals dying in the interval. -
qx
: the age-specific mortality probability, calculated as.
-
px
: the age-specific survival probability, given by.
-
lx
: the life table survival calculated aswhere
.
-
ax
: Proportion of the interval lived by those that died in the interval, given bywhere
is the subset of individuals that died within the interval, and
is the proportion lived by those individuals from the start of the interval to their deaths, this is
.
-
Lx
: The number of individual years lived within the interval, given by -
Tx
: The total number of individual years lived after age, given by
-
ex
: the remaining life expectancy at the beginning of each age interval, calculated as.
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)