Hi all,

I am trying to perform an over identification test on the following theoretic scenario. Say that I have a balanced panel where N = 208 and T=10. Let's call z = (z_1, z_2) the instrument matrix, x(NT,1) the endogenous being instrumented, w the other feature (NT, d_W). Now, according to Wooldridge et al. procedure, I would like to compute:

Code:
xtreg x z w i.Year, fe
predict double residuals, e
xtpoisson y x residuals w i.Year, fe
My aim is to test for over identifying restrictions in such scenario. One thing I thought is to manually compute the Hansen test:

1) estimate the entire procedure with all instruments;
2) save the residuals;
3) regress the residuals on the instruments alone (xtreg, fe ???)
4) Now N*R^2 would be Chi squared, but how to save N*R^2 from xtreg, fe? And how, in the case we manage to do it, to predict p-values?

As you can see the procedure lacks some steps. So, can you please either advice me on steps 3) and 4) or provide a more elegant (maybe a command or standard procedure) way to perform overidentifiication test on Poisson-CRE procedure please?

Thank you,

Federico