***
*** Example 3.5. Lorenz curves for South Africa (Figure 3.5)
***
*** The code shows how to calculate the cumulative fractions of
*** population and of PCE and uses the results to draw the standard
*** Lorenz curves.
***
*** 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 lorenz, replace;

cap program drop lc;
program def lc;
drop _all;
/* data saved from code in Ex3.4 above */
use sastats;
drop if pce==.;
if `1' > 0 {; keep if race==`1';};
sort pce;
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) border;
gen rcode=`1';
keep cumpce cumpop rcode;
if `1' > 0 {; append using temp; };
save temp, replace;
end;

lc 0;
lc 1;
lc 4;
drop _all;
use temp;

gen cumpce0=cumpce if rcode==0;
gen cumpce1=cumpce if rcode==1;
gen cumpce4=cumpce if rcode==4;
drop cumpce;
graph cumpce* cumpop cumpop,
c(llll) 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(lorenz, replace) border;
log close;


[Return to Program List]