# Hausman test for panel data, fe and re. Error in the estimation, what to do? Stata

I am performing a Hausman test on panel data to determine whether to choose Random Effects or Fixed Effects for my analysis. After performing the test I get this error:

chi2(2) = (b-B)'[(V_b-V_B)^(-1)](b-B)
=    -8.32    chi2<0 ==> model fitted on these
data fails to meet the asymptotic
assumptions of the Hausman test;
see suest for a generalized test


What does this mean? Is this result OK, and it simply means that I should use random effects or something is terribly wrong here? I cannot use suest as the software suggest, because that's not for panel data.

In addition, when I change the order of the analysis, i.e. I estimate re first, and then fe, and do: hausman random fixed, I get a "normal" result, like this:

chi2(17) = (b-B)'[(V_b-V_B)^(-1)](b-B)
=      411.18
Prob>chi2 =      0.0000


However, I read on Statalist that it is not as simple as changing the order, since you get a wrong statistic.

So, the question is, what to do in this case, can I change the order of the estimation? I am pretty sure that FE does not work well with my data, but I need a way to prove it.

Please consider I am not a statistician, so the simpler the answer, the better.

• This can be helpful to choose between Random effect and fixed effect by testing hausman test panel data *Run Fixed effect xtlogit y x1 x2 ,fe estimates store fe *Run Random effect xtlogit y x1 x2,re estimates store re hausman fe re, equations(1:1) – goodluck Apr 16 '18 at 13:41
• For future googlers, a comprehensive explanation of testing on model specification (FE or RE) using the above can be found here kb.iu.edu/d/bcmq – John Aug 18 '18 at 13:39

## 2 Answers

Your first test returns a negative test statistic (-8.32) which should not happen. Usually the reason for this is a too small sample or mis-specification of the model. As it stands the result of your first test cannot be used to infer much more. Certainly it is not advisable to reverse the order of the estimates in the test for the reasons highlighted in the Statalist post you linked.

You may want to try the command xtoverid which gives a positive test statistic and also works with panels (unlike suest). In Stata you can install it by typing
ssc install xtoverid
At the bottom of the help file you will also find an example of how to use the test for deciding between FE or RE models. Run the RE model and then use the xtoverid command after that. The interpretation is the same as with hausman, i.e. a significant test statistic rejects the null hypothesis that RE is consistent.

• Hi @Andy, I have implemented your solution, and I have a couple of questions: 1) My model includes year effects (dummies). When I try to perform xtoverid with the dummies included I get an error: operator invalid. If I remove it, then it works. Is it OK that I test re against fe without including the dummy, which it is actually significant for the model? 2) Just to clarify, I am getting the following result (after removing the year effects): Sargan-Hansen statistic 24.916 Chi-sq(2) P-value = 0.0000 // Does this mean, use FE? Thanks. – Herman Haugland Jul 26 '13 at 14:57
• 1) The i. operator does not work with xtoverid. You can just generate the dummies by using "qui tab year, gen(dyear)" and include them directly in the model instead of using an operator. 2) Yes, because it implies that RE is not consistent in your case. But try again with the complete model including the dummies. – Andy Jul 26 '13 at 15:35
• I get this error when I use dummies for years instead of year effects: Error - saved RE estimates are degenerate (sigma_u=0) and equivalent to pooled OLS. What to do? – Herman Haugland Jul 26 '13 at 15:56
• Either you have a very small sample or you are having a collinearity problem in your model. In the first case you can use the small-sample variance estimator by Swamy and Aurora (in Stata: xtreg y x, re sa). In the second case you will have to omit highly collinear variables. Normally Stata should do this automatically in the regression command though. – Andy Jul 26 '13 at 16:22
• Thank you very much @Andy, I'm going through my data now and I have found some mistakes in the raw data. I am going to follow your advise and see if I can solve my problem. – Herman Haugland Jul 26 '13 at 19:04

The negative sign can arise if different esti­mates of the error variance are used in forming variance of b and variance of B. In that case, you need to use the sigmamore option, which specifies that both covariance matri­ces are based on the (same) estimated disturbance variance from the efficient estimator.

hausman  FE RE , sigmamore


Note: FE and RE are estimates stored from fixed effect and random effect model. The answer is based on Microeconometrics using Stata by Cameron and Trivedi p. 261.