RATS 10.1
RATS 10.1

HAUSMAN.RPF is an example of a Hausman test for IV vs OLS. It's adapted from Greene(2012), Example 8.7 from page 237.

 

The model is a simple consumption on income regression:

\begin{equation} c_t = \alpha _0 + \alpha _1 y_t + u_t \label{eq:HausmanCY} \end{equation}

The maintained assumptions are:

\begin{equation} E\left( {u_t } \right) = E\left( {c_{t - 1} u_t } \right) = E\left( {y_{t - 1} u_t } \right) = 0 \label{eq:HausmanOrthog} \end{equation}

that is, that lagged consumption and lagged income are valid instruments. Under those assumptions, instrumental variables estimates are consistent. If we add the additional assumption that current income is pre-determined:

\begin{equation} E\left( {y_t u_t } \right) = 0 \label{eq:HausmanOLS} \end{equation}

then OLS is not just consistent, but efficient. That allows us to use a Hausman test to test that added assumption \eqref{eq:HausmanOLS}.

 

The first thing to note about this is that the natural estimation range for least squares will have on additional data point compared with instrumental variables, as the latter needs lags of \(c\) and \(y\). So the range has to be controlled to make the estimators match. This estimates the model by least squares and saves a copy of %XX, %BETA and (maximum likelihood) estimate of the residual variance:

 

linreg realcons 1950:2 *

# constant realgdp

compute xxols=%xx,betaols=%beta,sigsqols=%sigmasq

 

Next up is the instrumental variables estimator:

 

instruments constant realgdp{1} realcons{1}

linreg(inst) realcons

# constant realgdp

compute xxiv=%xx,betaiv=%beta

 

With these options, both LINREG instructions produce an %XX which needs to be multiplied by an estimate of the residual variance to get the covariance matrix. We need to pick one of those to be the common scaling for the covariance matrix of the difference. Here, we will use the SIGSQOLS from least squares. Different choices for this will yield (slightly) different test results. The FORM=CHISQUARED option is needed on the TEST because multiplying by SIGSQOLS converts it from an “F” form to a chi-squared form.

 

test(covmat=sigsqols*(xxiv-xxols),vector=betaols,all,$

  form=chisquared,title="Hausman Test")

 

Note that the degrees of freedom are adjusted to 1. Because the CONSTANT is in both the regression and the instrument set, if the slope coefficients are equal the intercepts have to be as well, so the test is really only on the slope. In practice, it’s rare for a Hausman test to have full rank since some of the assumptions tend to be common between the two models.

In many cases (such as this one), the Hausman test can be computed more easily with an auxiliary regression. In this case, it’s the Wu(1973) test, which adds the fitted value from projecting the endogenous explanatory variable onto the instruments to the linear regression and testing the fitted value (output):

 

linreg realgdp

# constant realgdp{1} realcons{1}

prj yfit

linreg realcons

# constant realgdp yfit

exclude(title="Wu test")

# yfit

 

And this latter test can be done even more simply using the @RegWuTest procedure (output) immediately after running the instrumental variables regression:

 

instruments constant realgdp{1} realcons{1}

linreg(inst) realcons 1950:2 *

# constant realgdp

@RegWuTest

 

Full Program

 

open data TableF5-2.txt

calendar(q) 1950

data(format=prn,org=columns) 1950:01 2000:04 year qtr realgdp realcons $

 realinvs realgovt realdpi cpi_u m1 tbilrate unemp pop infl realint

*

* Estimate the OLS regression, starting in 1950:2 to match the range on

* the IV regression. Save the %XX matrix and coefficients.

*

linreg realcons 1950:2 *

# constant realgdp

compute xxols=%xx,betaols=%beta,sigsqols=%sigmasq

*

* IV regression

*

instruments constant realgdp{1} realcons{1}

linreg(inst) realcons

# constant realgdp

compute xxiv=%xx,betaiv=%beta

*

test(covmat=sigsqols*(xxiv-xxols),vector=betaols,all,$

  form=chisquared,title="Hausman Test")

*

* Same test doing using the Wu method.

*

linreg realgdp

# constant realgdp{1} realcons{1}

prj yfit

linreg realcons

# constant realgdp yfit

exclude(title="Wu test")

# yfit

*

* Same thing done using @RegWuTest. This needs to be done after the

* LINREG(INST).

*

instruments constant realgdp{1} realcons{1}

linreg(inst) realcons 1950:2 *

# constant realgdp

@RegWuTest


 

Output

 

Linear Regression - Estimation by Least Squares

Dependent Variable REALCONS

Quarterly Data From 1950:02 To 2000:04

Usable Observations                       203

Degrees of Freedom                        201

Centered R^2                        0.9993097

R-Bar^2                             0.9993063

Uncentered R^2                      0.9998694

Mean of Dependent Variable       3008.9950739

Std Error of Dependent Variable  1456.9001521

Standard Error of Estimate         38.3727132

Sum of Squared Residuals         295965.48920

Regression F(1,201)               290981.9427

Significance Level of F             0.0000000

Log Likelihood                     -1027.4509

Durbin-Watson Statistic                0.3335

 

    Variable                        Coeff      Std Error      T-Stat      Signif

************************************************************************************

1.  Constant                     -151.9402925    6.4490889    -23.55996  0.00000000

2.  REALGDP                         0.6905845    0.0012802    539.42742  0.00000000

 

 

Linear Regression - Estimation by Instrumental Variables

Dependent Variable REALCONS

Quarterly Data From 1950:02 To 2000:04

Usable Observations                       203

Degrees of Freedom                        201

Mean of Dependent Variable       3008.9950739

Std Error of Dependent Variable  1456.9001521

Standard Error of Estimate         38.3733644

Sum of Squared Residuals         295975.53393

J-Specification(1)                   140.0844

Significance Level of J             0.0000000

Durbin-Watson Statistic                0.3336

 

    Variable                        Coeff      Std Error      T-Stat      Signif

************************************************************************************

1.  Constant                     -152.4242744    6.4500278    -23.63157  0.00000000

2.  REALGDP                         0.6906903    0.0012804    539.41683  0.00000000

 

Hausman Test

## X13. Redundant Restrictions. Using 1 Degrees, not 2

Chi-Squared(1)=     22.111856 with Significance Level 0.00000257

 

 

Linear Regression - Estimation by Least Squares

Dependent Variable REALGDP

Quarterly Data From 1950:02 To 2000:04

Usable Observations                       203

Degrees of Freedom                        200

Centered R^2                        0.9996885

R-Bar^2                             0.9996854

Uncentered R^2                      0.9999457

Mean of Dependent Variable       4577.1881773

Std Error of Dependent Variable  2108.9340299

Standard Error of Estimate         37.4058882

Sum of Squared Residuals         279840.09431

Regression F(2,200)               320946.1161

Significance Level of F             0.0000000

Log Likelihood                     -1021.7644

Durbin-Watson Statistic                1.3615

 

    Variable                        Coeff      Std Error      T-Stat      Signif

************************************************************************************

1.  Constant                     52.549705759 11.929518984      4.40501  0.00001723

2.  REALGDP{1}                    0.779232636  0.047080405     16.55110  0.00000000

3.  REALCONS{1}                   0.331037314  0.068218788      4.85258  0.00000245

 

 

Linear Regression - Estimation by Least Squares

Dependent Variable REALCONS

Quarterly Data From 1950:02 To 2000:04

Usable Observations                       203

Degrees of Freedom                        200

Centered R^2                        0.9993849

R-Bar^2                             0.9993788

Uncentered R^2                      0.9998837

Mean of Dependent Variable       3008.9950739

Std Error of Dependent Variable  1456.9001521

Standard Error of Estimate         36.3130369

Sum of Squared Residuals         263727.33034

Regression F(2,200)               162475.7657

Significance Level of F             0.0000000

Log Likelihood                     -1015.7452

Durbin-Watson Statistic                0.3120

 

    Variable                        Coeff      Std Error      T-Stat      Signif

************************************************************************************

1.  Constant                     -152.4242744    6.1037154    -24.97238  0.00000000

2.  REALGDP                         0.3512231    0.0686448      5.11653  0.00000073

3.  YFIT                            0.3394672    0.0686555      4.94450  0.00000161

 

Wu test

 

 

Null Hypothesis : The Following Coefficients Are Zero

YFIT

t(200)=   4.944502 or F(1,200)=  24.448099 with Significance Level 0.00000161

 

 

Linear Regression - Estimation by Instrumental Variables

Dependent Variable REALCONS

Quarterly Data From 1950:02 To 2000:04

Usable Observations                       203

Degrees of Freedom                        201

Mean of Dependent Variable       3008.9950739

Std Error of Dependent Variable  1456.9001521

Standard Error of Estimate         38.3733644

Sum of Squared Residuals         295975.53393

J-Specification(1)                   140.0844

Significance Level of J             0.0000000

Durbin-Watson Statistic                0.3336

 

    Variable                        Coeff      Std Error      T-Stat      Signif

************************************************************************************

1.  Constant                     -152.4242744    6.4500278    -23.63157  0.00000000

2.  REALGDP                         0.6906903    0.0012804    539.41683  0.00000000

 

Wu/Hausman Specification Test

F(1,200)=     24.44810 with Significance Level 0.00000161

Chi-Squared(1)=     22.111856 with Significance Level 0.00000257

 


Copyright © 2025 Thomas A. Doan