I want to remove the year of the event from the coefficient plots of my event study. In my setting there are variation in treatment timing, with a treatment unit which is a county can be treated at any point in the sample period (1990-2018). I am not sure if I am doing it right in the code below and hence it would be great to receive some feedback:
xtset fips year
forvalues i = 1/10 {
by fips (year), sort: gen Hurr_Surface`i' = L`i'.vmax_sust // creating lags
}
forvalues i = 0/10 {
by fips (year), sort: gen Hurr_Lead`i' = F`i'.vmax_sust // creating leads
}
by fips (year), sort: gen MajLag1 = inrange(Hurr_Surface1, 48, 299)
by fips (year), sort: gen MajLag2 = inrange(Hurr_Surface2, 48, 299)
by fips (year), sort: gen MajLag3 = inrange(Hurr_Surface3, 48, 299)
by fips (year), sort: gen MajLag4 = inrange(Hurr_Surface4, 48, 299)
by fips (year), sort: gen MajLag5 = inrange(Hurr_Surface5, 48, 299)
by fips (year), sort: gen MajLag6 = inrange(Hurr_Surface6, 48, 299)
************************************************** ****************************
by fips (year), sort: gen MajLead0 = inrange(Hurr_Lead0, 48, 299)
by fips (year), sort: gen MajLead1 = inrange(Hurr_Lead1, 48, 299)
by fips (year), sort: gen MajLead2 = inrange(Hurr_Lead2, 48, 299)
by fips (year), sort: gen MajLead3 = inrange(Hurr_Lead3, 48, 299)
by fips (year), sort: gen MajLead4 = inrange(Hurr_Lead4, 48, 299)
by fips (year), sort: gen MajLead5 = inrange(Hurr_Lead5, 48, 299)
by fips (year), sort: gen MajLead6 = inrange(Hurr_Lead6, 48, 299)
local i = 1
foreach dep_var in `dep_vars' {
qui xtreg `dep_var' `treat_vars' , fe vce(cluster fips)
estimates store Wage_Reg`i'
local i = `i' + 1
}
coefplot (Wage_Reg1, label("Poverty Percentage") pstyle(p4)) ///
, vertical drop(_cons) yline(0) msize(1) msymbol(D) byopts(yrescale xrescale row(2)) ///
coeflabels(MajLead0 = "0" ///
MajLag1 = " 1" ///
MajLag2 = " 2" ///
MajLag3 = " 3" ///
MajLag4 = " 4" ///
MajLag5 = " 5" ///
MajLag6 = " 6" ///
MajLead1 = " -1" ///
MajLead2 = " -2" ///
MajLead3 = " -3" ///
MajLead4 = " -4" ///
MajLead5 = " -5" ///
MajLead6 = " -6") ///
legend(off) xlabel(, angle(45)) xtitle({stSerif: Years}, size(3) color(gs5)) ///
ylabel(, angle(45)) ytitle({stSerif: Coefficient }, size(3) color(gs5)) ///
subtitle(, size(3) margin(none) justification(center) color(gs5) bcolor(white) bmargin(top_bottom))
xtset fips year
forvalues i = 1/10 {
by fips (year), sort: gen Hurr_Surface`i' = L`i'.vmax_sust // creating lags
}
forvalues i = 0/10 {
by fips (year), sort: gen Hurr_Lead`i' = F`i'.vmax_sust // creating leads
}
by fips (year), sort: gen MajLag1 = inrange(Hurr_Surface1, 48, 299)
by fips (year), sort: gen MajLag2 = inrange(Hurr_Surface2, 48, 299)
by fips (year), sort: gen MajLag3 = inrange(Hurr_Surface3, 48, 299)
by fips (year), sort: gen MajLag4 = inrange(Hurr_Surface4, 48, 299)
by fips (year), sort: gen MajLag5 = inrange(Hurr_Surface5, 48, 299)
by fips (year), sort: gen MajLag6 = inrange(Hurr_Surface6, 48, 299)
************************************************** ****************************
by fips (year), sort: gen MajLead0 = inrange(Hurr_Lead0, 48, 299)
by fips (year), sort: gen MajLead1 = inrange(Hurr_Lead1, 48, 299)
by fips (year), sort: gen MajLead2 = inrange(Hurr_Lead2, 48, 299)
by fips (year), sort: gen MajLead3 = inrange(Hurr_Lead3, 48, 299)
by fips (year), sort: gen MajLead4 = inrange(Hurr_Lead4, 48, 299)
by fips (year), sort: gen MajLead5 = inrange(Hurr_Lead5, 48, 299)
by fips (year), sort: gen MajLead6 = inrange(Hurr_Lead6, 48, 299)
local i = 1
foreach dep_var in `dep_vars' {
qui xtreg `dep_var' `treat_vars' , fe vce(cluster fips)
estimates store Wage_Reg`i'
local i = `i' + 1
}
coefplot (Wage_Reg1, label("Poverty Percentage") pstyle(p4)) ///
, vertical drop(_cons) yline(0) msize(1) msymbol(D) byopts(yrescale xrescale row(2)) ///
coeflabels(MajLead0 = "0" ///
MajLag1 = " 1" ///
MajLag2 = " 2" ///
MajLag3 = " 3" ///
MajLag4 = " 4" ///
MajLag5 = " 5" ///
MajLag6 = " 6" ///
MajLead1 = " -1" ///
MajLead2 = " -2" ///
MajLead3 = " -3" ///
MajLead4 = " -4" ///
MajLead5 = " -5" ///
MajLead6 = " -6") ///
legend(off) xlabel(, angle(45)) xtitle({stSerif: Years}, size(3) color(gs5)) ///
ylabel(, angle(45)) ytitle({stSerif: Coefficient }, size(3) color(gs5)) ///
subtitle(, size(3) margin(none) justification(center) color(gs5) bcolor(white) bmargin(top_bottom))