1

I'm attempting to run a fixed effects estimator on my data, and even though the pooling, between, and first differences estimators all worked, I keep getting this error when attempting the fixed effects estimator:

Error in class(x) <- setdiff(class(x), "pseries") : 
  invalid to set the class to matrix unless the dimension attribute is of length 2 (was 0)

I then changed my code so that I was specifically identifying each variable instead of relying on 'x' and 'y' objects from the global environment which changed my error message to:

Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) : 
  0 (non-NA) cases

I've seen this error quite a bit in other posts here and have thus tried all of the suggested solutions, none of which have worked (writing out all variables instead of using created "x" and "y" from environment, testing using all(is.na(x)), all(is.na(y)) which resulted in FALSE indicating this is not the problem, including na.action=na.exclude to remove NA values...) nothing has worked, and the same error keeps coming up. Here is my code:

mydata<- read.csv("/Users/hannahsalamon/Desktop/data.csv")
attach(mydata)
y<-cbind(RenEnCon)
x<-cbind(WomenParl, GDPpercap, Pop, UrbanPop, FreedomHouse, RegimeType, HDI, WomenPolEmpowerIndex)
pdata<-pdata.frame(mydata, index=c("Country", "Year"))
summary(y)
summary(x)
pooling<-plm(y~x, data = pdata, model = "pooling")
summary(pooling)
between<-plm(y~x, data = pdata, model = "between")
summary(between)
firstdiff<-plm(y~x, data = pdata, model = "fd")
summary(firstdiff)
fixed<-plm(y~x, data = pdata, model = "within")
fixed <- plm(RenEnCon ~ WomenParl+GDPpercap+UrbanPop+Pop+FreedomHouse+RegimeType+HDI+WomenPolEmpowerIndex, data=pdata, model= "within")

All the code up until the 'fixed' model (two included there, one using 'x' and 'y' and the other with individual variables) runs completely fine. Any suggestions will be very, very welcome! This is driving me crazy!

1 Answers1

1

Figured it out, of course, just after posting this. For anyone else, if this might be helpful, what solved the problem for me was ensuring that all missing values were coded as NA. I had some values that were coded as NA and others that instead were filled with "..". As soon as I removed these and replaced them as NA values the fixed effect model worked. I don't know why this wasn't an issue for any of the other estimators!