I wanted to ensure that xtdidregress was consistent with the "old-fashioned" way of running differences in differences. To do this, I generated a simulated dataset and ran some regressions (see code).
I started by verifying that `reg` and `reghdfe` produced consistent results. To my surprise, in this toy dataset, xtdidregress wouldn't run due to collinearity, even when I included the `nogteffects` option (so that there should be nothing to be co-linear with)!
What am I doing wrong?
I started by verifying that `reg` and `reghdfe` produced consistent results. To my surprise, in this toy dataset, xtdidregress wouldn't run due to collinearity, even when I included the `nogteffects` option (so that there should be nothing to be co-linear with)!
What am I doing wrong?
Code:
clear *
set seed 1234
local N 50
set obs `N'
gen id = _n
gen x = rnormal()
expand 2, gen(t)
label val t
* y is independent of x for t = 0
* y is related to x at t = 1
gen y = rnormal() + (t==1) * x
xtset id t
estimates clear
eststo: reghdfe y c.x##i.t, a(t id)
eststo: reg D.y x
esttab *, keep(1.t#c.x x)
* STATA complains about collinearity
xtdidregress (y) (x, continuous), group(id) time(t) nogteffects
/*
model is not identified
The treatment variable x was omitted because of collinearity.
*/
* Issue isn't with the continuous treatment
egen x_bin = cut(x), group(2)
xtdidregress (y) (x_bin), group(id) time(t) nogteffects

Comment