0

I'm trying to perform a VIF on a multivariate regression model, but when I ran the vif function in r I get an error.

Code and error below:

vif(analys3.lm)
Error in if (names(coefficients(mod)[1]) == "(Intercept)") { : 
  argument is of length zero

The intercept is still there in my model though.

analys3.lm<- lm(formula = cbind(df$col1,  
                                df$col2) ~  
                  df$col3+ df$col4,
data = df)
IRTFM
  • 258,963
  • 21
  • 364
  • 487
Barbara
  • 1,118
  • 2
  • 11
  • 34
  • What's `analys3.lm`? Can you show us how to create it, or something like it, that has the same problem? – Spacedman Nov 01 '17 at 07:49
  • @Spacedman I edited my question and added the information on `analys3.lm` – Barbara Nov 01 '17 at 08:27
  • 2
    I'm guessing that `VIF` can't deal with an `mlm` object (multiple DVs). Run separate models and check them. Also, you should omit `df$` from the formula. – Roland Nov 01 '17 at 08:39
  • @Roland thanks, that worked perfectly. If you put it as an answer I can select it. – Barbara Nov 01 '17 at 08:59
  • 1
    You should explain where your `vif` function comes from, there's several packages with a `vif` function (car, rms,...) and MASS isn't one of them, so I don't know why you've tagged it with "mass". – Spacedman Nov 01 '17 at 09:43

1 Answers1

1

Apparently, vif can't deal with an mlm object (multiple DVs). Run separate models and check them.

Roland
  • 127,288
  • 10
  • 191
  • 288
  • The help page for `car::vif` says: "VIFs or GVIFs for linear and similar regression models without intercepts are generally not sensible." – IRTFM Nov 10 '22 at 22:55