如何计算多类别响应的方差膨胀因子(vif,汽车包裹,r)?

时间:2019-02-06 14:36:49

标签: r

我想检查预测变量的多重共线性。这是我的数据(df):

y x1 x2 x3 x4 x5 1 UEWH 0.008219177835 2.210000038 52.40644836 0.3103494048 122 2 UEWH 0.008219177835 3.250000000 79.61562347 8.5430965424 187 3 UEWH 0.008219177835 2.250000000 54.93787003 17.4569702148 251 `

“ y”是四类的因数。 x1-x5都是数字。 Iam尝试向我们提供车载套件的vif功能。所以从理论上讲,我首先必须建立一个线性模型(尽管实际上是使用随机森林进行iam),然后在其上应用vif函数,对吗?但是这里出了问题:

model_vif <- lm(y ~ x1 + x2 + x3 + x4 + x5, data = df)
Warning messages:
1: In model.response(mf, "numeric") :
  using type = "numeric" with a factor response will be ignored
2: In Ops.factor(y, z$residuals) : ‘-’ not meaningful for factors

进一步错误:

> vif(model_vif)
 x1  x2  x3  x4  x5 
NaN NaN NaN NaN NaN 
 Warning messages:
1: In Ops.factor(r, 2) : ‘^’ not meaningful for factors
2: In cov2cor(v) :
  diag(.) had 0 or NA entries; non-finite result is doubtful

0 个答案:

没有答案