Learn R Programming

wINEQ (version 1.2.1)

Gini: Gini coefficient

Description

Computes Gini coefficient of a given variable taking into account weights.

Usage

Gini(X, W = rep(1, length(X)), fast = TRUE, rounded.weights = FALSE)

Value

The value of Gini coefficient.

Arguments

X

is a data vector

W

is a vector of weights

fast

logical, if TRUE (default), Gini is calculated via matrix operations - fast but may cause memory allocation problems. If FALSE, Gini is calculated via vector operations - slower but with better memory allocation

rounded.weights

logical, may be run when fast=FALSE. If TRUE (default), Gini is calculated through alternative formula based on ordered X and integer weights. Choose it when dealing with memory allocation problems.

Details

Gini coefficient is given by: $$G = \frac{ \sum_{i=1}^n \sum_{j=1}^n \mid x_{i} - x_{j} \mid}{2n^{2} \overline{x}}$$

References

Dixon P. M., Weiner, J., Mitchell-Olds, T., and Woodley, R.: (1987) Bootstrapping the Gini Coefficient of Inequality. Ecology , Volume 68 (5)

Firebaugh G.: (1999) Empirics of World Income Inequality, American Journal of Sociology

Deininger K.; Squire L.: (1996) A New Data Set Measuring Income Inequality, The World Bank Economic Review, Vol. 10, No. 3

Examples

Run this code
# Compare weighted and unweighted result
X=1:10
W=1:10
Gini(X)
Gini(X,W)

data(Tourism)
#Gini coefficient for Total expenditure with sample weights
X=Tourism$Total_expenditure
W=Tourism$Sample_weight
Gini(X,W)


Run the code above in your browser using DataLab