*Commands to solve the computer based excercises on unidimensional inequality and poverty*

*You will need to put your folder to work in in the line of cd*

********************************************************

*Whenever you want to break the program write log close exit

*after the last command you want Stata to perform

*Another way to make it not execute a specific command is to put a star

*at the beggining, then it reads it as text

*Take the start out when you want it to perform a command

********************************************************

clear

cap log close

log using introstata.log, replace

cd "c:\Documents and Settings\sabina\Desktop\Summer School"

set memory 256m

set more off

set memory 256m

use Half_Sample_Bhutan.dta

sum pce_real

sum pce_real [iw=weight]

sort area

by area: sum pce_real

**********************

*Using DASP

**********************

svyset houseid

clorenz pce_real, type(gen)

clorenz pce_real, hgroup(area) type(gen)

clorenz pce_real, hgroup(area) type(nor)

keep if dcode==15 | dcode==26

clorenz pce_real, hgroup(area) type(nor)

clorenz pce_real, hgroup(dcode) type(nor)

******************************

*I return to the overall sample

******************************

*clear

*use Half_Sample_Bhutan.dta

*svyset houseid

*Overall

*igini pce_real

*ientropy pce_real, theta(-1)

*ientropy pce_real, theta(1)

*ientropy pce_real, theta(0)

*ientropy pce_real, theta(2)

*Gini by region

*igini pce_real, hgroup(area)

*ientropy pce_real, theta(-1) hgroup(area)

*ientropy pce_real, theta(1) hgroup(area)

*ientropy pce_real, theta(0) hgroup(area)

*ientropy pce_real, theta(2) hgroup(area)

*keep if dcode==15 | dcode==26

*igini pce_real, hgroup(dcode)

*ientropy pce_real, theta(-1) hgroup(dcode)

*ientropy pce_real, theta(1) hgroup(dcode)

*ientropy pce_real, theta(0) hgroup(dcode)

*ientropy pce_real, theta(2) hgroup(dcode)

*******************************

*Poverty

*******************************

ifgt pce_real, alpha(0) pline(1096.94)

ifgt pce_real, alpha(1) pline(1096.94)

ifgt pce_real, alpha(2) pline(1096.94)

*by area

ifgt pce_real, alpha(0) hgroup(area) pline(1096.94)

ifgt pce_real, alpha(1) hgroup(area) pline(1096.94)

ifgt pce_real, alpha(2) hgroup(area) pline(1096.94)

*by district

ifgt pce_real, alpha(0) hgroup(dcode) pline(1096.94)

ifgt pce_real, alpha(1) hgroup(dcode) pline(1096.94)

ifgt pce_real, alpha(2) hgroup(dcode) pline(1096.94)

*decomposition of fgt*

dfgtg pce_real, hgroup(area) alpha(2) pline(1096.94)

******************************

*Using the inequal commands

******************************

*glcurve pce_real, pvar(perpop) glvar(perinc) replace

*glcurve pce_real, pvar(perpop) glvar(perinc) by(area) split replace

*glcurve pce_real, lorenz pvar(perpop) glvar(perinc) by(area) split replace

*glcurve pce_real if (dcode==15 | dcode==26), lorenz pvar(perpop) glvar(perinc) by(dcode) split replace

*glcurve pce_real if (dcode==15 | dcode==26), pvar(perpop) glvar(perinc) by(dcode) split replace

ainequal pce_real, alpha(-1) epsilon(2 1.5 1) all

ainequal pce_real if area==1, alpha(-1) epsilon(2 1.5 1) all

ainequal pce_real if area==2, alpha(-1) epsilon(2 1.5 1) all

ainequal pce_real if dcode==15, alpha(-1) epsilon(2 1.5 1) all

ainequal pce_real if dcode==26, alpha(-1) epsilon(2 1.5 1) all

*To calculate the inequality between ruban and rural you need to generate

*a veriable that contains the mean income of each area

mean pce_real, over(area)

matrix define MEAN=e(b)

matrix list MEAN

gen Mean=MEAN[1,1]

replace Mean=MEAN[1,2] if area==2

ainequal Mean, all

**************************

*Poverty Measures

**************************

poverty pce_real, line(1096.94) h igr fgt3 w s chu2 chu3 chu5

poverty pce_real if area==1, line(1096.94) h igr fgt3 w s chu2 chu3 chu5

poverty pce_real if area==2, line(1096.94) h igr fgt3 w s chu2 chu3 chu5

poverty pce_real if dcode==15, line(1096.94) h igr fgt3 w s chu2 chu3 chu5

poverty pce_real if dcode==26, line(1096.94) h igr fgt3 w s chu2 chu3 chu5

ainequal pce_real if poor==1, all

log close

exit