问题
I have run into some difficulties with the plm function in R.
I am trying to run different panel data models on the same dataset and it works with the "between","fd" and "pooling" models, but not with the "within" or "random" models. Not sure what I am doing it wrong. Below is my code and the error message that I get. Would be grateful for any help!!
pdata_1<-pdata.frame(mydata_1,index=c("Country","Year"))
fd<-plm(Y~Category+Eurozone+Poverty_Rate,data = pdata_1,model = "fd")
pooled<-plm(Y~Category+Eurozone+Poverty_Rate,data = pdata_1,model = "pooling")
Code above works, but when I try this:
within<-plm(Y~Category+Eurozone+Poverty_Rate,data = pdata_1,model = "within")
random<-plm(Y~Category+Eurozone+Poverty_Rate,data = pdata_1,model = "random")
It stops working and I get this error:
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 also tried specifying the index again. Like this for example:
within<-plm(Y~Category+Eurozone+Poverty_Rate,data = pdata_1,index=c("Country","Year"),model = "within")
But I get the same error message. I tried googling it, but I really cannot understand the explanation (if there is any). Could you pls help?
Thank you so much!!
来源:https://stackoverflow.com/questions/60766742/r-error-in-classx-plm-only-within-and-random-effects-models