help fastgini-------------------------------------------------------------------------------

Title

fastgini-- Fast algorithm for calculation of Gini coefficient and it's jackknife standard errors

Syntax

fastginivarname[if] [in] [weight] [,bin(#)jkLevel(#)nocheck]

pweights andfweights are allowed; see weight.

Description

fastginicalculates the Gini coefficient for either unit-level or aggregated level data. Optionally it returns the jackknife estimates of the standard error.fastginiuses a fast optimized algorithm that could be especially useful when calculating the Gini coefficient and it's standard errors for the large samples. The command implements algorithms for both exact and approximate calculation of the Gini coefficient.+------+ ----+ Main +-------------------------------------------------------------

bin(#)set number of bins. Specifying this option can dramatically reduce the computation time when working with large datasets (1M+ obs). Whenbin(#)is specifiedfastginiuses approximation algorithm for Gini calculation. Specifying the sufficient number bins allows obtaining the approximation for the Gini at any desired level of precision. For example, on the dataset of 1,000,000 observationsbin(100,000)will in most cases estimate computer-exact value of Gini. This calculation required significantly less computer time compared to the exact estimation of the Ginin on whole sample.

jkestimate jackknife (leave-one-out) standard error of the Gini coefficient. An efficient method of calculating jackknife estimates involves only two (one to get the Gini coefficient itself and another for standard errors) runs through the data.

level(#)set confidence level for the reported jackknife confidence intervals; default islevel(95).

nocheckby default, non-positive values ofvarnameare excluded from Gini calculations. Specifying {opt nocheck} skips the value check as well as ignores [if] [in] conditions. The option can be useful to speed-up the execution iffastginiis used within loops.

Saved Results

fastginisaves inr():

r(gini)calculated Gini coefficient;if

jkoption specified:

r(se)jackknife estimate for the standard error of the Gini;

r(mse)jackknife estimate for the mean standard error of the Gini;

r(gini_jk)jackknife estimate for the Gini.

Remarks

fastginiuses formula:i=N j=i SUM W_i*(SUM W_j*X_j - W_i*X_i/2) i=1 j=1 G = 1 - 2* ---------------------------------- i=N i=N SUM W_i*X_i * SUM W_i i=1 i=1

where observations are sorted in ascending order of X.

if

bin(M)is specified, the data are aggregated intoMequal-size bins, i.e.~ X_i = (X_min + i * binsize) binsize = (X_max - X_min)/M

~ ~ ~ W_i = SUM W_j (if X_(i-1)<=X_j<X_i) i=1..M j

and then Gini coefficient is calculated using aggregated data.

Examples

.fastgini pc_exp

.fastgini income [w=weight], jk

.fastgini income [w=weight], bin(10000)

AuthorZurab Sajaia, DECRG-PO SDG, The World Bank, zsajaia@worldbank.org

ReferencesKaragiannis E. and M. Kovacevic' (2000), "A Method to Calculate Jakknife Variance Estimator For the Gini Coefficient", Oxford Bulletin of Economics and Statistics, Vol. 62 Issue 1 119-122.

Also seeOnline: jackknife

Links to user-written programs: inequal7, egen_inequal, mm_gini(), ineqerr, ineqdeco, ineqdec0