bw_decomp | R Documentation |
Partition a lifespan inequality index into additive components of between-group inequality and within-group inequality. Presently implemented for Theil's index, e-dagger, variance, mean log deviation, the gini coeficient, mean absolute deviatation, the absolute inter-individual difference, and life table entropy (H).
bw_decomp(
age,
ax,
dx,
lx,
ex,
distribution_type = "aad",
prop = rep(1/ncol(dx), ncol(dx)),
method = c("theil", "edag", "var", "mld", "gini", "mad", "aid", "H")
)
age |
numeric vector of lower age bounds. |
ax |
numeric matrix of the average time spent in the age interval of those dying within the interval with age in rows and subgroups in columns. |
dx |
numeric matrix of the lifetable death distribution with age in rows and subgroups in columns. |
lx |
numeric matrix of the lifetable survivorship with age in rows and subgroups in columns. |
ex |
numeric matrix of remaining life expectancy with age in rows and subgroups in columns. |
distribution_type |
|
prop |
numeric vector of starting fractions for each of the subgroups. |
method |
character one of |
data(LT)
data(LTm)
# rescale dx to exactly sum to radix,
# this is a nerd step
LT$dx <- LT$dx / sum(LT$dx)
LTm$dx <- LTm$dx / sum(LTm$dx)
# make argument matrices (in this case just two columns)
method <- "mld"
ind <- 26:11
age <- 0:110
ax <- cbind(LT$ax,LTm$ax)
dx <- cbind(LT$dx,LTm$dx)
lx <- cbind(LT$lx,LTm$lx)
ex <- cbind(LT$ex,LTm$ex)
# Choice of remaining life vs age-at-death
# makes no difference for age 0:
method <- "mld"
# same story with other method choice
# (try "mld", theil", "edag","var","mld","gini","mad","aid", or "H")
bw_decomp(age = age,
ax = ax,
dx = dx,
lx = lx,
ex = ex,
prop = c(.4886,1-.4886),
distribution_type = "rl",
method = method)$fB
bw_decomp(age = age,
ax = ax,
dx = dx,
lx = lx,
ex = ex,
prop = c(.4886,1-.4886),
distribution_type = "aad",
method = method)$fB
# but if we age-condition, results should differ:
method <- "theil"
ind <- 26:111
bw_decomp(age = age[ind],
ax = ax[ind, ],
dx = dx[ind, ],
lx = lx[ind, ],
ex = ex[ind, ],
prop = c(.47,.53),
distribution_type = "rl",
method = method)$fB
bw_decomp(age = age[ind],
ax = ax[ind, ],
dx = dx[ind, ],
lx = lx[ind, ],
ex = ex[ind, ],
prop = c(.47,.53),
distribution_type = "aad",
method = method)$fB
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.