Written and maintained by CASRAI Editorial Board
Last updated
The Hausman test does not tell you whether fixed effects or random effects is the “better” model in the abstract. It tests one specific, narrow thing: whether the random-effects (RE) estimator and the fixed-effects (FE) estimator, fit on the same panel data, produce coefficients that are statistically distinguishable. If they diverge by more than sampling variation can explain, that divergence has one standard explanation — RE’s core assumption has failed — and the practical conclusion is to use FE instead. Understanding why that specific inference follows, and where it can mislead, matters more than memorizing the decision rule.
This guide covers the logic behind the test (not just fixed-effects and random-effects mechanics on their own), a reproducible worked example showing both a case where the test correctly flags the problem and a case where it correctly stays quiet, and the limitations that make an unqualified “reject means use FE” reading too simple for applied work.
The two estimators the test is comparing
Both fixed-effects and random-effects models start from the same one-way error-components model for panel data indexed by unit i and time t:
yit = β0 + β1xit + αi + εit
where αi is a unit-specific effect that does not vary over time (unmeasured ability, institutional culture, soil quality, whatever is fixed about that unit for the duration of the panel) and εit is the ordinary idiosyncratic error. The two estimators handle αi in incompatible ways:
- Fixed effects (the within estimator) demeans every variable within each unit before regressing, which algebraically removes αi entirely — it never has to be estimated or assumed about. This makes FE consistent for β1 regardless of whether αi is correlated with xit. The cost is that the within transformation also removes any time-invariant regressor, and it throws away the between-unit variation, which is usually a large share of the total variation — so FE is consistent but relatively inefficient (larger standard errors).
- Random effects (feasible GLS) treats αi as a random draw from a distribution, uncorrelated with xit, and uses a quasi-demeaning transformation (a weighted blend of the within and between variation, governed by a weight θ derived from the estimated variance components) instead of removing αi outright. Because it keeps some between-unit variation instead of discarding it, RE is more efficient than FE when its assumption holds. But that assumption — Cov(αi, xit) = 0 — is exactly the RE analogue of the exogeneity condition ordinary least squares needs, and it fails constantly in observational panel data: anything about a unit that is both stable over time and related to the regressor of interest (a firm’s underlying quality, a person’s unmeasured ability, a country’s institutional strength) breaks it. When it fails, RE is not just less efficient than FE — it is inconsistent, and no amount of additional data fixes that.
This is the setup that makes the comparison informative in the first place: FE is consistent under both the null and the alternative; RE is consistent only under the null. A test built to detect divergence between the two is therefore a test of RE’s extra assumption, using FE as the reference point that doesn’t depend on that assumption being true.
What the test actually does
The Hausman specification test (Hausman, 1978) compares the FE coefficient vector bFE to the RE coefficient vector bRE using the statistic:
H = (bFE − bRE)′ [Var(bFE) − Var(bRE)]−1 (bFE − bRE)
which is asymptotically chi-square distributed with degrees of freedom equal to the number of time-varying regressors being compared, under the null hypothesis that both estimators are consistent. The logic behind using the variance difference in the denominator, rather than the variance of either estimator on its own, comes from a general result Hausman proved: when one estimator (RE) is efficient under the null and the other (FE) stays consistent under both hypotheses, the covariance between the efficient estimator and the difference of the two estimators is exactly zero. That gives a clean variance decomposition, Var(bFE − bRE) = Var(bFE) − Var(bRE), which is what lets the test use only the two individual variances rather than needing their covariance separately.
The null hypothesis, precisely stated: H0: Cov(αi, xit) = 0 for every time-varying regressor — equivalently, “the random-effects estimator is consistent.” Rejecting H0 means the data are not consistent with that assumption: the unit effects are correlated with at least one regressor, RE is estimating the wrong quantity, and FE — which never needed that assumption — is the estimator to report. Failing to reject does not prove the assumption is true; it means the data gave no statistical reason to abandon RE’s more efficient estimates in favor of FE’s noisier but assumption-free ones.
Worked example (simulated, reproducible)
Illustrative simulation, not observed data. To show what the test actually looks like on both sides of the decision, this is a Monte Carlo simulation with a known, controlled data-generating process — not real study data. Two panels were generated (300 units × 4 periods each), differing in exactly one respect: whether the unit effect αi is correlated with the regressor xit.
Case A — αi correlated with xit (RE’s assumption genuinely violated):
- bFE = 1.4917 (SE 0.0322) | bRE = 1.6299 (SE 0.0300)
- Hausman H = 135.995 against a χ²(1) critical value of 3.841 at 5% — rejects overwhelmingly
Case B — αi independent of xit (RE’s assumption holds):
- bFE = 1.5182 (SE 0.0345) | bRE = 1.5179 (SE 0.0319)
- Hausman H = 0.000 against the same 3.841 threshold — nowhere close to rejecting
Both estimators were computed from the same code: FE as the within (demeaned) OLS estimator; RE as feasible GLS using the standard Swamy–Arora variance-component estimates and quasi-demeaning weight θ. In Case A, the true β1 used to generate the data was 1.5 — FE landed close to it (1.4917) precisely because the within transformation removed the correlated unit effect before estimating, while RE’s coefficient (1.6299) absorbed part of that correlation into the slope, which is exactly the bias the test is built to catch. In Case B, with no correlation to remove, FE and RE converge to nearly the same number, and the efficiency loss from unnecessarily using FE would show up only in the larger standard error, not in the point estimate. This is the entire logic of the test compressed into two numbers: not “which model fits better,” but “how far apart are these two estimators, relative to how far apart sampling noise alone could plausibly put them.”
Limitations: a significant result is not automatically “genuine endogeneity, case closed”
The textbook version of the test carries assumptions of its own, and treating a rejection as unambiguous proof of correlated unit effects skips past several places it can mislead:
- The classical statistic assumes the RE estimator is fully efficient under the null — which requires the composite error to be homoskedastic and free of serial correlation beyond what the error-components structure already implies. Real panel data routinely violates both (heteroskedasticity across units, autocorrelated idiosyncratic shocks within a unit over time). When that happens, RE is no longer actually efficient even under H0, the clean variance-difference formula the test relies on no longer holds, and the classical Hausman statistic can reject — or fail to reject — for reasons that have nothing to do with whether αi is correlated with xit. The standard fix is a regression-based (auxiliary-regression) or cluster-robust version of the test rather than the textbook formula, precisely because it doesn’t depend on RE being efficient in the first place.
- The variance-difference matrix is only guaranteed to be positive semi-definite asymptotically. In finite samples — small T, near-collinearity between a regressor’s within and between variation, or a specification close to the boundary where FE and RE nearly coincide — Var(bFE) − Var(bRE) can come out non-positive-definite, producing a negative test statistic. A negative H is not a stronger non-rejection; it’s a sign the asymptotic approximation the test depends on isn’t a good fit for this sample, and it is conventionally treated as a failure to reject rather than evidence either way.
- Rejection identifies that RE is inconsistent — it does not identify why, and it does not mean FE has solved the underlying problem. Fixed effects only removes confounding that is genuinely time-invariant over the panel’s observation window. If the true confound is time-varying (a policy change that affects some units more than others, a shock that hits at different times), FE is exactly as inconsistent as RE was, and the Hausman test comparing them gives no signal about that failure mode at all — both estimators can be wrong in the same direction. A significant Hausman statistic is evidence to prefer FE over RE for this specific model; it is not a certificate that the FE specification is correctly identified.
- Pretesting changes the properties of whatever comes after it. Using the test’s outcome to choose which estimator’s standard errors and confidence intervals to report — rather than committing to one estimator on design grounds beforehand — means the reported inference no longer has the coverage properties either estimator would have on its own; this is the general pretesting problem, not something specific to the Hausman test, but it is why a growing share of applied panel work reports FE with cluster-robust standard errors by default and treats the Hausman result as supporting evidence rather than the estimator-selection mechanism itself.
When the test isn’t the right tool at all
The Hausman test is specific to the classical fixed-vs-random-effects comparison in linear panel models. It is not the same test as the Durbin–Wu–Hausman test for regressor endogeneity against an instrumental-variables alternative, even though both share Hausman’s name and the same underlying logic of comparing a consistent-only estimator to a consistent-and-efficient one — see Endogeneity: The Three Sources, and the Remedy That Matches Each for that distinction and for what fixed effects can and can’t absorb as an endogeneity remedy more generally. And if the “random” and “fixed” terms in your model are actually about nested or hierarchical data structure — students within schools, patients within clinics, repeated measures within subjects — rather than a two-estimator panel-econometrics comparison, the relevant framework is a mixed-effects (multilevel) model instead; see Mixed-Effects Models: Choosing Random vs. Fixed Effects for Nested Research Data, which explicitly flags this exact panel-econometrics usage as a different question from the one it answers.
Frequently asked questions
Does failing to reject the Hausman test prove random effects is correct?
No. Failing to reject means the data gave no statistical evidence against RE’s assumption — it is an absence of evidence for a problem, not evidence of the assumption’s truth. With low power (small T, little within-unit variation in x), the test can fail to reject even when a real, small correlation between αi and xit is present.
Can the Hausman test be used with more than one regressor?
Yes — the statistic generalizes directly to a vector of time-varying coefficients, with degrees of freedom equal to the number of coefficients compared, and the same chi-square reference distribution.
What do I report if the classical test statistic comes out negative?
Treat it as a failure to reject (not a stronger non-rejection), and consider whether the classical test’s homoskedasticity/no-serial-correlation assumptions are plausible for the data; a regression-based or cluster-robust version of the test is the standard alternative when they aren’t.
If the test rejects, does that mean random effects is unusable and fixed effects is definitely correct?
It means RE is inconsistent for this model as specified, which is a real reason to prefer FE over RE specifically. It is not a guarantee that FE is correctly specified overall — FE can still be biased by any confounder that varies over time within a unit, which the test has no way to detect.








