[R] Hausman test error solve
Millo Giovanni
Giovanni_Millo at Generali.com
Wed Oct 31 10:49:50 CET 2012
Liebe Gloria,
the error says it all: you have a singular covariance matrix (the
vcov(q) term in the Hausman test); this is not invertible and therefore
the test fails.
As for the reasons, this might be either a bug or perhaps an
ill-conditioned problem: it is impossible for me to tell without a
reproducible example. I can only suggest an alternative strategy (which
you must tailor to your example).
Another (computationally more robust) way to perform a Hausman test is
through an auxiliary regression (see Wooldridge, "Econometric analysis
of cross-section and panel data", 10.7.3)
#### Hausman test by auxiliary regression ########
library(plm)
## standard Munnell example
data(Produc)
fm<-log(gsp)~log(pcap)+log(pc)+log(emp)+unemp
re<-plm(fm, data=Produc, model="random")
fe<-plm(fm, data=Produc, model="within")
## extract transformed data
y.re<-pmodel.response(re)
X.re<-model.matrix(re)
X.fe<-model.matrix(fe)
## check coefficients
coef(re)
lm(y.re~X.re-1)
coef(fe)
lm(pmodel.response(fe)~X.fe-1)
## make aux dataset
auxdata<-data.frame(cbind(y.re,X.re,X.fe))
colnames(auxdata)<-c("y", paste("x", 1:9, sep=""))
## auxiliary model
auxmod<-lm(y~x1+x2+x3+x4+x5+x6+x7+x8+x9-1, auxdata)
## regression-based Hausman test is exclusion test for 6-9
library(lmtest)
waldtest(auxmod, 6:9)
I will eventually add a production version of this to 'plm' as
phtest2().
Best wishes nach Koeln
Giovanni
Giovanni Millo, PhD
Research Dept.,
Assicurazioni Generali SpA
Via Machiavelli 4,
34132 Trieste (Italy)
tel. +39 040 671184
fax +39 040 671160
-------- original message ----------------------
Date: Mon, 29 Oct 2012 13:14:09 -0700 (PDT)
From: gloria <gbusche at smail.uni-koeln.de>
To: r-help at r-project.org
Subject: [R] Hausman test error solve
Message-ID: <1351541649650-4647793.post at n4.nabble.com>
Content-Type: text/plain; charset=UTF-8
Hello,
I am trying to conduct a Hausman test to choose between FE estimators
and RE
estimators.
When I try to run:
library(plm)
fixed <- plm(ROS ~ DiffClosenessC +ZZiele + AggSK + nRedundantStrecken +
Degree + KantenGew + BetweennessC + SitzKappazitaet,
data=Panel,index=c("id","time"),model="within")
summary(fixed)
fixef(fixed)
random <-plm(ROS ~ DiffClosenessC +ZZiele + AggSK + nRedundantStrecken +
Degree + KantenGew + BetweennessC + SitzKappazitaet,
data=Panel,index=c("id","time"), model="random")
summary(random)
phtest(fixed, random)
I get an error from phtest(fixed, random)
Fehler in solve.default(dvcov) :
System ist f?r den Rechner singul?r: reziproke Konditionszahl = ...
Error in solve.default(dvcov) :
system is computationally singular: reciprocal condition number =...
Can someone Help me with this problem or give me a hint where to look?
Thanks
gloria
--
View this message in context:
http://r.789695.n4.nabble.com/Hausman-test-error-solve-tp4647793.html
Sent from the R help mailing list archive at Nabble.com.
-------------end original message -----------------
Ai sensi del D.Lgs. 196/2003 si precisa che le informazi...{{dropped:12}}
More information about the R-help
mailing list