mm_gini() -- Gini coefficient
real rowvector mm_gini(X [, w])
X: real matrix containing data (rows are observations, columns variables)
w: real colvector containing weights
mm_gini(X, w) returns the Gini coefficient of each column of X.
w specifies the weights. Omit w, or specify w as 1 to obtain unweighted results. Missing values in X or w are omitted from the calculation.
The formula used in mm_gini() is
G(x) = 2 * Cov0(x, F) / mu
where mu is the mean of x. Let N denote the number of observations (or sum of weights). Then,
Cov0(x, F) = DCP(x, F) / N
where DCP(x, F) denotes the deviation cross product between x and its (adjusted) empirical cumulative, F. To be precise, F is defined as
1 w_i F_i = - * ( SUM w_j - --- ), i = 1,...,n W x_j<=x_i 2
where w_i are weights and W is the total sum of weights.
: x = exp(invnormal(uniform(100,1))) : mm_gini(x, 1) .5158638536
mm_gini(x, w): X: n x k w: n x 1 or 1 x 1 result: 1 x k
Ben Jann, ETH Zurich, firstname.lastname@example.org
Online: help for [M-5] mean(), moremata
Links to user-written programs: anogi, egen_inequal, inequal7, ineqerr,