Skip to content
Panel Dataadvanced

Random Effects and the Hausman Test

Random effects (RE) estimates yit=xitβ+ai+uity_{it} = x_{it}'\beta + a_i + u_{it} by feasible GLS rather than by full demeaning. It applies a partial (quasi) demeaning governed by a factor θ[0,1)\theta \in [0,1), so it keeps part of the between variation alongside the within variation. That makes RE more efficient than fixed effects and lets it estimate time-invariant regressors that FE wipes out. The price is a strong assumption. RE is consistent only when the unobserved effect aia_i is uncorrelated with the regressors in every period, Cov(ai,xit)=0\text{Cov}(a_i, x_{it}) = 0 for all tt, on top of strict exogeneity of uitu_{it}. If that orthogonality fails, RE is biased and inconsistent and FE is the safer choice.

Why it matters

Fixed effects throws away all between-firm variation to purge aia_i, which is robust but wasteful and silent on anything that never changes. Random effects instead treats aia_i as a random draw and removes only a fraction θ\theta of each unit mean, recovering efficiency and time-invariant slopes. The catch is that RE only works if the unobserved heterogeneity is unrelated to the regressors. The Hausman test is the formal referee. It asks whether FE and RE disagree by more than sampling noise. If they agree, keep the efficient RE estimator. If they diverge significantly, the RE assumption has failed and you fall back to FE.

Formulas

RE quasi-demeaning (FGLS) transformation
yitθyˉi=(xitθxˉi)β+νit,θ[0,1)y_{it} - \theta\,\bar{y}_i = (x_{it} - \theta\,\bar{x}_i)'\beta + \nu_{it}, \qquad \theta \in [0,1)
At θ=0\theta = 0 this is pooled OLS, and as θ1\theta \to 1 it approaches the fully demeaned FE estimator. RE sits between, using both within and between variation.
Hausman test statistic
H=(β^FEβ^RE)[Var^(β^FE)Var^(β^RE)]1(β^FEβ^RE)H = (\hat{\beta}_{FE} - \hat{\beta}_{RE})'\,\bigl[\widehat{\text{Var}}(\hat{\beta}_{FE}) - \widehat{\text{Var}}(\hat{\beta}_{RE})\bigr]^{-1}(\hat{\beta}_{FE} - \hat{\beta}_{RE})
Under the null that RE is consistent and efficient, HH is chi-squared with degrees of freedom equal to the number of time-varying regressors compared. A large HH rejects the null.

Worked examples

Scenario

Estimate a wage equation on a panel of workers by random effects in Stata.

Solution

After `xtset id year`, run `xtreg lwage educ exper expersq union, re`. Because RE keeps between variation, the time-invariant `educ` coefficient is reported, unlike under FE. The output also prints `theta`, the quasi-demeaning factor, and `rho`, the share of total variance due to aia_i.

NoteA `theta` near 1 means RE behaves much like FE, while a `theta` near 0 means it behaves like pooled OLS.
Scenario

Decide between FE and RE for the same wage equation using a Hausman test.

Solution

Estimate and store both models, then compare them: `xtreg lwage exper expersq union, fe` then `estimates store fe`, then `xtreg lwage exper expersq union, re` then `estimates store re`, then `hausman fe re`. Suppose the result is H=22.4H = 22.4 with a p-value of 0.001. You reject the null that RE is consistent, so the RE orthogonality assumption fails and you report the FE estimates.

NoteRejection means use FE. A large p-value instead would let you keep the more efficient RE estimator.

Common mistakes

  • Reading the Hausman test backwards. Rejecting the null does NOT mean use RE. The null is that RE is consistent, so a rejection says the RE assumption fails and you should use FE.
  • Believing RE is always better because it is more efficient. The efficiency gain is real only if the orthogonality assumption Cov(ai,xit)=0\text{Cov}(a_i, x_{it}) = 0 holds. If it fails, RE is simply biased, and a more precise wrong answer is still wrong.
  • Running `hausman fe re` after a cluster-robust or robust VCE. The classical Hausman test assumes one estimator is fully efficient under the null, which clustered standard errors break, so it can return a negative or undefined statistic. Use an auxiliary-regression version such as the Mundlak (cluster-robust) test instead.
  • Thinking FE and RE estimate different parameters. Under the RE null they estimate the same β\beta, which is exactly why their difference is informative. The test exploits that one estimator stays consistent while the other does not when the assumption fails.

Revision bullets

  • RE is FGLS with partial demeaning by θ\theta, using both within and between variation.
  • RE is more efficient than FE and can estimate time-invariant regressors, but only if Cov(ai,xit)=0\text{Cov}(a_i, x_{it}) = 0 for all tt.
  • Hausman null: RE is consistent and efficient. The two estimators should be close under the null.
  • Reject the Hausman null means the RE assumption fails, so use FE. Fail to reject means keep RE.
  • Stata sequence: `xtreg y x, fe`, `estimates store fe`, `xtreg y x, re`, `estimates store re`, then `hausman fe re`.
  • The classical `hausman` command is not valid after a robust or clustered VCE. Use a Mundlak auxiliary-regression test there.

Quick check

A Hausman test comparing FE and RE returns H=19.6H = 19.6 with a p-value of 0.000. What should you conclude?

Why is random effects able to estimate the coefficient on a time-invariant regressor such as years of schooling, while fixed effects cannot?

Connected topics

Sources

  1. Wooldridge (2019), §14.2
    Wooldridge, Jeffrey M. Introductory Econometrics: A Modern Approach. 7th ed. Cengage, 2019.
    Develops the random effects estimator as quasi-demeaned FGLS, the role of θ\theta, and the orthogonality assumption Cov(ai,xit)=0\text{Cov}(a_i, x_{it}) = 0 that RE requires.
  2. Wooldridge (2019), §14.2 (FE vs RE)
    Wooldridge, Jeffrey M. Introductory Econometrics: A Modern Approach. 7th ed. Cengage, 2019.
    Discusses the Hausman test for choosing between fixed and random effects, where rejection of the null points to fixed effects.
How to cite this page
Dr. Phil's Quant Lab. (2026). Random Effects and the Hausman Test. Derivatives Atlas. https://phucnguyenvan.com/concept/efm-random-effects
Next concept
Fixed Effects (the Within Estimator)
Share this page
Built by Dr. Phuc V. Nguyen ·Follow on LinkedInWork with PhilEmail