scale_qx | R Documentation |
Scale granular qx values to be consistent with aggregate age interval qx values already present in the data.
scale_qx(dt, id_cols, missing_dt_severity = "stop")
dt |
[
|
id_cols |
[ |
missing_dt_severity |
[ |
Convert to px-space, scale up age-hierarchy so that granular px
values multiply to aggregate px values, convert back to qx-space.
scale_qx()
is a wrapper for hierarchyUtils::scale()
.
This function is unique to aggregating and scaling qx over age because of
the dependence between age and the definition of qx. Aggregation of qx
across sex, location, or other variables should be done by first aggregating
ax and mx as population-weighted means (can use hierarchyUtils::agg()
and
hierarchyUtils::scale()
directly), then recalculating qx from mx and ax
(see mx_ax_to_qx()
).
[data.table()
]
Scaled qx values, has id_cols
and 'qx'
columns for all age groups.
Vignette on scaling multiplicative aggregates in hierarchyUtils
.
# scale qx up single-year to abridged u5 hierarchy
dt <- data.table::data.table(
sex = "male",
qx = c(0.03, 0.015, 0.005, 0.004, 0.001, 0.03, 0.05),
age_start = c(0, 1, 2, 3, 4, 1, 0),
age_end = c(1, 2, 3, 4, 5, 5, 5)
)
dt <- scale_qx(dt, id_cols = c("sex", "age_start", "age_end"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.