/
haiti-earthquake-gdp.do
132 lines (102 loc) · 4.16 KB
/
haiti-earthquake-gdp.do
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
********************************************************************
* Prepared for Gabor's Data Analysis
*
* Data Analysis for Business, Economics, and Policy
* by Gabor Bekes and Gabor Kezdi
* Cambridge University Press 2021
*
* gabors-data-analysis.com
*
* License: Free to share, modify and use for educational purposes.
* Not to be used for commercial purposes.
*
* Chapter 24
* CH24A Estimating the effect of the 2010 Haiti earthquake on GDP
* using the haiti-earthquake dataset
* version 0.9 2020-09-06
********************************************************************
* SETTING UP DIRECTORIES
* STEP 1: set working directory for da_case_studies.
* for example:
* cd "C:/Users/xy/Dropbox/gabors_data_analysis/da_case_studies"
* STEP 2: * Directory for data
* Option 1: run directory-setting do file
do set-data-directory.do
/* this is a one-line do file that should sit in
the working directory you have just set up
this do file has a global definition of your working directory
more details: gabors-data-analysis.com/howto-stata/ */
* Option 2: set directory directly here
* for example:
* global data_dir "C:/Users/xy/gabors_data_analysis/da_data_repo"
global data_in "$data_dir/haiti-earthquake/clean"
global work "ch24-haiti-earthquake-gdp"
cap mkdir "$work/output"
global output "$work/output"
cap mkdir "$work/temp"
global temp "$work/temp"
use "$data_in/haiti-earthquake-mod.dta", clear
*donor pool based on threshold calculations below: it is those countries with incomethreshold=1, and a balanced panel for all variables
gen dp=0
replace dp=1 if inlist(country, "Benin","Burkina Faso","Burundi" ,"Bangladesh" ,"Cambodia","Cameroon" )
replace dp=1 if inlist(country, "Kenya" ,"Kyrgyz Republic" ,"Liberia","Madagascar" ,"Mali","Moldova","Mozambique" )
replace dp=1 if inlist(country, "Nicaragua" ,"Nepal" ,"Rwanda","Senegal","Sierra Leone","Sudan","Tanzania","Togo","Uganda" )
replace dp=1 if country=="Haiti"
lab var dp "Country in donor pool"
keep if dp==1
sort country year
egen ccode = group(countrycode) if country!="Haiti"
replace ccode = ccode+1
replace ccode = 1 if country=="Haiti"
xtset ccode year
xtdes
compress
clear matrix
save "$work/haiti-earthquake-workfile.dta",replace
* time series in Haiti
line gdptb_us year if ccode==1, lw(thick) lc(navy*0.8) ///
xla(2004(2)2015, grid) yla(6(0.5)9, grid) ///
xline(2010, lp(dash) lc(gray)) ///
text(8 2009 "Earthquake") ///
graphregion(fcolor(white) ifcolor(none)) ///
plotregion(fcolor(white) ifcolor(white))
graph export "$output/ch24-figure-1-haiti-gdp-Stata.png", replace
* Haiti and synthetic control
synth gdptb_us cons exp imp gcf land pop inf gdppc_w ///
gdptb_us(2005) gdptb_us(2007) gdptb_us(2009) , ///
trunit(1) trperiod(2010) xperiod(2004(1)2009) nested ///
unitnames(country) keep("$temp/gdp-1")replace
use "$temp/gdp-1",replace
lab var _time "Year"
* total GDP in Haiti and synthetid control
* figure 24.2a
line _Y_treated _Y_synth _time, lw(vthick vthick) lc(navy*0.8 green*0.6) ///
xla(2004(2)2015, grid) yla(6(0.5)9, grid) ///
xline(2010, lp(dash) lc(gray)) ///
text(8 2009 "Earthquake") ///
text(9.1 2013 "Synthetic Haiti") text(7 2012 "Haiti") legend(off) ///
graphregion(fcolor(white) ifcolor(none)) ///
plotregion(fcolor(white) ifcolor(white)) ///
ytitle("Total GDP, constant USD, billion")
graph export "$output/ch24-figure-2a-haiti-gdp-synth-Stata.png", replace
* differenence in log total GDP
* figure 24.2b
gen lndiffY = ln(_Y_treated) - ln(_Y_synth)
line lndiffY _time, lw(vthick ) lc(navy*0.8) ///
xla(2004(2)2015, grid) yla(-0.2(0.05)0.05, grid) yline(0) ///
xline(2010, lp(dash) lc(gray)) ///
text(-0.17 2009 "Earthquake") ///
graphregion(fcolor(white) ifcolor(none)) ///
plotregion(fcolor(white) ifcolor(white)) ///
ytitle("Effect estimate, log of total GDP")
graph export "$output/ch24-figure-2b-haiti-gdp-synth-Stata.png", replace
****************************************************
* temporary stuff for textbook development
* for R - temp
use "$temp/gdp-1",replace
rename _Y_treated Ytreated
rename _Y_synthetic Ysynthetic
rename _time year
drop _W_Weight _Co_Number
keep if year<.
save "$temp\gdp-1-temp.dta",replace