【发布时间】:2016-11-23 14:57:21
【问题描述】:
几天前我开始使用 R studio,但我在计算 VIF 时有点吃力。情况如下:
我有一个面板数据并运行了固定效应和随机效应回归。我有一个因变量(New_biz_density)和两个自变量(Cost_to_start,Capital_requirements)。我想通过计算固定和随机效应模型的方差膨胀因子来检查我的两个自变量是否存在多重共线性。
我已经安装了一些包来执行 VIF(Faraway、Car),但没有成功。有人知道怎么做吗?
这是我的脚本:
# install.packages("plm")
library(plm)
mydata<- read.csv("/Users/juliantabone/Downloads/DATAweakoutliers.csv")
Y <- cbind(new_biz_density)
X <- cbind(capital_requirements, cost_to_start)
# Set data as panel data
pdata <- plm.data(mydata, index=c("country_code","year"))
# Descriptive statistics
summary(Y)
summary(X)
# 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 effects 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)
# LM test for random effects versus OLS
plmtest(pooling)
# LM test for fixed effects versus OLS
pFtest(fixed, pooling)
# Hausman test for fixed versus random effects model
phtest(random, fixed)
【问题讨论】: