```help mata mm_gini()
-------------------------------------------------------------------------------

Title

mm_gini() -- Gini coefficient

Syntax

real rowvector mm_gini(X [, w])

where

X:  real matrix containing data (rows are observations, columns
variables)

w:  real colvector containing weights

Description

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.

Remarks

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.

Example:

: x = exp(invnormal(uniform(100,1)))

: mm_gini(x, 1)
.5158638536

Conformability

mm_gini(x, w):
X:  n x k
w:  n x 1 or 1 x 1
result:  1 x k

Diagnostics

None.

Source code

mm_gini.mata

Author

Ben Jann, ETH Zurich, jann@soz.gess.ethz.ch

Also see

Online:  help for [M-5] mean(), moremata

Links to user-written programs:  anogi, egen_inequal, inequal7, ineqerr,
```