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: $${}_{n}S_0 = \frac{{}_{n}L_{0}}{n \cdot l_0}$$ $${}_{n}L_{0} = {}_{n}S_0 \cdot n \cdot l_0$$

Other age groups: $${}_{n}S_x = \frac{{}_{n}L_{x}}{{}_{n}L_{x-n}}$$ $${}_{n}L_{x} = {}_{n}S_x \cdot {{}_{n}L_{x-n}}$$

Terminal age group: $${}_{n}S_x = \frac{T_{x}}{T_{x-n}} = \frac{{}_{\infty}L_{x}}{{}_{\infty}L_{x} + {}_{n}L_{x - n}}$$ $${}_{\infty}L_{x} = \frac{{}_{n}S_x \cdot {}_{n}L_{x - n}}{1 - {}_{n}S_x}$$

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)