我有内部和随机效应方法的问题(它不起作用)。我没有问题的池,之间或第一个不同的估计->工作。
我也有类似于R - Error in class(x) - plm - only within and random effects models的问题。以下是我的数据链接:https://www.dropbox.com/s/8tgeyhxeb0wrdri/my_data.xlsx?raw=1 (有些国家有一些金融措施和GDP增长)
我的代码:
proba<-read_excel("my_data.xlsx")
attach(proba)
Y<-cbind(GDP_growth)
X<-cbind(gfdddi01, gfdddi02, gfdddi04, gfdddi05)
pdata<-pdata.frame(proba,index=c("id","year"))
##POOLED OLS estimator
pooling<-plm(Y~X,data=pdata,model="pooling")
summary(pooling)
##BETWEEN ESTIMATOR
between<-plm(Y~X,data=pdata,model="between")
summary(between)
#FIRST DIFFERENCES ESTIMATOR
firstdiff<-plm(Y~X,data=pdata,model="fd")
summary(firstdiff)
#FIXED EFFECT OR WITHIN ESTIMATOR
fixed <-plm(Y~X,data=pdata,model="within")
summary(fixed)
#RANDOM EFFECTS ESTIMATOR
random<- plm(Y~X,data=pdata,model="random")
summary(random)我得到的错误消息:
类(X) <- setdiff( class(x),"pseries")中的
错误:除非维度属性长度为2 (was 0),否则无法将类设置为矩阵
有什么不对的?
发布于 2020-03-23 05:47:15
不要使用来自环境的变量(就像您对Y和X所做的那样--不需要创建这些变量)。相反,在formula参数plm中使用变量名,因为它们发生在您的数据pdata中。
#FIXED EFFECT OR WITHIN ESTIMATOR
fixed <-plm(GDP_growth ~ gfdddi01 + gfdddi02 + gfdddi04 + gfdddi05, data = pdata, model ="within")
summary(fixed)
## Oneway (individual) effect Within Model
##
## Call:
## plm(formula = GDP_growth ~ gfdddi01 + gfdddi02 + gfdddi04 + gfdddi05,
## data = pdata, model = "within")
##
## Balanced Panel: n = 17, T = 41, N = 697
##
## Residuals:
## Min. 1st Qu. Median 3rd Qu. Max.
## -18.89148 -1.17470 0.12701 1.48874 20.70109
##
## Coefficients:
## Estimate Std. Error t-value Pr(>|t|)
## gfdddi01 -0.0066663 0.0153800 -0.4334 0.6648
## gfdddi02 0.0051626 0.0153343 0.3367 0.7365
## gfdddi04 -0.0245573 0.0150069 -1.6364 0.1022
## gfdddi05 -0.0049627 0.0073786 -0.6726 0.5014
##
## Total Sum of Squares: 5421.5
## Residual Sum of Squares: 5366.8
## R-Squared: 0.010095
## Adj. R-Squared: -0.019192
## F-statistic: 1.72352 on 4 and 676 DF, p-value: 0.14296https://stackoverflow.com/questions/60804415
复制相似问题