Open mcaceresb opened 7 months ago
FYI it's different each run and I'm not sure what's causing the sort order of the saved FEs to change. This also causes xbd
and resid
to change, if they are used.
@sergiocorreia Actually they're just wrong, sorry for the multiple messages:
clear
sysuse auto, clear
ivreghdfe price (mpg = turn), absorb(a1=rep78) cluster(rep78)
ivreghdfe price (mpg = turn), absorb(a2=rep78) cluster(rep78)
reghdfe mpg turn, absorb(rep78) resid
predict mpghat, xbd
reghdfe price mpghat, absorb(a3=rep78) cluster(rep78)
gen diff1 = reldif(a1, a3)
gen diff2 = reldif(a2, a3)
sum diff?
Variable | Obs Mean Std. Dev. Min Max
-------------+---------------------------------------------------------
diff1 | 74 93.00652 119.3723 0 300.4831
diff2 | 74 89.67282 112.5629 0 285.0808
For some reason, the problem is solved when pre-sorting by the fixed effects before the run:
sysuse auto, clear
sort rep78
ivreghdfe price turn, absorb(a1=rep78) cluster(rep78)
ivreghdfe price turn, absorb(a2=rep78) cluster(rep78)
reghdfe price turn, absorb(a3=rep78) cluster(rep78)
replace a3 = a3 + _b[_cons]
gen diff1 = reldif(a1, a3)
gen diff2 = reldif(a2, a3)
sum diff?
But need to delve a bit more into why the sorting gets broken.
gives