Hello everyone,
I’m running a stacked event-study using reghdfe in Stata, and I’ve encountered an unexpected issue that I’d like to understand better.
First, this is how I generate my stack for each treatment year :
* Save dataset in memory, so we can call this function multiple times.
preserve
* Determine earliest and latest time in the data.
* Used for feasibility check later
sum `timeID'
local minTime = r(min)
local maxTime = r(max)
*variable to label sub-experiment if treated in focalAdoptionTime,
gen sub_exp = `focalAdoptionTime' if `adoptionTime' == `focalAdoptionTime'
*Now fill in this variable for states with adoptionTime > focalAdoptionTime + kappa_post
*Include only never treated
replace sub_exp = `focalAdoptionTime' if never_treat == 1
*note, this will include never treated, because adopt_year is ., which stata counts as infinity
*replace sub_exp = `focalAdoptionTime' if `adoptionTime' > `focalAdoptionTime' + `kappa_post'
*Keep only treated and clean controls
keep if sub_exp != .
*gen treat variable in subexperiment
gen treat = `adoptionTime' == `focalAdoptionTime'
*gen event_time and
gen event_time = year - sub_exp
*gen post variable
gen post = event_time >= 0
*trim based on kappa's: -kappa_pre < event_time < kappa_post
keep if inrange(event_time, -`kappa_pre', `kappa_post')
*keep if event_time >= -`kappa_pre' & event_time <= `kappa_post'
gen feasible = 0
replace feasible = 1 if !missing(`adoptionTime')
replace feasible = 0 if `adoptionTime' < `minTime' + `kappa_pre'
replace feasible = 0 if `adoptionTime' > `maxTime' - `kappa_post'
drop if `adoptionTime' < `minTime' + `kappa_pre'
* Save dataset
compress
save "subexp`focalAdoptionTime'", replace
restore
When I estimate my model over the window [–3,+2], I get positive post-treatment coefficients.
However, when I extend the window to [–3,+3], the coefficients for +1 and +2 become much smaller and negative — even though the treated and control groups are identical across both samples.
To make sure the change wasn’t due to sample composition, I:
My interpretation is that adding those +3 observations shifts the within-stack means absorbed by sub_exp#event_time, which in turn re-centers all the other coefficients. Even though I extend the time window, I should not except my coefficient for time 1 and 2 to be so different.
Has anyone experienced something similar?
I’m running a stacked event-study using reghdfe in Stata, and I’ve encountered an unexpected issue that I’d like to understand better.
First, this is how I generate my stack for each treatment year :
* Save dataset in memory, so we can call this function multiple times.
preserve
* Determine earliest and latest time in the data.
* Used for feasibility check later
sum `timeID'
local minTime = r(min)
local maxTime = r(max)
*variable to label sub-experiment if treated in focalAdoptionTime,
gen sub_exp = `focalAdoptionTime' if `adoptionTime' == `focalAdoptionTime'
*Now fill in this variable for states with adoptionTime > focalAdoptionTime + kappa_post
*Include only never treated
replace sub_exp = `focalAdoptionTime' if never_treat == 1
*note, this will include never treated, because adopt_year is ., which stata counts as infinity
*replace sub_exp = `focalAdoptionTime' if `adoptionTime' > `focalAdoptionTime' + `kappa_post'
*Keep only treated and clean controls
keep if sub_exp != .
*gen treat variable in subexperiment
gen treat = `adoptionTime' == `focalAdoptionTime'
*gen event_time and
gen event_time = year - sub_exp
*gen post variable
gen post = event_time >= 0
*trim based on kappa's: -kappa_pre < event_time < kappa_post
keep if inrange(event_time, -`kappa_pre', `kappa_post')
*keep if event_time >= -`kappa_pre' & event_time <= `kappa_post'
gen feasible = 0
replace feasible = 1 if !missing(`adoptionTime')
replace feasible = 0 if `adoptionTime' < `minTime' + `kappa_pre'
replace feasible = 0 if `adoptionTime' > `maxTime' - `kappa_post'
drop if `adoptionTime' < `minTime' + `kappa_pre'
* Save dataset
compress
save "subexp`focalAdoptionTime'", replace
restore
When I estimate my model over the window [–3,+2], I get positive post-treatment coefficients.
However, when I extend the window to [–3,+3], the coefficients for +1 and +2 become much smaller and negative — even though the treated and control groups are identical across both samples.
To make sure the change wasn’t due to sample composition, I:
- Fixed the treated group (same departments in both windows).
- Used only never-treated units as controls.
- I also verified that the number of observations is identical across windows for each window. The only two exception are two stacks (2016 and 2019) gain extra observations (only for that time) at event_time == 3.
My interpretation is that adding those +3 observations shifts the within-stack means absorbed by sub_exp#event_time, which in turn re-centers all the other coefficients. Even though I extend the time window, I should not except my coefficient for time 1 and 2 to be so different.
Has anyone experienced something similar?
