The Hausman test: fixed or random effects?

The Hausman test decides between fixed and random effects in almost every panel-data dissertation. It is also misread more often than any other test. Here is how to run it, read it, and what to do when it fails.

4 min readReviewed 2026-11-25Stata · R · EViews
M

Made for: Master's dissertation student

Your data is ready. The model isn't cooperating.

Sound familiar?

  • The Hausman test gives a negative chi-squared
  • Stata says "V_b-V_B is not positive definite"
  • Your supervisor prefers random effects but the test rejects it
  • You don't know which p-value to report

We diagnose your model, run it with you, and explain every number so you can defend it.

What the Hausman test does

Hausman (1978) compares two estimators of the same coefficients:

  • Fixed effects (FE) is consistent whether or not the unit effects are correlated with the regressors, but less efficient.
  • Random effects (RE) is efficient, but consistent only if the unit effects are uncorrelated with the regressors.

If both are consistent, their estimates should be close. A large, systematic difference suggests RE is inconsistent.

  • Null hypothesis (H₀): the difference in coefficients is not systematic, so RE is consistent and efficient. Use RE.
  • Alternative (H₁): the difference is systematic, so RE is inconsistent. Use FE.

The statistic is H = (b_FE − b_RE)′ [Var(b_FE) − Var(b_RE)]⁻¹ (b_FE − b_RE), distributed χ² with degrees of freedom equal to the number of time-varying regressors compared.

Step by step in Stata

xtset id year
xtreg y x1 x2 x3, fe
estimates store fe
xtreg y x1 x2 x3, re
estimates store re
hausman fe re

Order matters: the consistent model (FE) goes first, the efficient one (RE) second.

Reading the output: look at Prob > chi2.

Result Decision
p < 0.05 Reject H₀ → fixed effects
p ≥ 0.05 Do not reject → random effects is acceptable (still check the LM test against pooled OLS)

In R and EViews

library(plm)
fe <- plm(y ~ x1 + x2 + x3, data = p, model = "within")
re <- plm(y ~ x1 + x2 + x3, data = p, model = "random")
phtest(fe, re)

In EViews, estimate the random-effects equation, then choose View → Fixed/Random Effects Testing → Correlated Random Effects – Hausman Test.

When the Hausman test fails

"V_b−V_B is not positive definite" or a negative χ²

The standard test assumes RE is fully efficient. In finite samples the variance difference can fail to be positive definite. Options:

  • hausman fe re, sigmamore (or sigmaless) to use a common error variance estimate.
  • Better: the robust test below.

Heteroskedasticity or serial correlation

The classic Hausman test is invalid if errors are heteroskedastic or serially correlated, which is the usual case in firm and country panels. You can't simply add vce(cluster id) to the two models and run hausman. Use one of these instead:

  1. Mundlak / correlated random effects approach. Add the unit means of each time-varying regressor to the RE model and test their joint significance with cluster-robust errors. Significance → FE.
  2. Overidentification test xtoverid (user-written: ssc install xtoverid) after xtreg …, re vce(cluster id). It is a robust Sargan-Hansen equivalent of the Hausman test.
* Mundlak test with cluster-robust SEs
foreach v of varlist x1 x2 x3 {
    bysort id: egen m_`v' = mean(`v')
}
xtreg y x1 x2 x3 m_x1 m_x2 m_x3, re vce(cluster id)
test m_x1 m_x2 m_x3        // reject → fixed effects

Your supervisor wants random effects, but the test says fixed

Show them the robust test. If it also rejects, FE is the defensible choice. If your study needs time-invariant variables (which FE can't estimate), consider the correlated random effects (Mundlak) model or Hausman-Taylor, which keep those variables while addressing correlation.

How to report it

Example: A Hausman test rejected the random-effects specification (χ²(4) = 31.62, p < .001). Because the classic test assumes homoskedastic errors, we confirmed the result with a cluster-robust Mundlak test (F(4, 119) = 7.85, p < .001). We therefore estimate fixed-effects models with standard errors clustered by firm.

Common mistakes

  • Putting RE first in hausman. The consistent model goes first.
  • Interpreting a non-significant result as "RE is proven". It means only that the data can't reject RE.
  • Running Hausman with time-invariant regressors and expecting them to be compared; only time-varying ones are.
  • Skipping the Breusch-Pagan LM test: even if Hausman favours RE, check that RE beats pooled OLS.
  • Ignoring the test's assumptions when errors are clearly heteroskedastic.

Frequently asked questions

Is the Hausman test needed if I only care about within-firm effects?

If your question is explicitly about within-unit changes, FE is justified by design. Many applied papers still report Hausman for completeness.

Can I use the Hausman test with dynamic panels?

Not for choosing between FE and RE with a lagged dependent variable: both are biased with short T. Use difference or system GMM.

The Hausman test is used for endogeneity too. Is that the same test?

It uses the same logic (compare a consistent and an efficient estimator), applied to OLS vs IV. That version is the Durbin-Wu-Hausman test, covered in our Instrumental variables (IV/2SLS) guide.