0

I'm trying to test for multi-collinearity in a multinomial logistic regression model I've set up. The data contains 13 variables on over 33000 observations. 9 of the variables are categorical factor variables and the remaining 3 are numeric/continuous variables. I ran and multinom logistic regression model from the nnet package that looked like this

my.model = multinom(dependent.var ~., data = training data)

which worked (despite being not very good). I then ran the VIF function from car and the GVIF results for every variable came back as "NaN" with a warning message:

Warning message: In vif.default(multi.model) : No intercept: vifs may not be sensible.

Why does the issue keep occurring?

Thanks

  • Hi Chris and welcome to StackOverflow! Can you try to provide a reprex, or some of your code by typing `dput(df)` into the console? Please see here about creating a reprex: https://stackoverflow.com/help/minimal-reproducible-example – Matt Apr 07 '20 at 17:50

1 Answers1

0

If you look at the vif called (car:::vif.default), there is a line in the code:

if (names(coefficients(mod)[1]) == "(Intercept)") {
        v <- v[-1, -1]
        assign <- assign[-1]
    }
    else warning("No intercept: vifs may not be sensible.")

So, we can use an example below to demonstrate why it returns the error:

library(nnet)
fit = multinom(Species ~.,data=iris)
vif(fit)
 Sepal.Length   Sepal.Width  Petal.Length   Petal.Width 
-1.878714e+16 -8.846005e+15 -1.827592e+15 -4.954974e+15 
Warning message:
In vif.default(fit) : No intercept: vifs may not be sensible.

Same error, and we look at the coefficients:

coefficients(fit)
           (Intercept) Sepal.Length Sepal.Width Petal.Length Petal.Width
versicolor    18.69037    -5.458424   -8.707401     14.24477   -3.097684
virginica    -23.83628    -7.923634  -15.370769     23.65978   15.135301

names(coefficients(fit))
NULL

Because it is multinomial, the coefficients are stored as a matrix (using one class as reference, you estimate log-odds of other classes), hence the names() function doesn't work, and returns you the error.

StupidWolf
  • 45,075
  • 17
  • 40
  • 72
  • Aw okay, that makes sense. My issue now is that the VIF values that are returned from the function are all NaNs? – ChrisAirth Apr 08 '20 at 09:40
  • hey in that case can you share the data. Does the model fit correctly? For example, if you do summary(my.model) what do you see. Could you update your question according to that? Thanks! – StupidWolf Apr 08 '20 at 09:42
  • 1
    Found the source of the problem! I had one variable loaded that was set as an integer when it should have been a factor, whole system works now, thank you for your help! – ChrisAirth Apr 08 '20 at 09:54