R/abridged_life_tables.R
build_abridged_life_tables.RdConstructs female, male, and both-sex abridged (5-year age group)
period life tables for every province and year present in mx_5x1,
from compute_death_rates()'s mx_1x1/mx_5x1 output. See
build_abridged_life_table() for the method; build_life_tables()
for the single-year (1x1) equivalent this complements.
build_abridged_life_tables(mx_1x1, mx_5x1)Output of the mx_1x1 element of compute_death_rates().
Output of the mx_5x1 element of compute_death_rates().
list(fltper, mltper, bltper, qc): each a tibble with
nuts3_code, province_name, year, age_group, age_start,
n, mx, ax, qx, lx, dx, Lx, Tx, ex; qc is a named
list of validate_abridged_life_table() results.
mx_1x1 <- tibble::tibble(
nuts3_code = "ES111", province_name = "A Coruna", year = 2023,
age = 0:4, mx_female = c(0.004, 0.0003, 0.0002, 0.0002, 0.0002),
mx_male = c(0.005, 0.0004, 0.0003, 0.0003, 0.0003),
mx_total = c(0.0045, 0.00035, 0.00025, 0.00025, 0.00025)
)
start <- seq(0, 100, by = 5)
mx_female <- c(0.0011, 0.00004 * exp(0.095 * start[-1]))
mx_5x1 <- tibble::tibble(
nuts3_code = "ES111", province_name = "A Coruna", year = 2023,
age_group = c(sprintf("%02d-%02d", start[-21], start[-21] + 4), "100+"),
mx_female = mx_female, mx_male = 1.4 * mx_female, mx_total = 1.2 * mx_female
)
alt <- build_abridged_life_tables(mx_1x1, mx_5x1)
#> All abridged life tables passed validation.
alt$fltper
#> # A tibble: 21 × 14
#> nuts3_code province_name age_group age_start n mx ax qx
#> <chr> <chr> <chr> <int> <int> <dbl> <dbl> <dbl>
#> 1 ES111 A Coruna 00-04 0 5 0.0011 0.635 0.00488
#> 2 ES111 A Coruna 05-09 5 5 0.0000643 2.01 0.000322
#> 3 ES111 A Coruna 10-14 10 5 0.000103 2.70 0.000517
#> 4 ES111 A Coruna 15-19 15 5 0.000166 2.70 0.000831
#> 5 ES111 A Coruna 20-24 20 5 0.000267 2.70 0.00134
#> 6 ES111 A Coruna 25-29 25 5 0.000430 2.70 0.00215
#> 7 ES111 A Coruna 30-34 30 5 0.000692 2.70 0.00345
#> 8 ES111 A Coruna 35-39 35 5 0.00111 2.70 0.00555
#> 9 ES111 A Coruna 40-44 40 5 0.00179 2.69 0.00890
#> 10 ES111 A Coruna 45-49 45 5 0.00288 2.69 0.0143
#> # ℹ 11 more rows
#> # ℹ 6 more variables: lx <dbl>, dx <dbl>, Lx <dbl>, Tx <dbl>, ex <dbl>,
#> # year <dbl>