Package 'shapleyHALE'

Title: Shapley Value Decomposition of Health-Adjusted Life Expectancy
Description: Implements a Shapley-value framework to decompose changes in health-adjusted life expectancy (HALE) into additive contributions of individual diseases or causes, fully accounting for higher-order interactions. Separates mortality and disability effects and provides second-order Shapley interaction indices. Uncertainty is propagated via parametric bootstrap.
Authors: Jun-Yan Xi [aut, cre] (ORCID: <https://orcid.org/0000-0001-7473-7783>, affiliation: Sun Yat-sen University)
Maintainer: Jun-Yan Xi <[email protected]>
License: MIT + file LICENSE
Version: 0.1.0
Built: 2026-09-28 12:37:06 UTC
Source: https://github.com/cran/shapleyHALE

Help Index


Example age group information

Description

Matches the age groups in demo_gbd.

Usage

age_info_demo

Format

A data.table with columns:

age_id

numeric age group ID

age_start

start of interval

width

interval width (years)


Parametric bootstrap Shapley decomposition

Description

Performs bootstrap uncertainty analysis by sampling rates from triangular distributions defined by point estimates and 95

Usage

bootstrap_shapley(
  deaths_data,
  ylds_data,
  base_year,
  target_year,
  cause_ids,
  age_ids,
  ages_info,
  n_boot = 1000,
  n_perm_inner = 5000,
  parallel = FALSE,
  n_cores = NULL
)

Arguments

deaths_data

data.table with mortality rates (cols: year, cause_id, age_id, val, lower, upper)

ylds_data

data.table with YLD rates (same structure)

base_year

baseline year

target_year

target year

cause_ids

character vector of cause IDs

age_ids

numeric vector of age IDs in correct order

ages_info

data.frame with age_start and width, matching age_ids

n_boot

number of bootstrap iterations (default 1000)

n_perm_inner

number of Shapley permutations per bootstrap (default 5000)

parallel

logical, use parallel processing?

n_cores

number of cores (NULL = detectCores()-1)

Value

list containing point estimates and bootstrap summaries


Compute health-adjusted life expectancy

Description

Sullivan method combining mortality and YLD rates.

Usage

compute_hale(mx, yld_rate, ages)

Arguments

mx

numeric vector of age-specific mortality rates (per person-year)

yld_rate

numeric vector of YLD rates (per person-year)

ages

data.frame with columns 'age_start' and 'width'

Value

list containing HALE0 and LE0

Examples

ages <- data.frame(age_start = c(0,1,5), width = c(1,4,5))
compute_hale(c(0.01,0.02,0.05), c(0.1,0.1,0.1), ages)

Second-order Shapley interaction indices

Description

Quantifies pairwise synergies/antagonisms among the leading causes.

Usage

compute_shapley_interactions(
  base_mx,
  base_yld,
  target_mx,
  target_yld,
  causes,
  ages,
  top_n = 20,
  n_perm = 1000,
  point_est = NULL
)

Arguments

base_mx

matrix, baseline mortality rates

base_yld

matrix, baseline YLD rates

target_mx

matrix, target mortality rates

target_yld

matrix, target YLD rates

causes

character vector of all cause IDs

ages

data.frame with age_start and width

top_n

number of leading causes to consider (default 20)

n_perm

number of permutations (default 1000)

point_est

optional named vector of total Shapley values (for ranking)

Value

data.table with columns cause_A, cause_B, interaction


Create cause-rate matrix from GBD-style data.table

Description

Create cause-rate matrix from GBD-style data.table

Usage

create_rate_matrix(data, year_val, cause_ids, age_ids)

Arguments

data

data.table with columns year, cause_id, age_id, val

year_val

numeric year

cause_ids

character vector of cause IDs

age_ids

numeric vector of age IDs in correct order

Value

matrix (ages x causes)


Demo GBD rates (simulated)

Description

A small simulated dataset mimicking GBD cause-specific mortality and YLD rates.

Usage

demo_gbd

Format

A data.table with columns:

measure_id

1 = mortality, 3 = YLD

sex_id

3 = both sexes

year

1990 or 2023

cause_id

character cause identifier

cause_name

cause name

age_id

numeric age group ID

val

point estimate (rate)

upper

upper 95% UI

lower

lower 95% UI

Source

Simulated for package examples.


Shapley decomposition of HALE change

Description

Decomposes the HALE change between baseline and target into additive contributions of individual causes, separating mortality and disability effects.

Usage

run_shapley_decomp(
  base_mx,
  base_yld,
  target_mx,
  target_yld,
  causes = NULL,
  ages,
  n_perm = 5000
)

Arguments

base_mx

matrix of baseline mortality rates (age x cause)

base_yld

matrix of baseline YLD rates (age x cause)

target_mx

matrix of target mortality rates

target_yld

matrix of target YLD rates

causes

character vector of cause IDs (column names)

ages

data.frame with 'age_start' and 'width'

n_perm

number of random permutations (default 5000)

Value

list with total_change, total_effect, death_effect, disability_effect