[R] plm: Hausman Test error

londonphd r.otojanov at qmul.ac.uk
Mon Apr 1 19:35:59 CEST 2013


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.



More information about the R-help mailing list