Dear all,
I am comparing the fitted values obtained from reg and reghdfe (ssc install reghdfe). Following the approach described in https://www.statalist.org/forums/for...-after-reghdfe, I find that the fitted values from reg and from reghdfe are almost identical but not exactly the same.
My first question is: are these differences simply due to numerical precision issues?
Next, I would like to compute extrapolation fitted values in a similar way. I estimate the model using the sample with gear_ratio < 3, and then calculate the fitted values for the observations with gear_ratio ≥ 3 based on that estimation. With reg, it is straightforward to obtain the extrapolated fitted values, but reghdfe does not seem to allow this—likely because it has already absorbed the fixed effects.
So my second question is: is there a way to use reghdfe to obtain extrapolation fitted values in the same way as reg?
I am comparing the fitted values obtained from reg and reghdfe (ssc install reghdfe). Following the approach described in https://www.statalist.org/forums/for...-after-reghdfe, I find that the fitted values from reg and from reghdfe are almost identical but not exactly the same.
Code:
************************************************************************************ ** reg and reghdfe fitted value comparison ************************************************************************************ // no extrapolation // with singleton sysuse auto, clear bysort rep78: drop if rep78==4 & _n>1 // force rep78 == 4 to be singleton * reg reg price weight length i.rep78 predict reg_fit_singleton, xb * reghdfe reghdfe price weight length, absorb(rep78) nocons res predict reghdfe_fit_singleton, xbd drop *resid * reghdfe + keepsingletons reghdfe price weight length, absorb(rep78) nocons res keepsingletons predict reghdfe_fit_singleton_keep, xbd drop *resid
Next, I would like to compute extrapolation fitted values in a similar way. I estimate the model using the sample with gear_ratio < 3, and then calculate the fitted values for the observations with gear_ratio ≥ 3 based on that estimation. With reg, it is straightforward to obtain the extrapolated fitted values, but reghdfe does not seem to allow this—likely because it has already absorbed the fixed effects.
Code:
************************************************************************************ ** reg and reghdfe fitted value "Extrapolation" comparison ************************************************************************************ // extrapolation // with singleton sysuse auto, clear bysort rep78: drop if rep78==4 & _n>1 // force rep78 == 4 to be singleton * reg reg price weight length i.rep78 if gear_ratio < 3 predict reg_fit if gear_ratio >= 3, xb * reghdfe + keepsingletons reghdfe price weight length if gear_ratio < 3, absorb(rep78) nocons res keepsingletons predict reghdfe_fit if gear_ratio >= 3, xbd drop *resid
Comment