Hi Statalist

In the help files for -hausman- we see an example (eg1 on p.894, Stata 16) in which all the regressors vary with time.

My question is whether the Hausman test is still valid when there are time-invariant regressors that the FE model subsequently remove?

In the simulated data below, the unobserved time-invariant component is correlated with regressor x1. As such, it would suggest that we should apply an FE model instead of an RE model.

However, x1 is time-invariant and the resultant Hausman test supports the use of RE. Does this mean that in order for the Hausman test to be valid (ignoring homoskedasticity for the time being), both sets of RE and FE equations must contain the same set of regressors?

Thanks.

Code:
*****************
clear
set seed 111
set obs 1000
*****************
generate id     = _n
generate year   = 2000
generate x1     = runiform()> .5

generate nu     = rnormal()
generate alpha = x1 + nu
*****************
expand 5
bysort id:  replace year = year + _n
*****************
generate x2    = rbeta(2,3)
generate u     = rnormal()
*****************
generate y  = (3) + (1) * x1 + (1) * x2 + alpha + u 
// the unobserved time-invariant component alpha is correlated with regressor x1,
// so FE would be more appropriate

xtset id year

xtsum // to check that x1 is time-invariant whereas x2 varies with time

quietly xtreg y x1 x2, re
estimates store RE

quietly xtreg y x1 x2, fe
estimates store FE

hausman FE RE, sigmamore

                 ---- Coefficients ----
             |      (b)          (B)            (b-B)     sqrt(diag(V_b-V_B))
             |       FE           RE         Difference          S.E.
-------------+----------------------------------------------------------------
          x2 |    .9144598     .9098057        .0046541         .016269
------------------------------------------------------------------------------
                           b = consistent under Ho and Ha; obtained from xtreg
            B = inconsistent under Ha, efficient under Ho; obtained from xtreg

    Test:  Ho:  difference in coefficients not systematic

                  chi2(1) = (b-B)'[(V_b-V_B)^(-1)](b-B)
                          =        0.08
                Prob>chi2 =      0.7748