lt_abridged | R Documentation |
Given vectors for Deaths and Exposures, or Mx, or qx, or lx, calculate a full abridged lifetable.
lt_abridged(
Deaths = NULL,
Exposures = NULL,
nMx = NULL,
nqx = NULL,
lx = NULL,
Age,
AgeInt = age2int(Age = Age, OAvalue = 5),
radix = 1e+05,
axmethod = "pas",
a0rule = "ak",
Sex = "m",
IMR = NA,
region = "w",
mod = TRUE,
SRB = 1.05,
OAG = TRUE,
OAnew = max(Age),
extrapLaw = NULL,
extrapFrom = max(Age),
extrapFit = NULL,
...
)
Deaths |
numeric. Vector of death counts in abridged age classes. |
Exposures |
numeric. Vector of population exposures in abridged age classes. |
nMx |
numeric. Vector of mortality rates in abridged age classes. |
nqx |
numeric. Vector of conditional death probabilities in abridged age classes. |
lx |
numeric. Vector of lifetable survivorship at abridged ages. |
Age |
integer. A vector of ages of the lower integer bound of the age classes. |
AgeInt |
integer. Vector of age class widths. Default |
radix |
numeric. Lifetable radix, l0. Default 100000. |
axmethod |
character. Either |
a0rule |
character. Either |
Sex |
character. Either male |
IMR |
numeric. Infant mortality rate q0, in case available and |
region |
character. North, East, South, or West: |
mod |
logical. If |
SRB |
the sex ratio at birth (boys / girls), default 1.05 |
OAG |
logical. Whether or not the last element of |
OAnew |
integer. Desired open age group (5-year ages only). Default |
extrapLaw |
character. If extrapolating, which parametric mortality law should be invoked? Options include
|
extrapFrom |
integer. Age from which to impute extrapolated mortality. |
extrapFit |
integer vector. Ages to include in model fitting. Defaults to all ages |
... |
Other arguments to be passed on to the
|
The main variations here are in the treatment of nAx
.
In all cases, the lifetable is extended and closed out using one from a
selection of mortality age extrapolation methods implemented in the
MortalityLaws
package rather than the common practice of taking
the inverse of the final nMx
value (if it's an open interval).
For this, a desired open age must be specified, defaulting to the present
open age group, but which can not exceed 110 in the present implementation.
By default, the extrapolation model is fit to ages 60 and higher, but you
can control this using the extrapFit
argument (give the vector of ages,
which must be a subset of Age
). By default extrapolated values are used
starting with the input open age, but you can lower this age using the
extrapFrom
argument. The Sx
output column (survivor ratios)
is aligned with the other columns in all 5-year age groups, but note the
first two values have a slightly different age-interval interpretation:
In Age 0, the interpretation is survival from birth until interval 0-4.
In Age 1, it is survival from 0-4 into 5-9. Thereafter the age groups align.
This column is required for population projections.
Lifetable in data.frame with columns
Age integer. Lower bound of abridged age class
AgeInt integer. Age class widths.
nMx numeric. Age-specific central death rates.
nAx numeric. Average time spent in interval by those deceased in interval.
nqx numeric. Age-specific conditional death probabilities.
lx numeric. Lifetable survivorship
ndx numeric. Lifetable deaths distribution.
nLx numeric. Lifetable exposure.
Sx numeric. Survivor ratios in uniform 5-year age groups.
Tx numeric. Lifetable total years left to live above age x.
ex numeric. Age-specific remaining life expectancy.
greville1977shortDemoTools \insertRefun1982modelDemoTools \insertRefarriaga1994populationDemoTools \insertRefmortpak1988DemoTools \insertRefPASDemoTools
# trial code from PAS LTPOPDTH, North, Males, IMR = .1
Exposures <- c(100958,466275,624134,559559,446736,370653,301862,249409,
247473,223014,172260,149338,127242,105715,79614,53660,
31021,16805,8000,4000,2000,1000)
Deaths <- c(8674,1592,618,411,755,1098,1100,1357,
1335,3257,2200,4023,2167,4578,2956,4212,
2887,2351,1500,900,500,300)
# lower age bounds
Age <- c(0, 1, seq(5, 100, by = 5))
AgeInt <- c(diff(Age), NA)
PASLT <- lt_abridged(Deaths = Deaths,
Exposures = Exposures,
Age = Age,
AgeInt =AgeInt,
axmethod = "pas",
IMR = .1,
region = "n",
Sex = "m",
a0rule ="cd")
# examples based on UN 1982 (p. 34)
Mx <- c(.23669,.04672,.00982,.00511,.00697,.01036,.01169,
.01332,.01528,.01757,.02092,.02517,.03225,.04241,.06056,
.08574,.11840,.16226,.23745)
excheckUN <- c(35.000,42.901,47.190,44.438,
40.523,36.868,33.691,30.567,27.500,24.485,21.504,18.599,
15.758,13.080,10.584,8.466,6.729,5.312,4.211)
AgeInt <- inferAgeIntAbr(vec = Mx)
# generate two variants: with and without PG's variants
# for ages 5-14
UNLT1 <- lt_abridged(nMx = Mx,
Age = c(0,1,seq(5,85,by=5)),
AgeInt = AgeInt,
axmethod = "un",
Sex = "m",
mod = FALSE)
UNLT2 <- lt_abridged(nMx = Mx,
Age = c(0,1,seq(5,85,by=5)),
AgeInt = AgeInt,
axmethod = "un",
Sex = "m",
mod = TRUE)
# \dontrun{
# plot(UNLT2$ex - UNLT1$ex)
# }
# a Mortpak unit test:
# data from p. 82 United Nations (1988) Mortpak - ...
MPnMx <- c(0.12846,0.02477,0.00603,0.0034,
0.00417,0.00513,0.00581,0.00645,0.00725,
0.00813,0.00913,0.01199,0.01647,
0.0256,0.04047,0.06624,0.10638,0.19611)
Age <- c(0,1,seq(5,80,by=5))
AgeInt <- age2int(Age,OAvalue = 5)
MPexcheck <- c(49.997,55.675,57.245,53.921,
49.803,45.799,41.922,38.084,34.249,
30.420,26.578,22.701,18.945,
15.349,12.095,9.240,6.903,5.099)
# First with lifetable extention to 100
MP_UNLT100 <- lt_abridged(
nMx = MPnMx,
Age = Age,
AgeInt = AgeInt,
axmethod = "un",
Sex = "f",
mod = FALSE,
OAnew = 100,
a0rule ="cd")
#'
#' # lifetable to original open age group
MP_UNLT80 <- lt_abridged(
nMx = MPnMx,
Age = Age,
AgeInt = AgeInt,
axmethod = "un",
Sex = "f",
mod = FALSE,
OAnew = 80,
a0rule ="cd")
# same, but truncated at 60
MP_UNLT60 <- lt_abridged(
nMx = MPnMx,
Age = Age,
AgeInt = AgeInt,
axmethod = "un",
Sex = "f",
mod = FALSE,
OAnew = 60,
a0rule ="cd")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.