[R] Hausman Test

Achim Zeileis Achim.Zeileis at uibk.ac.at
Sun Jan 16 16:29:03 CET 2011


On Sun, 16 Jan 2011, Holger Steinmetz wrote:

>
> Dear Achim,
>
> thank you very much.
>
> One follow up question. The Hausman-test always gives me a p-value of 1 
> - no matter how small the statistic is.
>
> I now generated orthogonal regressors (X1-X3) and the test gives me
>
>
>        Hausman specification test for consistency of the 3SLS estimation
>
> data:  data
> Hausman = -0.0138, df = 2, p-value = 1
>
> What is confusing to me is the "3SLS".

Hausman tests can be used for comparisons of various models. The 
implementation in systemfit is intended for comparison of 2SLS and 3SLS 
but can also be (ab)used for comparison of 2SLS and OLS. You just have to 
enter the models in the reverse order, i.e., hausman.systemfit(fit2sls, 
fitOLS).

A worked example that computes the test statistic "by hand" is also 
included in

   help("Baltagi2002", package = "AER")

in the section about the US consumption data, Chapter 11.

An adaptation is also shown below:

   ## data
   library("AER")
   data("USConsump1993", package = "AER")
   usc <- as.data.frame(USConsump1993)
   usc$investment <- usc$income - usc$expenditure

   ## 2SLS via ivreg(), Hausman by hand
   fm_ols <- lm(expenditure ~ income, data = usc)
   fm_iv <- ivreg(expenditure ~ income | investment, data = usc)
   cf_diff <- coef(fm_iv) - coef(fm_ols)
   vc_diff <- vcov(fm_iv) - vcov(fm_ols)
   x2_diff <- as.vector(t(cf_diff) %*% solve(vc_diff) %*% cf_diff)
   pchisq(x2_diff, df = 2, lower.tail = FALSE)

   ## 2SLS via systemfit(), Hausman via hausman.systemfit()
   library("systemfit")
   sm_ols <- systemfit(expenditure ~ income, data = usc, method = "OLS")
   sm_iv <- systemfit(expenditure ~ income, data = usc, method = "2SLS",
     inst = ~ investment)
   hausman.systemfit(sm_iv, sm_ols)

hth,
Z

> I am just beginning to learn about
> instrumental variables (I am a psychologist ;) Perhaps that's a problem?
>
> As a background, here's the complete simulation:
>
> W = rnorm(1000)
> X2 = rnorm(1000)
> X3 = rnorm(1000)
> X1 = .5*W  + rnorm(1000)
> Y = .4*X1 + .5*X2 + .6*X3 + rnorm(1000)
> data = as.data.frame(cbind(X1,X2,X3,Y,W))
>
> fit2sls <- systemfit(Y~X1,data=data,method="2SLS",inst=~W)
> fitOLS <- systemfit(Y~X1,data=data,method="OLS")
>
> print(hausman.systemfit(fitOLS, fit2sls))
>
> Best,
> Holger
> -- 
> View this message in context: http://r.789695.n4.nabble.com/Hausman-Test-tp3220016p3220065.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list