Reputation: 1721
I am running a fixed effect model using Stata, and then performing out of sample predictions. But seems
xtreg
followed by
predict yhat, xbu
does not predict out-of-sample along with the fixed effects. Is there a way to use xtreg for out of sample by including the fixed effect? Illustration:
webuse nlswork
xtset idcode year
regress ln_wage age if year <= 80
predict temp1
xtreg ln_wage age if year <= 80, fe
predict temp2, xbu
For my case, I need to predict values for year = 81. And temp2 is empty for years > 80. Reading the manuals for xtreg, and also for areg, seems like out of sample predictions are not possible especially with xbu -- which includes fixed effect predictions. It is understandable that if I used the year fixed effect it does not make sense, but if I just used idcode it should be possible? Any advice would be deeply appreciated. Or any advice on how I can get the solution for it?
It seems to to generate only for all years <= 2000. That is I am able to generate predictions only for in sample.
Upvotes: 1
Views: 5490
Reputation: 9460
You can extend the FE out of sample since it is time invariant and then add it to the rest of the prediction, which is available out of sample:
capture ssc install carryforward
xtreg ln_wage age if year <= 80, fe
predict xb_plus_a, xb
predict fe, u
carryforward fe, replace
gen yhat2 = xb_plus_a + fe
Upvotes: 5