1
votes

Please help! By using vif for multicollinearity come those errors:

vif (M1) Error in as.vector(y) - mean(y) : non-numeric argument to binary operator

In addition: Warning message: In mean.default(y) : argument is not numeric or logical: returning NA

My script:

library(lmtest) 
M1 <- lm(y ~ x + x1 + x2,           
          data = Mydata)
summary(M1)
library(VIF)
vif (M1)
1
You are loading the wrong package. If you want to calculate Variance Inflation Factors I suggest you use package car. VIF::vif implements VIF-regression, which is a different beast.Roland
Thank you very much!! How to load this package? Could you please write a code.Svet Lana
Dear Roland! Thank you a lot!!!!!!! It was really wrong package! Now it works! A lot of success in R and in general also to you! :))))Svet Lana

1 Answers

0
votes

You should do the following steps:

install.packages("car") 
library(car)
vif(M1)

It works for me