Computes E(x,t) = 1/2[P(x,t) + P(x,t+1)] + 1/6[D_L(x,t) - D_U(x,t)] (HMD Methods Protocol V6, Eq. 57) for every province present in both population and deaths, where D_L and D_U are deaths in the lower (cohort born in t - x) and upper (cohort born in t - x - 1) Lexis triangles.

compute_exposure(population, deaths)

Arguments

population

Output of the data element of get_ine_population().

deaths

Output of the data_provinces element of get_ine_deaths().

Value

list(data, qc): data is a tibble with columns nuts3_code, province_name, year, age, female, male, total (exposure), is_boundary_year, is_missing_source_pop; qc is the output of validate_exposure().

Details

INE's death tables are not classified by birth cohort. Unless deaths carries a cohort column, deaths are split evenly between the two triangles, the correction term is zero, and exposure is the mean of the two January-1 populations. This is an adaptation of the HMD protocol, which splits 1x1 deaths by regression (Appendix A) and corrects for the monthly distribution of births (Appendix E); its effect is quantified in the package's validation study (see reproducibility/).

If P(x,t+1) is unavailable for a year that is kept, exposure falls back to P(x,t) and the row is flagged with is_boundary_year = TRUE.

Death registration lags population estimates by about a year, so population commonly includes a most-recent year (e.g. a Jan-1 stock snapshot) with no corresponding rows anywhere in deaths yet. That year is still used as the P(x,t+1) boundary for computing the previous year's exposure, but is not included in the returned exposure rows itself — treating an entirely-absent year as zero deaths (rather than missing data) would mechanically produce zero mortality for that year, and downstream a nonsensical inflated life expectancy.

Examples

population <- tibble::tibble(
  nuts3_code = "ES111", province_name = "A Coruna",
  year = c(2022, 2023), age = 0,
  female = c(100, 105), male = c(105, 110), total = c(205, 215)
)
deaths <- tibble::tibble(
  nuts3_code = "ES111", province_name = "A Coruna",
  year = c(2022, 2023), age = 0,
  female = c(1, 1), male = c(1, 2), total = c(2, 3)
)
compute_exposure(population, deaths)
#> Warning: No cohort column in `deaths`: splitting deaths evenly between Lexis triangles, so exposure is the mean of the two January-1 populations (the HMD V6 Eq. 57 triangle correction is zero).
#> All exposure validation checks passed.
#> $data
#> # A tibble: 2 × 9
#>   nuts3_code province_name  year   age female  male total is_boundary_year
#>   <chr>      <chr>         <dbl> <dbl>  <dbl> <dbl> <dbl> <lgl>           
#> 1 ES111      A Coruna       2022     0   102.  108.   210 FALSE           
#> 2 ES111      A Coruna       2023     0   105   110    215 TRUE            
#> # ℹ 1 more variable: is_missing_source_pop <lgl>
#> 
#> $qc
#> $qc$passed
#> [1] TRUE
#> 
#> $qc$issues
#> list()
#> 
#>