| Title: | Provides Easy Methods to Perform Life Expectancy Decomposition |
| Version: | 1.0.0 |
| Description: | Provides an easy to use implementation of life expectancy decomposition formulas for age bands, derived from Ponnapalli, K. (2005). A comparison of different methods for decomposition of changes in expectation of life at birth and differentials in life expectancy at birth. Demographic Research, 12, pp.141–172. <doi:10.4054/demres.2005.12.7> In addition, there is a decomposition function for disease cause breakdown and a couple helpful plot functions. |
| License: | GPL (≥ 3) |
| Depends: | R (≥ 4.1.0) |
| Imports: | dplyr, magrittr, stringr, tidyr, purrr, ggplot2, rlang |
| Encoding: | UTF-8 |
| LazyData: | true |
| RoxygenNote: | 7.3.3 |
| Suggests: | testthat (≥ 3.0.0), tibble, forcats |
| Config/testthat/edition: | 3 |
| URL: | https://github.com/herts-phei/decompositionLE |
| BugReports: | https://github.com/herts-phei/decompositionLE/issues |
| NeedsCompilation: | no |
| Packaged: | 2025-12-02 11:07:31 UTC; vyu |
| Author: | Victor Yu [aut, cre, cph],
Will Yuill |
| Maintainer: | Victor Yu <victor.yu@hertfordshire.gov.uk> |
| Repository: | CRAN |
| Date/Publication: | 2025-12-09 07:40:06 UTC |
Title decomp_age
Description
Function for performing life expectancy decomposition for age bands
Usage
decomp_age(df, method = "arriaga3", age_col, e1, e2, l1, l2, append = TRUE)
Arguments
df |
An outputted life table with columns for age bands, number of persons alive at each age band and expectation of life at each age band |
method |
Methods to use for life expectancy decomposition. Defaults to 'arriaga3'. Current methods available are: 'arriaga3', 'chandrasekaran1', 'chandrasekaran2'. |
age_col |
Column providing ordered age bands with the final age group being an open-ended interval suffxied with '+', e.g. '90+'.. Of factor type. |
e1 |
Column name for expectation of life at age group x, in the 1st group of comparison. |
e2 |
Column name for expectation of life at age group x, in the 2nd group of comparison. |
l1 |
Column name for the proportion of persons alive at age group x, in the 1st group of comparison. |
l2 |
Column name for the proportion of persons alive at age group x, in the 2nd group of comparison. |
append |
Whether to append the decomposition columns to the original data frame. Default to TRUE. |
Value
A data frame with attached life expectancy age breakdown decomposition values
Title decomp_disease
Description
Function for performing life expectancy decomposition for disease groups
Usage
decomp_disease(
df,
breakdown,
diseases,
age_col,
group_1,
group_1_m,
group_2,
group_2_m,
nDx
)
Arguments
df |
An outputted life table with relevant columns of interest |
breakdown |
Whether disease breakdowns are raw mortality rates or a decimal proportion of total all-cause mortality rate. Accepts either 'proportion' or 'raw'. |
diseases |
Character vector of diseases which are suffixed to |
age_col |
Column providing ordered age bands with the final age group being an open-ended interval suffxied with '+', e.g. '90+'.. Of factor type. |
group_1 |
Unique matching stem prefix in columns for group 1 related disease cause breakdowns |
group_1_m |
Column name for group 1 all-cause mortality rate between ages x and x + n |
group_2 |
Unique matching stem prefix in columns for group 2 related disease cause breakdowns |
group_2_m |
Column name for group 2 all-cause mortality rate between ages x and x + n |
nDx |
Column name for contribution of all-cause mortality differences in groups 1 and 2 in age groups x to x + n. Computationally the same as the total effect column computed from |
Value
A data frame with attached life expectancy disease breakdown decomposition values
Age and Cause Decomposition of Difference in Life Expectancies at Birth, India and China, males, 1990
Description
A subset of data from The Global Burden of Disease Study 1996.
Usage
india_china_males_1990
Format
A data frame with 7 rows and 10 columns:
- Age
ordered age groups as factor type
- India_nmx
all-cause mortality rate between ages x and x + n for males in India, 1990
- India_CD
proportion of deaths from communicable diseases between ages x and x + n for males in India, 1990
- India_NCD
proportion of deaths from non-communicable diseases between ages x and x + n for males in India, 1990
- India_Injuries
proportion of deaths from injuries between ages x and x + n for males in India, 1990
- China_nmx
all-cause mortality rate between ages x and x + n for males in China, 1990
- China_CD
proportion of deaths from communicable diseases between ages x and x + n for males in China, 1990
- China_NCD
proportion of deaths from non-communicable diseases between ages x and x + n for males in China, 1990
- China_Injuries
proportion of deaths from injuries between ages x and x + n for males in China, 1990
- nDx
contribution of all-cause mortality differences in groups 1 and 2 in age groups x to x + n. Computationally the same as the total effect column computed from
decomp_LE().
where n = length of the age interval
Source
Murray, C. J. and A. D. Lopez, 1996. The Global Burden of Disease: A Comprehensive Assessment of Mortality and Disability from Diseases, Injuries, and Risk Factors in 1990 and Projected to 2020. Boston, Harvard University, School of Public Health.
Title plot_age
Description
S3 method for plot() that visualizes age-related decomposition breakdowns from a data frame.
It pivots columns from decomp_age() output into a long format and creates a formatted bar plot.
Usage
plot_age(x, method, plot_type, line = FALSE)
Arguments
x |
A data frame containing unmodified |
method |
Method used for age decomposition. Same as method argument in |
plot_type |
Plot either total contribution in years or segmented effect contribution. Options: "total", "segment_dodge". |
line |
Logical for additional line geom showing total effect if 'segment_dodge' |
Details
Plot age decomposition breakdown
Value
A ggplot object showing disease breakdown values
Examples
age_output <- decomp_age(us_females,
method = "arriaga3", age_col = "Age", e1 = "e1x",
e2 = "e2x", l1 = "l1x", l2 = "l2x"
)
plot_age(age_output, method = "arriaga3", plot_type = "segment_dodge")
plot_age(age_output, method = "arriaga3", plot_type = "segment_dodge", line = TRUE)
plot_age(age_output, method = "arriaga3", plot_type = "total", line = TRUE)
Title plot_disease
Description
Visualize disease-related deltas from a data frame.
It pivots columns starting with "delta" and ending with user-specified suffixes
(e.g., c("CD", "NCD", "Injuries")) into a long format and creates a formatted stacked bar plot.
Usage
plot_disease(x, suffixes, nDx, line = TRUE)
Arguments
x |
A data frame containing |
suffixes |
A character vector of disease suffixes to match (e.g., |
nDx |
Column name for contribution of all-cause mortality differences in groups 1 and 2 in age groups x to x + n. |
line |
Logical for additional line geom showing total effect. TRUE by default. |
Details
Plot disease decomposition breakdown
Value
A ggplot object showing disease breakdown values
Examples
disease_data <- decomp_disease(india_china_males_1990,
breakdown = "proportion", age_col = "Age", diseases = c("CD", "NCD", "Injuries"),
group_1 = "India", group_1_m = "India_nmx", group_2 = "China",
group_2_m = "China_nmx", nDx = "nDx"
)
plot_disease(disease_data, c("delta_CD", "delta_NCD", "delta_Injuries"), "nDx", line = FALSE)
plot_disease(disease_data, c("delta_CD", "delta_NCD", "delta_Injuries"), "nDx", line = TRUE)
Life table values for United States, Females, 1935 and 1995
Description
A subset of data from 'Life Tables for the United States Social Security Area, 1900-2080' for United States women born in 1935 and 1995.
Usage
us_females
Format
A data frame with 19 rows and 7 columns:
- Age
ordered age groups as factor type
- nm1x
age specific death rate in the age group x; x + n in the initial time period ‘1935’
- l1x
number of persons alive at exact age x, in the initial time period ‘1935’ expressed as decimal form and as a proportion of the starting the age group
- e1x
expectation of life at exact age x, in the initial time period ‘1935’
- nm2x
age specific death rate in the age group x; x + n in the latter time period ‘1995’
- l2x
number of persons alive at exact age x, in the latter time period ‘1995’ expressed as decimal form and as a proportion of the starting the age group
- e2x
expectation of life at exact age x, in the latter time period ‘1995’
where n = length of the age interval
Source
Murthy, P.K. (2005). A comparison of different methods for decomposition of changes in expectation of life at birth and differentials in life expectancy at birth. Demographic Research, 12, pp.141–172. doi: doi:10.4054/demres.2005.12.7, Appendix 1, available at https://www.demographic-research.org/volumes/vol12/7/12-7.pdf
Bell, F.C., A.H. Wade and S.C. Goss, (1992), Life Tables for the United States Social Security Aria: 1900-2080. Baltimore, Maryland, US Social Security Administration Office of the Actuary, Actuarial Study No.107, [nmx, and ex columns were calculated from lx; nLx and Tx columns given in: Preston, S.H., P.Heuveline and M.Guillot (2001) Demography: Measuring and Modeling Population Processes, United Kingdom: Blackwell Publishers Ltd., Box: 3.4, P.65]