R -plm-内部效应模型和随机效应模型中的误差(合并,第一次差异之间起作用) [英] R -plm - error within and random effects models (pooling, between & first differences work)

查看:346
本文介绍了R -plm-内部效应模型和随机效应模型中的误差(合并,第一次差异之间起作用)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对内部"和随机效果方法有疑问(这不起作用).而且我对合并池,第一个差值估计器或第一个差值估计器没有问题->它起作用.

I have problem with Within and random effect method (it doesn't work). And I have no problem with pooling, between or first diffeences estimator -> it works.

我遇到与 R相同的问题-类(x)中的错误-plm-仅在随机效应模型内和. 这是指向我的数据的链接: https://www.dropbox. com/s/8tgeyhxeb0wrdri/my_data.xlsx?raw = 1 (某些国家/地区有一些财务指标和GDP增长)

I have the same problem like R - Error in class(x) - plm - only within and random effects models. Here is the link to my data: https://www.dropbox.com/s/8tgeyhxeb0wrdri/my_data.xlsx?raw=1 (there are some financial measures and GDP growth for some countries)

我的代码:

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)

我收到的错误消息:

class(x)中的错误<-setdiff(class(x),"pseries"):除非Dimension属性的长度为2(为0),否则将类设置为矩阵无效

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)

有什么问题吗?

推荐答案

请勿使用环境中的变量(就像您对YX所做的操作一样-无需创建它们).而是在plmformula参数中使用变量名称,因为它们出现在数据pdata中:

Do not use variables from the environment (like you have done with Y and X - no need to create those). Rather, use in the formula argument of plm the variable names as they occur in your data 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.14296

这篇关于R -plm-内部效应模型和随机效应模型中的误差(合并,第一次差异之间起作用)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆