Hello all,
I am new to Stata. This is my first post on this forum and I apologize in case I am doing anything wrong. I am currently working with a difference-in-differences model with two-way fixed effects.This is my code:
xtset unitid year
xtreg outcome treatment f.treatment i.year i.unitid##c.year control1, fe cluster(unitid)
To avoid any bias from pretreatment trends, I would also like to calculate residuals from a regression of demeaned variables for all units and years, and then estimate the model using those residualized variables. I am, however, not entirely sure how to go about this. This is what I have:
xtset unitid year
xtreg outcome treatment f.treatment i.year i.unitid##c.year control1, fe cluster(unitid)
predict pred_outcome
predict resid_outcome, residuals
xtreg resid_outcome treatment f.treatment i.year i.unitid##c.year control1, fe cluster(unitid)
But I do not know if it is correct and I would appreciate your input.
R.G.
I am new to Stata. This is my first post on this forum and I apologize in case I am doing anything wrong. I am currently working with a difference-in-differences model with two-way fixed effects.This is my code:
xtset unitid year
xtreg outcome treatment f.treatment i.year i.unitid##c.year control1, fe cluster(unitid)
To avoid any bias from pretreatment trends, I would also like to calculate residuals from a regression of demeaned variables for all units and years, and then estimate the model using those residualized variables. I am, however, not entirely sure how to go about this. This is what I have:
xtset unitid year
xtreg outcome treatment f.treatment i.year i.unitid##c.year control1, fe cluster(unitid)
predict pred_outcome
predict resid_outcome, residuals
xtreg resid_outcome treatment f.treatment i.year i.unitid##c.year control1, fe cluster(unitid)
But I do not know if it is correct and I would appreciate your input.

R.G.