logo

Applied Econometrics 
Econ 508 - Fall 2014

Professor: Roger Koenker 

TA: Nicolas Bottan 

Welcome to a new issue of e-Tutorial. This time we focus on measures of inequality. We will suggest some basic methods to calculate the Hill estimator, the Lorenz curve, and the Gini coefficient. The data set to be used is the same from the problem set 4. 1

Data

The first thing you need is to download the phuzics panel data set, called phuzics10.txt from the Econ 508 web site. Save it in your preferred directory.

The next step is loading the Data in Stata. If you saved it in your hard drive you can load it by typing:

    infile id  yr  phd  sex  rphd  ru  y  Y  s  using  "phuzics10.txt", clear
drop if id==.
xtset id yr

Hill Estimator

Here we compute the Hill estimator mentioned in Prof. Koenker’s Lecture 19 and “Appendix A - Concentration of Productivity in Phuzics Scholarship”.The idea is to calculate the index of concentration “\(\alpha\)” for the years between 1970 and 1990, and check if there is a trend. As mentioned in the note, if there is an unbiased positive trend, you can infer that phuzics productivity is becoming less concentrated, and the field is becoming less scientific (according to Parzen’s definition of the term). An unbiased negative trend would mean the reverse. The function below can calculate the alpha-coefficient of concentration for a given year (say, 1970). You are expected to adjust the code such that you can reproduce the experiment for the other periods:

   drop if yr~=70  
gsort -Y
gen Yratio=Y/Y[11]
drop if Y<Y[10]
gen a=log(Yratio)
egen b=sum(a)
scalar alpha=(b/10)^(-1)
scalar list
   alpha =  .73199431

You are asked to repeat this for the remaining years, and then plot the coefficients along time.

Bootstrap Bias-Correction for the Hill Estimator:

In STATA, you can implement the bootstrap bias correction for the Hill estimator, suggested in Prof. Koenker's "Appendix A - Concentration of Productivity in Phuzics Scholarship", by using the command bsample. I will do that for one year, say, 1970, and then you can replicate the experiment for other years. The strategy is as folows:

Numerator \(\alpha_{N}\):

The first step is to calculate the numerator of the formula on page 2 of the note “Appendix A - Concentration of Productivity in Phuzics Scholarship”, called alpha_N. This is done as follows.

  1. Open the original data set;
   infile id  yr  phd  sex  rphd  ru  y  Y  s  using  "phuzics10.txt", clear
drop if id==.
  1. Drop all observations not included in your interval of interest, say not included in 1970-1990;
   drop if yr<70 | yr>90 
  1. Compute the Hill estimator for this pooled sample.
   gsort -Y  
gen Yratio=Y/Y[11]
drop if Y<Y[10]
gen a=log(Yratio)
egen b=sum(a)
scalar alpha=(b/10)^(-1)
scalar list
     alpha =  9.4789316

Denominator \({\hat{\alpha}_{n_{t}}}\):

  1. Open the original data set;
   infile id  yr  phd  sex  rphd  ru  y  Y  s  using  "phuzics10.txt", clear
drop if id==.
  1. Drop all observations not included in your interval of interest:
   drop if yr<70 | yr>90 
  1. Get the sample size of the respective year of interest;
   sort yr 
by yr: sum Y
  1. Generate a bootstrapped sample (with replacement) of the same size of the year you are working with. For example, because 1970 has 11 observations, you type
   bsample[11]

this will generate a bootstrapped sample with 11 observations drawn from the pooled sample.

  1. Calculate the Hill estimator for this bootstrapped sample.
   gsort -Y  
gen Yratio=Y/Y[11]
drop if Y<Y[10]
gen a=log(Yratio)
egen b=sum(a)
scalar alpha=(b/10)^(-1)
scalar list
This routine will give you one bootstrapped alpha for the year 1970. You need to repeat the experiment "B" times (say, 20 times), and get "B" (say, 20) different bootstrapped alphas for 1970. After that, take the average of those "B" (say, 20) alphas and use this number as the denominator of the formula on page 2 of Prof. Koenker's "Appendix A - Concentration of Productivity in Phuzics Scholarship".

Finally, you need to apply the formula: multiply the original Hill estimator of 1970 by the pooled Hill estimator (here called "numerator") and divide it by the average bootstrapped estimator for 1970 (here called "denominator"), so that you find a bias-corrected Hill estimator for the year 1970.

This procedure is required for every year in the period 1970-1990. Each year will have its respective  corrected alpha. The final step is to plot those corrected alphas along time, and check if there is any trend. 

Lorenz Curves and Gini Coefficient

STATA provides add-ins to calculate these statistics. You can type 

   help lorenz
help glcurve

This will provide a menu of add-in programs related to the topic. You need to install the selected package and the help files. You are free to decide whether to use add-ins or to write your own code. The most important thing, though, is to understand the theoretical background of such measures, which we will discuss in class.


  1. Please send comments to bottan2@illinois.edu or srmntbr2@illinois.edu