Type: | Package |
Title: | Affluence (Richness) Indices |
Version: | 2.2 |
Date: | 2024-09-18 |
Maintainer: | Alicja Wolny-Dominiak <alicja.wolny-dominiak@ue.katowice.pl> |
Description: | Enables to compute the statistical indices of affluence (richness) with bootstrap errors, and inequality and polarization indices. Moreover, gives the possibility of calculation of affluence line. Some simple errors are fixed and it works with new version of Spatial Statistics packaged. |
Depends: | R (≥ 3.6.2), stats |
Imports: | spatstat.univar |
Author: | Alicja Wolny-Dominiak [aut, cre], Anna Saczewska-Piotrowska [aut] |
License: | GPL-2 |
NeedsCompilation: | no |
Packaged: | 2024-09-20 07:57:04 UTC; woali |
Repository: | CRAN |
Date/Publication: | 2024-09-21 17:50:02 UTC |
Affluence (richness) indices
Description
This package allows to compute the affluence indices (average affluence gap, income share of the top p %, richness headcount ratio, concave and convex measures of affluence) and to construct the confidence intervals for the affluence indices. The affluence line is defined by the user as multiple of the income median. This package also allows to compute the Medeiros's affluence line which is set as a multiple (defined by the user) of the income median. Additionally, this package allows also to compute some standard inequality and polarization measures: the Gini coefficient, the Palma index, the Wolfson polarization index. All measures may be calculated with weighted data.
Author(s)
Alicja Wolny-Dominiak, Anna Saczewska-Piotrowska
Maintainer: Alicja Wolny-Dominiak
References
1. Alichi A., Kantenga K., Sole J. (2016) Income polarization in the United States. IMF Working Paper, WP/16/121.
2. Brzezinski M. (2010) Income affluence in Poland. Social Indicators Research, 99, pp. 285-299.
https://link.springer.com/article/10.1007/s11205-010-9580-0
3. Cobham A., Sumner A.(2013). Is it all about the tails? The Palma measure of income inequality. Working Paper No. 343, Center for Global Development.
4. Creedy J. (2015). A note on computing the Gini inequality measure with weighted data. Workin Paper No. 3, Victoria University of Wellington.
5. Lerman R.I., Yitzhaki S. (1989) Improving the accuracy of estimates of Gini coefficients. Journal of Econometrics, 42(1), pp. 43-47.
doi:10.1016/0304-4076(89)90074-2
6. Medeiros M. (2006) The rich and the poor: the construction of an affluence line from the poverty line. Social Indicators Research, 78(1), pp. 1-18.
https://link.springer.com/article/10.1007/s11205-005-7156-1
7. Peichl A., Schaefer T., Scheicher C. (2008) Measuring richness and poverty - A micro data application to Europe and Germany. IZA Discussion Paper No. 3790, Institute for the Study of Labor (IZA).
8. Saczewska-Piotrowska A. (2015) Identification of determinants of income richness using logistic regression model.
Zarzadzanie i Finanse. Journal of Management and Finance, 4, Part 2, pp. 241-259 (in Polish).
9. Wolfson M.C. (1994) When inequalities diverge, The American Economic Review, 84, pp. 353-358.
https://www.jstor.org/stable/2117858
Palma index
Description
Computes the Palma index (also known as S90/S40 ratio)
Usage
S90S40(x, weight)
Arguments
x |
income vector |
weight |
vector of weights |
Details
The Palma index is the ratio between the income share of the top 10\%
and the bottom 40\%
. The weighted Palma index (with weights w_1,w_2,...,w_n
) is given by:
S90/S40 = \frac{\sum_{i=1}^n{x_iw_i}\boldsymbol{1}_{x_i>q_{w(0.9)}}}{\sum_{i=1}^n{x_iw_i}\boldsymbol{1}_{x_i \leq q_{w(0.4)}}},
where x_i
is an income of individual i
, n
is the number of individuals, q_{w(0.9)},q_{w(0.4)}
are the 0.9 and 0.4 quantiles, respectively,
\boldsymbol{1}_{(\cdot)}
denotes the indicator function, which is equal to 1 when its argument is true and 0 otherwise.
Value
S90S40 |
the value of index |
Author(s)
Anna Saczewska-Piotrowska, Alicja Wolny-Dominiak
References
Cobham A., Sumner A.(2013). Is it all about the tails? The Palma measure of income inequality. Working Paper No. 343, Center for Global Development
Equivalised income
Description
The database contains information about equivalised income of households.
Usage
data("affluence")
Format
A data frame with 2000 observations on the following 4 variables.
income
a numeric vector (equivalised income of households; equivalisation using modified OECD scale)
education
a numeric vector (education of the household's head: 1=tertiary, 2=secondary, 3=basic vocational, 4=low)
age
a numeric vector (age of the household's head: 1=less than 35, 2=35-44, 3=45-59, 4=60 and more)
sex
a numeric vector (sex of the household's head: 0=male, 1=female)
hs_size
vector of weights
Source
Based on Council for Social Monitoring (2016). Integrated database.http://www.diagnoza.com [11.09.2016].
Examples
data(affluence)
names(affluence)
Bootstrap standard error 1
Description
Calculates the bootstrap standard errors.
Usage
boot.sd1(x, weight, kp, nsim, boot.index = c("r.hc", "r.is"), gamma)
Arguments
x |
income vector |
weight |
vector of weights |
kp |
multiple of the median income (k) or order of quantile (p) |
nsim |
the number of replications |
boot.index |
the index for which the error is estimated |
gamma |
confidence level |
Details
The function uses quantile method of calculating bootstrap confidence intervals.
Value
se.r |
the bootstrap error |
summary |
bootstrap summary |
boot.ind |
bootstraped sample of index |
Author(s)
Alicja Wolny-Dominiak
References
Brzezinski M. (2010) Income affluence in Poland. Social Indicators Research, 99, pp. 285-299.
Examples
data(affluence)
affluence$weight <- rep(1, nrow(affluence))
boot.sd1(affluence$income, affluence$weight, 0.9, 10, "r.is", 0.95)
boot.sd1(affluence$income, affluence$weight, 2, 10, "r.hc", 0.95)
Bootstrap standard error 1
Description
The estimation of bootstrap standard error of affluence index in subpopulation.
Usage
boot.sd1.sub(x.sub, x, weight.sub, weight, kp, nsim, boot.index=c("r.hc", "r.is"), gamma)
Arguments
x |
income vector of subpopulation |
x.sub |
income vector of population |
weight.sub |
weight vector of subpopulation |
weight |
weight vector of population |
kp |
multiple of the median income (k) or order of quantile (p) |
nsim |
the number of replications |
boot.index |
the index for which the error is estimated |
gamma |
confidence level |
Details
The function uses quantile method of calculating bootstrap confidence intervals.
Value
se.r |
the bootstrap error of the affluence index |
summary |
bootstrap summary |
boot.ind |
bootstraped sample of index |
Author(s)
Alicja Wolny-Dominiak
References
Brzezinski M. (2010) Income affluence in Poland. Social Indicators Research, 99, pp. 285-299.
Examples
data(affluence)
affluence$weight <- rep(1, nrow(affluence))
aff.sub <- subset(affluence, education == 2)
boot.sd1.sub(aff.sub$income, affluence$income, aff.sub$weight, affluence$weight,
0.9, 10, "r.is", 0.95)
boot.sd1.sub(aff.sub$income, affluence$income, aff.sub$weight, affluence$weight,
0.9, 10, "r.hc", 0.95)
Bootstrap standard error 2
Description
Calculates the bootstrap standard errors.
Usage
boot.sd2(x, weight, k, alpha, nsim, boot.index = c("r.cha", "r.fgt"), gamma)
Arguments
x |
income vector |
weight |
weight vector of population |
k |
multiple of the median income |
alpha |
parameter of the index: |
nsim |
the number of replications |
boot.index |
the index for which the error is estimated |
gamma |
confidence level |
Details
The function uses quantile method of calculating bootstrap confidence intervals.
Value
se.r |
the bootstrap error |
summary |
bootstrap summary |
boot.ind |
vector of bootstraped index |
Author(s)
Alicja Wolny-Dominiak
References
Brzezinski M. (2010) Income affluence in Poland. Social Indicators Research, 99, pp. 285-299.
Examples
data(affluence)
boot.sd2(affluence$income, weight = NULL, 2, 2, 10, "r.cha", 0.95)
boot.sd2(affluence$income, weight = NULL, 2, 2, 10, "r.fgt", 0.95)
Bootstrap standard error 2
Description
Calculates the bootstrap standard errors in subpopulation.
Usage
boot.sd2.sub(x.sub,x,weight.sub,weight,k,alpha,nsim,boot.index=c("r.cha","r.fgt"),gamma)
Arguments
x |
income vector of subpopulation |
x.sub |
income vector of population |
weight.sub |
weight vector of subpopulation |
weight |
weight vector of population |
k |
multiple of the median income |
alpha |
parameter of the index: |
nsim |
the number of replications |
boot.index |
the index for which the error is estimated |
gamma |
confidence level |
Details
The function uses quantile method of calculating bootstrap confidence intervals.
Value
se.r |
the bootstrap error |
summary |
bootstrap summary |
Author(s)
Alicja Wolny-Dominiak
References
Brzezinski M. (2010) Income affluence in Poland. Social Indicators Research, 99, pp. 285-299.
Examples
data(affluence)
affluence$weight <- rep(1, nrow(affluence))
aff.sub <- subset(affluence, education == 2)
x <- aff.sub$income
boot.sd2.sub(x, affluence$income, aff.sub$weight, affluence$weight, 2, 2, 10, "r.cha", 0.95)
boot.sd2.sub(x, affluence$income, aff.sub$weight, affluence$weight, 2, 2, 10, "r.fgt", 0.95)
Gini coefficient
Description
Computes the Gini coefficient.
Usage
gini.w(x, weight)
Arguments
x |
income vector of population |
weight |
vector of weights |
Details
The Gini coefficient is the most popular measure of income inequality. The formula taking into account the weights of income w_1,w_2,...,w_n
is given by:
G_w = \frac{\sum_{i=1}^nw_i\sum_{j=1}^n w_j|x_i-x_j|}{2(\sum_{i=1}^nw_i)^2\mu_w},
where x_i,x_j
are incomes of individuals i
and j
, respectively, n
is the number of individuals, \mu_w
is the mean income. The Gini coefficient ranges between 1 (perfect equality) and 1 (perfect inequality).
Value
GG |
the value of coefficient |
Author(s)
Alicja Wolny-Dominiak, Anna Saczewska-Piotrowska
References
1. Creedy J. (2015). A note on computing the Gini inequality measure with weighted data. Workin Paper No. 3, Victoria University of Wellington.
2. Lerman R.I., Yitzhaki S. (1989) Improving the accuracy of estimates of Gini coefficients. Journal of Econometrics, 42(1), pp. 43-47.
Examples
data(affluence)
gini.w(affluence$income, affluence$hs_size)
Medeiros's affluence line
Description
Computes the Medeiros's affluence line.
Usage
line.med(x, weight, k)
Arguments
x |
the income vector |
weight |
vector of weights |
k |
poverty line as a multiple of the median income |
Details
The Medeiros's affluence line is based on the concept of poverty gap related to a given poverty line (in the package this line is set as a defined by the user multiple of the median income). Based on the determined poverty gap, there is calculated the point where the income of the richest should be reduced in order to make possible enough transfers to cover this gap and eliminate poverty. The calculated point of income may be also presented as the multiple of the median income.
Value
median_inc |
the median income |
Gp |
the poverty gap |
rho_medeiros |
Medeiros's affluence line |
median_multiple |
Medeiros's affluence line as a multiple of the median |
Author(s)
Anna Saczewska-Piotrowska, Alicja Wolny-Dominiak
References
Medeiros M. (2006) The rich and the poor: The construction of an affluence line from the poverty line. Social Indicators Research, 78(1), pp. 1-18.
Examples
data(affluence)
line.med(affluence$income, affluence$hs_size, 0.6)
Wolfson polarization index
Description
Computes the Wolfson polarization index.
Usage
polar.aff(x, weight)
Arguments
x |
the income vector |
weight |
vector of weights |
Details
Standard inequality measures do not give any information about polarization. A more polarized income distribution is one that has relatively fewer middle income class and more low- and/or high-income households (Alichi et al. 2016). Low income class is very often identified with poverty and high-income class with richness. One of the measures of polarization is the Wolfson polarization index (Wolfson 1994). Weighted version of this index is given by:
P_w= 2 \left( 2T-G_w \right) \frac{\mu_w}{\rho_w},
where T
is the difference between 0.5 and the income share of bottom half of the population, G_w
is the Gini coefficient,
\mu_w
is the mean income, \rho_w
is the median income.
Value
Pw |
the value of index |
TT |
the difference between 0.5 and the income share of bottom half of the population |
Author(s)
Alicja Wolny-Dominiak, Anna Saczewska-Piotrowska
References
1. Alichi A., Kantenga K., Sole J. (2016) Income polarization in the United States. IMF Working Paper, WP/16/121.
2. Wolfson M.C. (1994) When inequalities diverge, The American Economic Review, 84, pp. 353-358.
Examples
data(affluence)
polar.aff(affluence$income, weight = NULL)
Concave measure of affluence
Description
Computes the measure of affluence analogous to the poverty index of Chakravarty (1983).
Usage
r.cha(x, weight, k, beta)
Arguments
x |
the income vector |
weight |
vector of weights |
k |
multiple of the median income |
beta |
parameter of the index: |
Details
Peichl et. al (2008) defined an affluence index. Weighted index (with weights w_1,w_2,...,w_n
) is given by:
R^{CHA}_{\beta}(\boldsymbol{x},\boldsymbol{w},\rho_w) = \frac{\sum_{i=1}^n(1-(\frac{\rho_w}{x_i})^\beta)\boldsymbol{1}_{x_i > \rho_w}w_i}{\sum_{i=1}^n{w_i}}, \beta > 0,
where x_i
is an income of individual i
, n
is the number of individuals, \rho_w
is the richness line,
\boldsymbol{1}_{(\cdot)}
denotes the indicator function, which is equal to 1 when its argument is true and 0 otherwise.
Index satisfies transfer axiom T1
(concave): a richness index should increase when a rank-preserving progressive transfer between two rich individuals takes place.
Value
r |
elements of the sum in the index formula |
r.cha |
the value of index |
Author(s)
Alicja Wolny-Dominiak, Anna Saczewska-Piotrowska
References
1. Chakravarty S.R. (1983) A new index of poverty. Mathematical Social Sciences, 6, pp. 307-313.
2. Peichl A., Schaefer T., Scheicher C. (2008) Measuring richness and poverty - A micro data application to Europe and Germany. IZA Discussion Paper No. 3790, Institute for the Study of Labor (IZA).
Examples
data(affluence)
r.cha(affluence$income, weight = NULL, 2, 2)
Concave measure of affluence in subpopulation
Description
Computes the measure of affluence in subpopulation analogous to the poverty index of Chakravarty(1983).
Usage
r.cha.sub(x.sub, x, weight.sub, weight, k, beta)
Arguments
x |
income vector of subpopulation |
x.sub |
income vector of population |
weight.sub |
weight vector of subpopulation |
weight |
weight vector of population |
k |
multiple of the median income |
beta |
parameter of the index: |
Value
r |
elements of the sum in the index formula |
r.cha |
the value of index |
Author(s)
Alicja Wolny-Dominiak, Anna Saczewska-Piotrowska
References
1. Chakravarty S.R. (1983) A new index of poverty. Mathematical Social Sciences, 6, pp. 307-313.
2. Peichl A., Schaefer T., Scheicher C. (2008) Measuring richness and poverty - A micro data application to Europe and Germany. IZA Discussion Paper No. 3790, Institute for the Study of Labor (IZA).
See Also
Examples
data(affluence)
r.cha(affluence$income, weight = NULL, 2, 2)
Convex measure of affluence
Description
Computes the measure of affluence analogous to the convex version of Foster, Greer and Thorbecke (1984) family of poverty indices.
Usage
r.fgt(x, weight, k, alpha)
Arguments
x |
the income vector |
weight |
vector of weights |
k |
multiple of the median income |
alpha |
parameter of the index: |
Details
Peichl et. al (2008) defined an affluence index. Weighted index (with weights w_1,w_2,...,w_n
) is given by:
R_{\alpha}^{FGT,T2}(\mathbf{x},\mathbf{w},\rho_w)=\frac{\sum_{i=1}^{n} \left( \frac{x_i - \rho_w}{\rho_w}\right)^{\alpha}\mathbf{1}_{x_i>\rho_w}w_i}{\sum_{i=1}^{n}w_i},\alpha>1,
where x_i
is an income of individual i
, n
is the number of individuals, \rho_w
is the richness line, \boldsymbol{1}_{(\cdot)}
denotes the indicator function, which is equal to 1 when its argument is true and 0 otherwise.
Index satisfies transfer axiom T2
(convex): a richness index should decrease when a rank-preserving progressive transfer between two rich individuals takes place.
Value
r |
values of the sum in the index formula |
r.fgt |
the value of index |
Author(s)
Alicja Wolny-Dominiak, Anna Saczewska-Piotrowska
References
1. Foster J.E., Greer J., Thorbecke E. (1984) A class of decomposable poverty measures. Econometrica, 52, pp. 761-766.
2. Peichl A., Schaefer T., Scheicher C. (2008) Measuring richness and poverty - A micro data application to Europe and Germany. IZA Discussion Paper No. 3790, Institute for the Study of Labor (IZA).
Examples
data(affluence)
r.fgt(affluence$income, weight = NULL, 2, 1)
Convex measure of affluence in subpopulation
Description
Computes the measure of affluence in subpopulation analogous to the convex version of Foster, Greer and Thorbecke (1984) family of poverty indices.
Usage
r.fgt.sub(x.sub, x, weight.sub, weight, k, alpha)
Arguments
x |
income vector of subpopulation |
x.sub |
income vector of population |
weight.sub |
weight vector of subpopulation |
weight |
weight vector of population |
k |
multiple of the median income |
alpha |
parameter of the index: |
Value
r |
values of the sum in the index formula |
r.fgt |
the value of index |
Author(s)
Alicja Wolny-Dominiak, Anna Saczewska-Piotrowska
References
1. Foster J.E., Greer J., Thorbecke E. (1984) A class of decomposable poverty measures. Econometrica, 52, pp. 761-766.
2. Peichl A., Schaefer T., Scheicher C. (2008) Measuring richness and poverty - A micro data application to Europe and Germany. IZA Discussion Paper No. 3790, Institute for the Study of Labor (IZA).
See Also
Examples
data(affluence)
affluence$weight <- rep(1, nrow(affluence))
aff.sub <- subset(affluence, education == 2)
r.fgt.sub(aff.sub$income, affluence$income, aff.sub$weight, affluence$weight, 2, 1)
Richness headcount ratio
Description
Computes the richness headcount ratio.
Usage
r.hc(x, weight, k)
Arguments
x |
the income vector |
weight |
weight vector of population |
k |
multiple of the median income |
Details
Richness headcount ratio is a proportion of the population with incomes above the affluence line. Weighted version (with weights w_1,w_2,...,w_n
)
of this ratio is given by:
R^{HC}(\boldsymbol{x},\boldsymbol{w},\rho_w) = \frac{\sum_{i=1}^n \boldsymbol{1}_{x_i > \rho_w}w_i}{\sum_{i=1}^n{w_i}},
where x_i
is an income of individual i
, n
is the number of individuals, \rho_w
is the richness line,\boldsymbol{1}_{(\cdot)}
denotes the indicator function, which is equal to 1 when its argument is true and 0 otherwise.
Value
count.rich |
the number of the rich |
r.hc |
the value of index |
Author(s)
Alicja Wolny-Dominiak, Anna Saczewska-Piotrowska
References
1. Brzezinski M. (2010) Income affluence in Poland. Social Indicators Research, 99, pp. 285-299.
2. Saczewska-Piotrowska A. (2015) Identification of determinants of income richness using logistic regression model.
Zarzadzanie i Finanse. Journal of Management and Finance, 4, Part 2, pp. 241-259 (in Polish).
Examples
data(affluence)
affluence$weight <- rep(1, nrow(affluence))
r.hc(affluence$income, affluence$weight, 3)
Richness headcount ratio in subpopulation
Description
Computes the richness headcount ratio in subpopulation.
Usage
r.hc.sub(x.sub, x, weight.sub, weight, k)
Arguments
x.sub |
income vector of subpopulation |
x |
income vector of population |
weight.sub |
weight vector of subpopulation |
weight |
weight vector of population |
k |
multiple of the median income |
Value
count.rich |
the number of the rich |
r.hc |
the value of the index |
Author(s)
Alicja Wolny-Dominiak, Anna Saczewska-Piotrowska
References
1. Brzezinski M. (2010) Income affluence in Poland. Social Indicators Research, 99, pp. 285-299.
2. Saczewska-Piotrowska A. (2015) Identification of determinants of income richness using logistic regression model.
Zarzadzanie i Finanse. Journal of Management and Finance, 4, Part 2, pp. 241-259 (in Polish).
See Also
Examples
data(affluence)
affluence$weight <- rep(1, nrow(affluence))
aff.sub <- subset(affluence, education == 2)
r.hc.sub(aff.sub$income, affluence$income, aff.sub$weight, affluence$weight, 3)
Income share of the top p %
Description
Computes the income share of the top p %.
Usage
r.is(x, weight, p)
Arguments
x |
the vector of income |
weight |
vector of weights |
p |
the order of quantile. Must be in [0,1] as probability |
Details
The most popular measure of richness which takes a form (with weights w_1,w_2,...,w_n
):
R^{IS}(\boldsymbol{x},\boldsymbol{w},p) = \frac{\sum_{i=1}^n{x_iw_i}\boldsymbol{1}_{x_i>q_{w(1-p)}}}{\sum_{i=1}^n{x_iw_i}},
where q_{w(1-p)}
is the (1-p)
quantile of the population and \boldsymbol{1}_{(\cdot)}
denotes the indicator function, which is equal to 1 when its argument is true and 0 otherwise.
There is always p
% of rich individualsa in the population.
Value
r.2 |
the value of index |
Author(s)
Alicja Wolny-Dominiak, Anna Saczewska-Piotrowska
References
Brzezinski M. (2010) Income affluence in Poland. Social Indicators Research, 99, pp. 285-299.
Examples
data(affluence)
r.is(affluence$income, weight = NULL, 0.9)
Income share of the top p % in subpopulation
Description
Computes income share of the top p % in subpopulation.
Usage
r.is.sub(x.sub, x, weight.sub, weight, p)
Arguments
x.sub |
income vector of subpopulation |
x |
income vector of population |
weight.sub |
weight vector of subpopulation |
weight |
weight vector of population |
p |
the order of quantile. Must be in [0,1] as probability |
Value
r.2 |
the value of index |
Author(s)
Alicja Wolny-Dominiak, Anna Saczewska-Piotrowska
References
Brzezinski M. (2010) Income affluence in Poland. Social Indicators Research, 99, pp. 285-299.
See Also
Examples
data(affluence)
affluence$weight <- rep(1, nrow(affluence))
aff.sub <- subset(affluence, education == 2)
r.is.sub(aff.sub$income, affluence$income, aff.sub$weight, affluence$weight, 0.9)
Average affluence gap
Description
Computes the average affluence gap of population.
Usage
r.med(x, weight, k)
Arguments
x |
income vector |
weight |
vector of weights |
k |
multiple of the median income |
Details
Medeiros (2006) defined an average affluence gap. Weighted gap (with weights w_1,w_2,...,w_n
) is given by:
R^{Me}= \frac{\sum_{i=1}^n \max\{x_i-\rho_w,0\}w_i}{\sum_{i=1}^nw_i},
where x_i
is an income of individual i
, n
is the number of individuals, \rho_w
is the richness line.
Medeiros' index is not standarized and is an absolute measure of richness.
Value
gap |
the value of the average affluence gap |
Author(s)
Alicja Wolny-Dominiak, Anna Saczewska-Piotrowska
References
Medeiros M. (2006) The rich and the poor: the construction of an affluence line from the poverty line. Social Indicators Research, 78, pp. 1-18.
Examples
data(affluence)
r.med(affluence$income, weight = NULL, 2)
Average affluence gap in subpopulation
Description
Computes the average affluence gap in subpopulation.
Usage
r.med.sub(x.sub, x, weight.sub, weight, k)
Arguments
x |
income vector of subpopulation |
x.sub |
income vector of population |
weight.sub |
weight vector of subpopulation |
weight |
weight vector of population |
k |
multiple of the median income |
Value
gap |
the gap value |
Author(s)
Alicja Wolny-Dominiak
References
Medeiros M. (2006) The rich and the poor: the construction of an affluence line from the poverty line. Social Indicators Research, 78, pp. 1-18.
See Also
Examples
data(affluence)
affluence$weight <- rep(1, nrow(affluence))
aff.sub <- subset(affluence, education == 2)
r.med.sub(aff.sub$income, affluence$income, aff.sub$weight, affluence$weight, 2)