gen_u5_ax_from_qx: Generate ax for ages under 5 years, from qx

View source: R/gen_u5_ax.R

gen_u5_ax_from_qxR Documentation

Generate ax for ages under 5 years, from qx

Description

Add ax onto a data.table for ages <1 and 1-4 years, with algorithm based on under-1 qx.

Usage

gen_u5_ax_from_qx(dt, id_cols)

Arguments

dt

[data.table()]
Columns:

  • 'age_start' with values 0 (for under-1) and 1 (for 1-4). Other ages permitted but will result in NA output for ax or unchanged ax if ax in input dt.

  • 'age_end' with values 1 (for under-1) and 5 (for 1-4).

  • 'sex' where values must be 'male', 'female', or 'both'

  • 'qx' for mortality rate

  • All additional columns from 'id_cols'

id_cols

[character()]
Columns that uniquely identify observations in dt. Must include 'age_start', 'age_end', and 'sex'.

Details

Takes a data.table with 'age_start', 'age_end', 'sex', and infant probability of death ('qx') and adds a column 'ax'. There is no absolute relationship between ax and qx without mx also known. Instead, this function performs an inverse calculation of the calculation described for gen_u5_ax_from_mx() which estimates ax from 1m0. Since the inverse involves a quadratic, we use stats::uniroot() to find the solution.

Value

Modifies dt in place with 'ax' column added on.

References

Preston Samuel H, Patrick H, Michel G. Demography: measuring and modeling population processes. MA: Blackwell Publishing. 2001.

See Also

gen_u5_ax_from_mx()

Examples

dt <- data.table::data.table(
  age_start = c(0, 1),
  age_end = c(1, 5),
  qx = c(0.0846, 0.3658),
  sex = c("male", "male")
)
gen_u5_ax_from_qx(dt, id_cols = c("age_start", "age_end", "sex"))

ihmeuw-demographics/demCore documentation built on Feb. 24, 2024, 11:05 p.m.