Processing math: 100%

Generate the nLx life table parameter given survivorship ratios (nSx).

gen_nLx_from_nSx(dt, id_cols)

Arguments

dt

[data.table()]
Input data that includes columns for id_cols and 'nSx'.

id_cols

[character()]
Columns that uniquely identify each row of dt. Must include 'age_start' and 'age_end'.

Value

dt with column added for new life table parameter. Modifies data.tables in place.

Details

See the references page for the formatted equations below.

First age group: nS0=nL0nl0 nL0=nS0nl0

Other age groups: nSx=nLxnLxn nLx=nSxnLxn

Terminal age group: nSx=TxTxn=LxLx+nLxn Lx=nSxnLxn1nSx

See also

Other survivorship_ratio: gen_lx_from_nLx_ax(), nSx_from_lx_nLx_Tx()

Examples

id_cols <- c("sex", "age_start", "age_end")
dt <- data.table::data.table(
  sex = rep("both", 4),
  age_start = c(0, 5, 10, 15),
  age_end = c(5, 10, 15, Inf),
  nSx = c(0.95, 0.99, 0.99, 0.75)
)
gen_nLx_from_nSx(dt, id_cols)