0
我幾天前開始使用R studio,並且我正在努力計算一個VIF。這是的情況:在R中執行VIF測試
我有一個面板數據,並運行固定效應和隨機效應迴歸。我有一個從屬變量(New_biz_density)和2個獨立變量(Cost_to_start,Capital_requirements)。我想通過計算它們的方差膨脹因子來檢查我的兩個獨立變量是否表現出多重共線性,包括固定效應模型和隨機效應模型。
我已經安裝了一些包來執行BIF(遠景,汽車),但沒有設法做到這一點。有人知道該怎麼做嗎?
非常感謝!
這裏是我的腳本:
# 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)