borusyak / did_imputation

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

Event plots for effect heterogeneity analysis #22

Open orectique opened 2 months ago

orectique commented 2 months ago

Hi Kirill,

Hoping to get some clarity in generating event plots for effect heterogeneity analysis.

For example if I ran did_imputation with hetby(male) and I had my estimates in the form tau#_0 and tau#_1, how would I then plot the two groups of estimates separately in the same event_plot graphic?

Thanks in advance for your guidance.

orectique commented 2 months ago

My current solution is in the following form:

did_imputation Y i t Ei, hetby(bin_var) [options]

estimates store coefs

event_plots coefs ., stub_lag(tau#_0 tau#_1) plottype(scatter)

This gives me something quite close to what I would like - only, the lead values are duplicated.

Furthermore, would I be able to specify the bin_var category in the legend?

borusyak commented 2 months ago

Hi, The leads are not duplicated in the figure: they are actually estimated on the full sample. You can run any pre-trend test you like, such as on separate subsamples. The command doesn't currently do that but it's just an OLS regression on untreated sample. Notice however, that estimation with hetby() assumes that the trends are the same in both groups, unless you include period FEs interacted with the group.

For the legend, I recommend you use the reportcommand option to see what event_plot is doing and which legend_opt() to add.