I am trying to create a event study plot that give me yearly average treatment effects on the treated on a business law on the average number of property firms relative to a control state where the business law is not in effect. Where am I going wrong with my code?
xtset county_id year
gen post = year >= sbdcopen
gen treated_post = treated * post
* Run the fixed-effects regression
xtreg prop_firms treated_post##c.year, fe
* Store the estimated coefficients
estimates store event_study
* Generate variable for the difference from mean
matrix mean_b = e(b)
gen diff_from_mean = prop_firms - mean_b[1, 1]
* Create coefplot for the event study
coefplot (diff_from_mean, label("Excess Prop Firms")) ///
xline(0) ylabel("Difference from Mean") ///
xlabel("Year relative to treatment") ///
title("Event Study: Excess Prop Firms Over Time")
estimation result diff_from_mean not found
You have more control on the event study plot if you generate dummies for treated units for each year yourself. See example below:
In this example, the treatment happens in 2010 (shown as
xline(4)) and I replace the first pre-treatment period (2008) by aconstantin order to avoid losing this in the coefplot.Edit: variable names