LifeTable: Create a LifeTable object.

Description Usage Arguments Details Value See Also Examples

View source: R/LifeTable-generators.R

Description

Create an object of class LifeTable holding the information necessary to create the full suite of life table functions.

Usage

1
2
3
4
5
6
7
8
9
LifeTable(
  mx,
  ax = NULL,
  showFun = c("mx", "qx", "dx", "lx", "Lx", "ex"),
  radix = 1e+05,
  showQuantiles = TRUE,
  showTotal = FALSE,
  prob = c(0.025, 0.5, 0.975)
)

Arguments

mx

An object of class Values holding estimated mortality rates.

ax

An object of class Values holding estimated separation factors. Optional.

showFun

A character vector with the names of the functions that are printed or plotted by default

radix

A positive number. Defaults to 100,000.

showQuantiles

Logical. If TRUE, the default, quantiles are shown, rather than iterations.

showTotal

Logical. If TRUE, the default, and if there is a dimension with dimtype "sex", then a "total" category is shown, in addition to "female" and "male" cateogies.

prob

Values used to calculate quantiles. Passed to function quantile.

Details

For definitions of the life table functions, see the documentation for lifeTableFun.

mx is a Values object holding estimates of mortality rates, disaggregated by

ax specifies "separation factors", that is, the average amount of time lived during an age interval by people who die during that interval. ax can not include dimensions that object does not. However, object can include dimensions that ax does not. If it does, then values for ax are assumed to be identical across these dimensions. For instance, if object has a "region" dimension, but ax does not, then the same values for ax are used for all regions. See below for examples.

When mx and ax share a dimension, all values for that dimension that appear in mx must also appear in ax–except for the age dimension. If mx includes an age interval that ax does not, then ax for that value is assumed to be half the width of the age interval.

If ax is not supplied, then LifeTable imputes values. The imputed values equal half the length of the corresponding age group, except at ages 0 and 1-4. If mx includes rates for age 0, then LifeTables obtains ax values for ages 0 and 1-4 by applyin the formulas provided by Preston et al (2001: Table 3.3).

The arguments showFun, showQuantiles and prob affect printing, plotting, and as.data.frame, but do not affect the underlying data. This means, for instance, that lifeTableFun can be produce values for life table functions that are not included in showFun.

l0, the first value of lx is conventionally set to 100,000. Alternative values can be supplied via the radix argument. Changing the value of radix also affects the dx, Lx and Tx columns.

Value

An object of class LifeTable.

See Also

lifeTableFun returns values for a life table function. as.data.frame converts a LifeTable object to a (long form) data.frame, typically as a step towards exporting the life table to a .csv file.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
mx <- dembase::ValuesOne(c(0.2, 0.05, 0.1, 0.4),
                labels = c("0", "1-4", "5-9", "10+"),
                name = "age")
LifeTable(mx)
LifeTable(mx, showTotal = TRUE)

al <- demdata::afghan.life
al <- dembase::Values(al)
mx <- dembase::subarray(al,
               subarray = (fun == "mx") & (time == "2001-2005"))
ax <- dembase::subarray(al,
               subarray = (fun == "ax") & (time == "2001-2005"))
LifeTable(mx = mx, ax = ax)

StatisticsNZ/demlife documentation built on April 27, 2021, 10:02 p.m.