sergiocorreia/reghdfe

Predict residual outside e(sample)

Opened this issue · 0 comments

Feature request

Is your feature request related to a problem? Please describe.

Is there any method to predict the residuals outside e(sample)?

Describe the solution you'd like

Hi Sergio,
I am estimating a regression model with individual FE and year FE. The regression is controlled for some polynomial age trends because age is an important factor in the outcomes. Since the treatment is perfectly collinear with age, I estimate the effect in two steps as follow:

reghdfe outcome age_controls if treated!=1, a(id year) cl(birth_cohort) resid
predict residual, res
reg residual treated, r

However, predict does not predict for those treated==1. I've tried to force it to predict residuals for the treated observations by adding if !e(sample) but in vain. Is there any method to make it predict residuals for the observations excluded? I read some previous discussions about this issue, but I think my case is a little bit different. In my case, each individual is not treated in some years, and each year some individuals are not treated. No new FEs need to be estimated.

Regards,
SW