有因素时测试多重共线性

时间:2011-05-28 15:43:58

标签: r statistics

是否可以在具有Dummyvariables的模型中检查多重共线性?假设以下示例

treatment <- factor(rep(c(1, 2), c(43, 41)), levels = c(1, 2), labels = c("placebo", "treated"))
improved <- factor(rep(c(1, 2, 3, 1, 2, 3), c(29, 7, 7, 13, 7, 21)), levels = c(1, 2, 3), labels = c("none", "some", "marked"))
numberofdrugs <- rpois(84, 5)+1
healthvalue <- rpois(84,5)
y <- data.frame(healthvalue,numberofdrugs, treatment, improved)

test <- lm(healthvalue~numberofdrugs+treatment+improved, y)

当我想检查这种模型中是否存在多重共线性时,我该怎么做?

1 个答案:

答案 0 :(得分:7)

您可以计算预测变量的VIF来量化多重共线性的数量:

library(car)
vif(test)
                  GVIF Df GVIF^(1/(2*Df))
numberofdrugs 1.035653  1        1.017670
treatment     1.224984  1        1.106790
improved      1.193003  2        1.04510