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

gen_u5_ax_from_mx(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'

  • 'mx' 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'.

Value

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

Details

Takes a data.table with 'age_start', 'age_end', 'sex', and infant mortality rate ('mx') and adds a column 'ax'.

The following table shows the conversions from 1m0 to 1a0 and 4a1. Note that when sex is "both" the relationship is a mean of the male and female relationships.

MalesFemales
1a0:
If 1m0 >= 0.1070.3300.350
If 1m0 < 0.1070.045 + 2.684 * 1m00.053 + 2.800 * 1m0
4a1:
If 1m0 >= 0.1071.3521.361
If 1m0 < 0.1071.651 - 2.816 * 1m01.522 - 1.518 * 1m0

References

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

Examples

dt <- data.table::data.table(
  age_start = c(0, 1),
  age_end = c(1, 5),
  mx = c(0.09, 0.12),
  sex = c("male", "male")
)
gen_u5_ax_from_mx(dt, id_cols = c("age_start", "age_end", "sex"))
#> Indices: <age_end__age_start>, <age_end__age_start__sex>
#>    age_start age_end    mx    sex      ax
#>        <num>   <num> <num> <char>   <num>
#> 1:         0       1  0.09   male 0.28656
#> 2:         1       5  0.12   male 1.39756