lt_abridged: Calculate an abridged-age lifetable.

View source: R/lt_abridged.R

lt_abridgedR Documentation

Calculate an abridged-age lifetable.

Description

Given vectors for Deaths and Exposures, or Mx, or qx, or lx, calculate a full abridged lifetable.

Usage

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,
  ...
)

Arguments

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 inferAgeIntAbr(Age = Age).

radix

numeric. Lifetable radix, l0. Default 100000.

axmethod

character. Either "pas" or "un".

a0rule

character. Either "ak" (default) or "cd".

Sex

character. Either male "m", female "f", or both "b".

IMR

numeric. Infant mortality rate q0, in case available and nqx is not specified. Default NA.

region

character. North, East, South, or West: "n", "e", "s", "w". Default "w".

mod

logical. If "un" specified for axmethod, whether or not to use Nan Li's modification for ages 5-14. Default TRUE.

SRB

the sex ratio at birth (boys / girls), default 1.05

OAG

logical. Whether or not the last element of nMx (or nqx or lx) is an open age group. Default TRUE.

OAnew

integer. Desired open age group (5-year ages only). Default max(Age). If higher then rates are extrapolated.

extrapLaw

character. If extrapolating, which parametric mortality law should be invoked? Options include "Kannisto", "Kannisto_Makeham", "Makeham", "Gompertz", "GGompertz", "Beard", "Beard_Makeham", "Quadratic". Default "Kannisto" if the highest age is at least 90, otherwise "makeham". See details.

extrapFrom

integer. Age from which to impute extrapolated mortality.

extrapFit

integer vector. Ages to include in model fitting. Defaults to all ages > =60.

...

Other arguments to be passed on to the MortalityLaw function.

Details

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.

Value

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.

References

\insertRef

greville1977shortDemoTools \insertRefun1982modelDemoTools \insertRefarriaga1994populationDemoTools \insertRefmortpak1988DemoTools \insertRefPASDemoTools

Examples

# 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")

timriffe/DemoTools documentation built on Oct. 14, 2024, 12:53 p.m.