R - Error in class(x) - plm - only within and random effects models

元气小坏坏 提交于 2020-04-18 03:47:46

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!