Calculate survivorship ratios to be used in projecting
populations forward in time with ccmpp()
. The survivorship ratios
represent the proportion of people in one age group that will survive into
the next age group given the age-specific mortality rates in a life table.
nSx_from_lx_nLx_Tx(dt, id_cols, terminal_age)
[data.table()
]
Input data that includes columns for id_cols
, 'lx', 'nLx' and 'Tx'.
[character()
]
Columns that uniquely identify each row
of dt
. Must include 'age_start' and 'age_end'.
[integer(1)
]
The terminal age group in the population that the calculated survivorship
ratios will be used to project in. This must be less than or equal to the
maximum 'age_start' in dt
.
[data.table()
] with the id_cols
plus a column for 'nSx' with the
survivorship ratio value.
See the references page for the formatted equations below.
First age group: $${}_{n}S_0 = \frac{{}_{n}L_{0}}{n \cdot l_0}$$
Other age groups: $${}_{n}S_x = \frac{{}_{n}L_{x}}{{}_{n}L_{x-n}}$$
Terminal age group: $${}_{n}S_x = \frac{T_{x}}{T_{x-n}}$$
Other survivorship_ratio:
gen_lx_from_nLx_ax()
,
gen_nLx_from_nSx()
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),
mx = c(0.1, 0.2, 0.3, 0.4),
ax = c(2.5, 2.5, 2.5, 2.5)
)
lifetable(dt, id_cols)
#> sex age_start age_end age_length mx ax qx px
#> <char> <num> <num> <num> <num> <num> <num> <num>
#> 1: both 0 5 5 0.1 2.5 0.4000000 0.6000000
#> 2: both 5 10 5 0.2 2.5 0.6666667 0.3333333
#> 3: both 10 15 5 0.3 2.5 0.8571429 0.1428571
#> 4: both 15 Inf Inf 0.4 2.5 1.0000000 0.0000000
#> lx dx nLx Tx ex
#> <num> <num> <num> <num> <num>
#> 1: 1.00000000 0.40000000 4.00000000 6.64285714 6.642857
#> 2: 0.60000000 0.40000000 2.00000000 2.64285714 4.404762
#> 3: 0.20000000 0.17142857 0.57142857 0.64285714 3.214286
#> 4: 0.02857143 0.02857143 0.07142857 0.07142857 2.500000
nSx <- nSx_from_lx_nLx_Tx(dt, id_cols, terminal_age = 15)