-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCode(1).do
More file actions
237 lines (138 loc) · 4.71 KB
/
Code(1).do
File metadata and controls
237 lines (138 loc) · 4.71 KB
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
**Unit root test
varsoc gap
varsoc IGP
varsoc taxgdp
dfuller gap, lags(2)
dfuller IGP, lags(3)
dfuller taxgdp, lags(1)
***Starting the estimations
clear
import excel "C:\Users\Marina Sanches\OneDrive\Made\Submissao JODS\Data.xlsx", sheet("Total") firstrow
drop if Ano==.
tset Ano
gen ly = log(gdp)
**gen ly = log(employment)
gen difigp=d.IGP
gen diftaxgdp=d.taxgdp
// set estimation window & clean control window
local post_window 10
local pre_window 10
local postobs = `pre_window' +1
local preobs = `pre_window' + `post_window'
local cc_window 5
// compute long differences in the outcome
forval j = 0/`post_window' {
qui gen D`j'y = F`j'.ly - L.ly
}
forval j = 1/`pre_window' {
qui gen Dm`j'y = L`j'.ly - L.ly
}
*
g ftreatment=progressiveneutral
g treatment=l1.ftreatment
*For the Appendix:
*g ftreatment=regressive
*g ftreatment=progressive
gen trend = _n
// compute clean control indicators
forv i = 1/`cc_window' {
gen l`i'_ftreatment = l`i'.ftreatment
replace l`i'_ftreatment =0 if l`i'_ftreatment ==.
replace l`i'_ftreatment=abs(l`i'_ftreatment)
}
forv i = 1/`post_window' {
gen f`i'_ftreatment = f`i'.ftreatment
replace f`i'_ftreatment = 0 if f`i'_ftreatment ==.
replace f`i'_ftreatment = abs(f`i'_ftreatment)
}
sum l`cc_window'_ftreatment
egen unclean_lags = rowtotal(l1_ftreatment-l`cc_window'_ftreatment)
gen unclean_leads_1 = f1_ftreatment
forv i=2/`post_window' {
egen unclean_leads_`i' = rowtotal(f1_ftreatment-f`i'_ftreatment)
}
gen CC_0 = 0
replace CC_0 = 1 if ftreatment==0 & unclean_lags==0
forv i=1/`post_window' {
gen CC_`i' = 0
replace CC_`i' = 1 if ftreatment==0 & unclean_lags==0 & unclean_leads_`i'==0
}
// gen event time variable
gen event_time=_n-`postobs' if _n-1<=`preobs'
// Check how many clean treated and clean controls we have
count if ftreatment==1
count if ftreatment==1 & unclean_lags==0
tab unclean_lags
tab CC_0
*tab CC_5
*tab CC_10
*tab CC_15
// calculating the impact and confidence intervals
cap drop b u_90 d_90 u_sd d_sd
gen b = 0
gen u_90 = 0
gen d_90 = 0
gen u_sd = 0
gen d_sd = 0
forv k = 0/`post_window' {
// years after
reghdfe D`k'y ftreatment l(1/4).ftreatment l(1/4).ly difigp gap, vce(robust)
lincom ftreatment
replace b = r(estimate) if event_time == `k'
replace u_90 = b + 1.645 * r(se) if event_time == `k'
replace d_90 = b - 1.645 * r(se) if event_time == `k'
replace u_sd = b + r(se) if event_time == `k'
replace d_sd = b - r(se) if event_time == `k'
// years before
if `k' >= 1 & `k' <= `pre_window' {
reghdfe Dm`k'y ftreatment l(1/4).ftreatment l(1/4).ly difigp gap, vce(robust)
lincom ftreatment
replace b = r(estimate) if event_time == -`k'
replace u_90 = b + 1.645 * r(se) if event_time == -`k'
replace d_90 = b - 1.645 * r(se) if event_time == -`k'
replace u_sd = b + r(se) if event_time == -`k'
replace d_sd = b - r(se) if event_time == -`k'
}
}
// Keeping only the necessary variables and creating a graph
preserve
keep if event_time ~= .
keep u_90 d_90 u_sd d_sd b event_time
twoway ///
rcap u_90 d_90 event_time, col(blue) || ///
rcap u_sd d_sd event_time, col(red) || ///
scatter b event_time, ms(O) mc(blue) ///
xtit("Years after the shock") ytit("Impact on GDP") ///
legend(order(1 "IC 90%" 2 "1 Standard Deviation" 3 "Estimative") ///
col(1) position(3) ring(0)) yline(0, lc(black)) ///
xlab(-10(2)10) scheme(plotplainblind) scale(1.5) title("")
restore
preserve
keep if event_time >= 0 & event_time <= 3 // Years between 0 and 3
keep u_90 d_90 u_sd d_sd b event_time // Only variables
twoway ///
(rarea u_90 d_90 event_time, color(gray%30) lcolor(gray)) ///
(rarea u_sd d_sd event_time, color(gray%40) lcolor(gray)) ///
(line b event_time, lcolor(black) lwidth(thick)) ///
, xlabel(0(1)3, labsize(small)) ///
ylabel(, labsize(small)) ///
xtitle("Years after the shock", size(medium)) ///
ytitle("Impact on GDP", size(medium)) ///
yline(0, lc(black) lwidth(thin) lpattern(solid)) ///
legend(off) ///
graphregion(color(white)) bgcolor(white) ///
title("", size(3))
restore
// Save the graphs
graph save "C:\Users\Marina Sanches\OneDrive\Made\narrativa\inflemp.gph", replace
**Graphs for the robustness tests
graph combine controllagemp.gph withoutemp.gph gapemp.gph inflemp.gph, cols(2) ysize(12) xsize(15)
graph combine 1lagemp.gph 2lagemp.gph 3lagemp.gph 5lagemp.gph, cols(2) ysize(12) xsize(15)
graph combine dummiesemp.gph trendemp.gph, cols(2) ysize(12) xsize(15)
**See results
preserve
keep if event_time >= 0 & event_time <= 3 //
keep u_90 d_90 u_sd d_sd b event_time //
//
list event_time b u_90 d_90 u_sd d_sd, noobs clean
restore