*! version 1.0.0 09jun2026

Title

xttestpanel hausman -- FE-vs-RE specification test (classical + robust)

Syntax

xttestpanel hausman [depvar indepvars] [if] [in]
[, tune(#) graph]

Postestimation form (no varlist) reuses the last xtreg; the test always fits
both FE and RE internally, so model() is not needed.

Description

xttestpanel hausman tests whether the random-effects estimator is consistent,
i.e. whether the regressors are uncorrelated with the unit effects. It fits both FE
and RE internally and reports two statistics:

o Classical Hausman - the standard Hausman (1978) contrast
(b_FE - b_RE)' (V_FE - V_RE)^(-1) (b_FE - b_RE), computed by calling Stata's
built-in hausman. It therefore reproduces hausman's chi-squared and
degrees of freedom exactly.

o Robust weighted Hausman - a Mundlak (1978)
auxiliary-regression test (the group means of the regressors are added to the RE-GLS
equation and tested jointly) computed after Huber down-weighting of
outlying/high-leverage observations, with a cluster-robust (by unit) variance,
following the robust specification test of Beyaztas, Bandyopadhyay & Mandal
(2021). A large gap between the classical and robust statistics flags influential
observations driving the classical decision.

You can verify the classical row against the built-in command:

. xtreg y x1 x2, fe
. estimates store fe
. xtreg y x1 x2, re
. estimates store re
. hausman fe re

Decision: reject H0 => the RE estimator is inconsistent => prefer fixed effects.

Options

tune(#) Huber tuning constant for the robust weights; default 1.345
(95% Gaussian efficiency). Smaller => more aggressive down-weighting.

graph histogram and kernel density of the composite residuals (u+e); fat
tails indicate that the classical Hausman test may be unreliable.

Stored results

r(hausman) classical Hausman statistic

r(p_hausman) its p-value

r(robust_hausman) robust weighted statistic

r(p_robust) its p-value

r(pct_down) % of observations down-weighted

r(df) degrees of freedom

Examples

. xttestpanel hausman ln_wage age tenure hours, graph

. xttestpanel hausman ln_wage age tenure hours, tune(1.0)

References

Beyaztas, B.H., S. Bandyopadhyay, and A. Mandal. 2021. arXiv:2104.07723.

Mundlak, Y. 1978. Econometrica 46: 69-85.

Hausman, J.A. 1978. Econometrica 46: 1251-1271.

Author

Merwan Roudane - merwanroudane920@gmail.com -
github.com/merwanroudane