Hello. Here are my comments: your email would make for such a nice bug report, if only you would add: - a reproducible example of the fail in phtest() - a reproducible example of your code, if it's yours, and also the source of the code, if on the contrary you found it somewhere; because as it is, you make it almost impossible to help you. For more on this, please see the posting guide.
Anyway, in principle the Hausman test is correct. I've had code for this lying around for ages, I'll try to add it to 'plm' one of these days; but as in the end it is simply a joint restriction test, waldtest() should work fine. Best wishes, Giovanni --------------- original message --------------- Message: 26 Date: Mon, 1 Apr 2013 10:35:59 -0700 (PDT) From: londonphd <r.otoja...@qmul.ac.uk> To: r-help@r-project.org Subject: [R] plm: Hausman Test error Message-ID: <1364837759243-4662980.p...@n4.nabble.com> Content-Type: text/plain; charset=us-ascii Hi, I am trying to run a panel regression using 88 observations and 9 variables. In-built Hausman Test did not work, then I found a code for auxiliary regression method for the Hausman test. The panel models are: fe=plm(gd ~ l+g+o+c+g1+h+n+r, model = "within", data = new.frame,index = c("id")) re=plm(gd ~ l+g+o+c+g1+h+n+r, model = "random", data = new.frame,index = c("id"),random.method="amemiya") then I wrote the following function for the Hausman Test using an auxiliary regression method: hmtest=function(re=0,fe=0){ y.re=pmodel.response(re) X.re=model.matrix(re) X.fe=model.matrix(fe) auxdata<-data.frame(cbind(y.re,X.re,X.fe)) colnames(auxdata)<-c("y", paste("x", 1:17, sep="")) auxmod<-lm(y~x1+x2+x3+x4+x5+x6+x7+x8+x9+x10+x11+x12+x13+x14+x15+x16+x17- 1, auxdata) return(waldtest(auxmod, 10:17)[2,4]) } using the function above to choose between "fe" and "re" hmtest(re,fe) Error in solve(vc[ovar, ovar]) : subscript out of bounds Not sure what's gone wrong this time. I would appreciate your comments! -- View this message in context: http://r.789695.n4.nabble.com/plm-Hausman-Test-error-tp4662980.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}} ______________________________________________ R-help@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.