Given a data.table
with at least two of variables mx, ax, and
qx, compute a complete life table. This is a helper function that combines
many other functions in this package to calculate px, lx, dx, Tx, nLx,
and ex.
lifetable(
dt,
id_cols,
preserve_u5 = FALSE,
assert_na = TRUE,
format_long = FALSE
)
[data.table()
]
Input life tables. Must include 2/3 of 'qx', 'mx', and 'ax', in addition
to all id_cols
.
[character()
]
Columns that uniquely identify each row of dt
. Must include 'age_start'
and 'age_end'.
[logical()
]
Whether to preserve under-5 qx estimates rather than recalculating them
based on mx and ax.
[logical()
]
Whether to assert that there is no
missingness.
[logical(1)
]
Whether to format output with a 'life_table_parameter' column and a column
for each summary statistic (rather than a column for each
'life_table_parameter' and summary statistic pair).
[data.table()
]
Input life table(s) with additional columns: px, lx, dx, Tx, nLx, ex.
Or, if format_long
is TRUE, additional columns 'life_table_parameter'
and 'value' with data long on life table parameter.
Note that while it typically takes estimation techniques to arrive at mx, ax, and qx from empirical data, the solution of the remaining life table parameters as compiled in this function is deterministic once mx, ax, and qx are specified. The steps of this solution are as follows:
Calculate mx, ax, or qx if one of the three is missing
Recalculate qx if all three of mx, ax, and qx are provided to confirm
the three agree. See mx_qx_ax_conversions
functions. Will not recalculate
under-5 qx if preserve_u5
is true.
Compute px from qx
Replace terminal (age_end = Inf) ax with terminal ex