**specifying identifiers in excel
=if(B3=B2, A2, A2+1)
**Declaring Data Set as Panel Data
xtset code year
**Describe Data
describe
** major descriptives
sum gl
sum gl if countrynames == "Pakistan"
sum gl if region == "SA"
sum gl if inc_gr == "UIC"
sum gl if year == 2008
**descriptives in series form by individuals and groups
egen av_gl= mean(gl), by(code)
egen avig_gl= mean(gl), by(inc_gr)
egen avre_gl= mean(gl), by(region)
egen sd_gl= sd(gl), by(code)
egen sdig_gl= sd(gl), by(inc_gr)
egen sdre_gl= sd(gl), by(region)
** recoding/ generating categories from continuous variables
sum gl, detail
recode gl (min/39.999=1) (40/59.999=2) (60/72.999=3) (73/max=4), gen(glcat)
lab define glcatlabel1 1 "LG" 2 "LMG" 3 "UMG" 4 "HG"
label value glcat glcatlabel
tab glcat
** generating time and crossectional dummies
tab region, gen(reg_)
tab year, gen(yr_)
tab inc_gr, gen(inc_)
*to show the distribution of regions by income groups
tab inc_gr region, sum (gl)
tab inc_gr glcat, sum(gl)
tab region glcat, sum(gl)
** for average gl statistics on yearly basis
sort year
tab year inc_gr, sum(gl)
tab year region, sum(gl)
tab year glcat, sum(gl)
**taking descriptive to word
ssc install asdoc
asdoc tab year glcat, sum(gl)
** Graphical Representation of data
**Line Graph
xtline gl, t(year) i(countrynames) ytitle(Globalization, size(small)) xtitle(Year,
size(small)) title(Globalization, size(small))
xtline gl if inc_gr == "UIC" & region == "ECE", t(year) i(countrynames)
ytitle(Globalization, size(small)) xtitle(Year, size(small)) title(Globalization,
size(small))
xtline gl if inc_gr == "UIC" & region == "ECE", overlay t(year) i(countrynames)
ytitle(Globalization, size(small)) xtitle(Year, size(small))
**Bar Graph
collapse (mean) gl, by(countrynames inc_gr region)
sort gl
list in 1/10
list in 130/140
graph bar (mean) gl, over(inc_gr)
graph bar (mean) gl, over(inc_gr) by(region)
**Scatter Diagrams
collapse (mean) gl tourism, by(countrynames inc_gr region)
twoway (scatter gl tourism, sort mlabel ( countrynames ) mlabsize(vsmall)),
ytitle( Globalization, size(small)) xtitle(Tourism, size(small)) title(Full Sample,
size(medium small))
twoway (scatter gl tourism if region == "SA", sort mlabel ( countrynames )
mlabsize(vsmall)), ytitle( Globalization, size(small)) xtitle(Tourism, size(small))
title(South Asia, size(medium small))
twoway (scatter gl tourism if inc_gr == "UIC", sort mlabel ( countrynames )
mlabsize(vsmall)), ytitle( Globalization, size(small)) xtitle(Tourism, size(small))
title(Higher Income Countries, size(medium small))
twoway (scatter gl tourism if inc_gr == "UIC") (lfit gl tourism if inc_gr ==
"UIC" , sort mlabel ( countrynames ) mlabsize(vsmall)), ytitle( Globalization,
size(small)) xtitle(Tourism, size(small)) title(Higher Income Countries,
size(medium small))
**Box Plots
graph box gl, over(inc_gr)
graph box gl, by(inc_gr) over(region)
**Estimations
**Observing heterogeneities
bysort code: egen mean_tourism= mean(tourism)
twoway (scatter tourism code if code<=20, msymbol(circle_hollow)) || (connected
mean_tourism code if code<=20, msymbol(circle))
twoway (scatter tourism code if region=="EU", msymbol(circle_hollow)) ||
(connected mean_tourism code if region == "EU", msymbol(circle))
bysort year: egen mean_tourism1= mean(tourism)
twoway (scatter tourism year , msymbol(circle_hollow)) || (connected
mean_tourism1 year , msymbol(circle))
**Pooled OLS
regress tourism lgl
**Three ways to run fixed effect model
xi: regress tourism gl i.code
predict yhat
twoway connected yhat1-yhat14 gl || lfit tourism gl
** To know which country is significantly heterogenous
regress tourism gl
estimates store ols
xi: regress tourism gl i.code
estimates store ols_dum
estimates table ols ols_dum, star stats(N)
xtreg tourism gl, fe
areg tourism gl, absorb(code)
comparing all three
xtreg tourism gl, fe
estimates store fixed
regress tourism gl
estimates store ols
xi: regress tourism gl i.code
estimates store ols_dum
estimates table fixed ols ols_dum, star stats(r r2 N)
**testing for time fixed effect
xtreg tourism gl i.year, fe
testparm i.year
**testing forcross sectional effect
xi:reg touris gl i.code
testparm i.code
**Random effect
xtreg tourism gl,re
**Choosing between fixed and random
xtreg tourism gl, fe
estimates store fixed
xtreg tourism gl,re
estimates store random
hausman fixed random
**checking for hetero
xtreg tourism gl, fe
xttest3
xtreg tourism gl, fe vce(robust)