***
*** Example 3.6. Transformed Lorenz curves for Côte d'Ivoire (Figure 3.6)
***
*** This example adapts the code for the standard Lorenz curves 
*** so as to plot the distance between the Lorenz curve and the 
*** 45-degree line.
*** 
*** Note: The following provides the STATA code used to produce 
*** results used in "The Analysis of Household Surveys: 
*** A Microeconometric Approach to Development Policy", by Angus Deaton.
*** This book, published for the World Bank by The Johns Hopkins University
*** Press and scheduled for release in 1997.
***
version 4.0
#delimit ;
drop _all;
cap log close;
log using lorenzic, replace; 
cap program drop lcic;
program def lcic;
drop _all;
use cdi85_88;
drop if pce==.;
if `1' > 0 {; keep if year==`1';};
sort pce;
gen wt=hhs*allwaitn;
gen cumpop=sum(wt);
gen cumpce=sum(pce); 
qui summ wt;
replace cumpop=cumpop/(_result(1)*_result(3));
qui summ pce;
replace cumpce=cumpce/(_result(1)*_result(3));
local gg=int(_N/100);
keep if ((`gg'*int(_n/`gg')-_n)==0)|_n==1|_n==_N;
sort pce;
graph cumpce cumpop cumpop,
c(ll) s(..) xlabel(0,0.2,0.4,0.6,0.8,1.0)
ylabel(0, 0.2,0.4,0.6,0.8,1.0);
gen ycode=`1';
keep cumpce cumpop ycode;
if `1' > 1985 {; append using temp; };
save temp, replace;
end; 
lcic 1985;
lcic 1986;
lcic 1987;
lcic 1988;
drop _all;
use temp; 
gen cumpce5=cumpce if ycode==1985;
gen cumpce6=cumpce if ycode==1986;
gen cumpce7=cumpce if ycode==1987;
gen cumpce8=cumpce if ycode==1988;
drop cumpce;
graph cumpce* cumpop cumpop,
c(lllll) s(.....) xlabel(0,0.2,0.4,0.6,0.8,1.0)
ylabel(0, 0.2,0.4,0.6,0.8,1.0) saving(lorenzic, replace);
/* defining the complementary lorenz curves as graphed */
gen compce5=cumpop-cumpce5;
gen compce6=cumpop-cumpce6;
gen compce7=cumpop-cumpce7;
gen compce8=cumpop-cumpce8;
graph compce* cumpop, c(lllll) s(.....) xlabel(0,0.2,0.4,0.6,0.8,1.0)
ylabel(0, 0.1,0.2,0.3,0.4) saving(complc,replace); 
log close;

[Return to Program List]