borusyak / did_imputation

Event studies: robust and efficient estimation, testing, and plotting
GNU General Public License v3.0
160 stars 69 forks source link

Legend order in five_estimators_example.do #10

Closed Alalalalaki closed 1 year ago

Alalalalaki commented 1 year ago

Hi,

Thanks very much for the package.

I am new to Stata and I am trying to adopt the code in five_estimators_example.do. Everything goes well, except I am confused about the order of the legend. When I just use 1-5 (I don't have a true result), I find the final two labels have wrong symbols.

Code:

event_plot ols sa_b#sa_v bjs dcdh_b#dcdh_v cs, stub_lag(L#event L#event tau# Effect_# Tp#) stub_lead(F#event F#event pre# Placebo_# Tm#) plottype(scatter) ciplottype(rcap) together trimlead(`lead') trimlag(`lag') noautolegend graph_opt(title("`var'", size(medlarge)) xtitle("Periods since the event") ytitle("Average causal effect", angle(horizontal)) ysc(titlegap(`titlegap')) xlabel(-`lead'(1)`lag') ////
legend(order(1 "OLS" 3 "Sun-Abraham (2020)" 5 "Borusyak et al. (2021)" 2 "de Chaisemartin-D'Haultfoeuille (2020)" 4 "Callaway-Sant'Anna (2020)") rows(3) region(style(none)) size(small) ) yline(0, lcolor(grey)) ) ///
lag_opt1(msymbol(+) color(cranberry)) lag_ci_opt1(color(cranberry)) ///
lag_opt2(msymbol(O) color(purple)) lag_ci_opt2(color(purple)) ///
lag_opt3(msymbol(Dh) color(navy)) lag_ci_opt3(color(navy)) ///
lag_opt4(msymbol(Th) color(forest_green)) lag_ci_opt4(color(forest_green)) ///
lag_opt5(msymbol(Sh) color(dkorange)) lag_ci_opt5(color(dkorange));

Result: image

It this a problem of the legend order? I am totally confused that how do you pick the order numbers in the original do file.

borusyak commented 1 year ago

Hi, The helpfile for event_plot explains how the legend works.