Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Creating Event Plots for Multiple treated units, Multiple time periods and Heterogenous treatments.

    I have a US county panel (T=30) where different counties are treated by varying intensities of natural disasters at different points in time.

    I generate the lags and leads manually and then use them in the regression. However, in the current procedure, I am unable to plot the null coefficient of the omitted period (t=-1) and also I am unable to get a horizontal/vertical line. Hence, it would be really helpful if someone can suggest a better piece of code.

    Also in an alternative treatment specification, I have a continuous treatment which denotes the Z score of the disaster intensity. Hence any suggestions to that front would also be quite helpful.

    ************************************************** ********************
    by fips (year), sort: gen MajLag0 = inrange(Hurr_Lag0, 48, 299)
    by fips (year), sort: gen MajLag1 = inrange(Hurr_Lag1, 48, 299)
    by fips (year), sort: gen MajLag2 = inrange(Hurr_Lag2, 48, 299)
    by fips (year), sort: gen MajLag3 = inrange(Hurr_Lag3, 48, 299)
    by fips (year), sort: gen MajLag4 = inrange(Hurr_Lag4, 48, 299)
    by fips (year), sort: gen MajLag5 = inrange(Hurr_Lag5, 48, 299)
    by fips (year), sort: gen MajLag6 = inrange(Hurr_Lag6, 48, 299)
    by fips (year), sort: gen MajLag7 = inrange(Hurr_Lag7, 48, 299)
    by fips (year), sort: gen MajLag8 = inrange(Hurr_Lag8, 48, 299)
    by fips (year), sort: gen MajLag9 = inrange(Hurr_Lag9, 48, 299)
    by fips (year), sort: gen MajLag10 = inrange(Hurr_Lag10, 48, 299)

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

    //by fips (year), sort: gen MajLead1 = 0 //drop t-1
    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)
    by fips (year), sort: gen MajLead7 = inrange(Hurr_Lead7, 48, 299)
    by fips (year), sort: gen MajLead8 = inrange(Hurr_Lead8, 48, 299)
    by fips (year), sort: gen MajLead9 = inrange(Hurr_Lead9, 48, 299)
    by fips (year), sort: gen MajLead10 = inrange(Hurr_Lead10, 48, 299)

    local treat_vars "MajLead6 MajLead5 MajLead4 MajLead3 MajLead2 MajLag0 MajLag1 MajLag2 MajLag3 MajLag4 MajLag5 MajLag6 " // Omitted MajLag1 (baseline t = -1)

    local dep_vars "Violent_Percap Property_Percap Total_Crime_Percap "

    local i = 1
    foreach dep_var in `dep_vars' {
    qui xtreg `dep_var' `treat_vars' i.year i.state_var##c.year, fe vce(cluster fips)
    estimates store Maj_Reg`i'
    local i = `i' + 1
    }

    coefplot (Maj_Reg1, label("Violent Crime") pstyle(p4) ) ///
    || (Maj_Reg2, label("Property Crime") pstyle(p4) ) ///
    , keep(MajLead* MajLag*) vertical ciopts(recast(rcap)) drop(_cons) yline(0) msize(1) msymbol(D) byopts(yrescale row(1)) ///
    coeflabels(MajLead6 = "-6" ///
    MajLead5 = "-5" ///
    MajLead4 = "-4" ///
    MajLead3 = "-3" ///
    MajLead2 = "-2" ///
    (0) = "-1" /// Manually set t = -1 as zero
    MajLag0 = "0" ///
    MajLag1 = "+1" ///This is t = 0 (current period)
    MajLag2 = "+2" ///
    MajLag3 = "+3" ///
    MajLag4 = "+4" ///
    MajLag5 = "+5" ///
    MajLag6 = "+6" ///
    ) ///
    legend(off) xlabel(, angle(45)) xtitle({stSerif: Year}, 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))
Working...
X