vif function from the car package results in NaNs? Why?

I have run glm and lm on my train dataset successfully. However when I use vif function from car package I get all NA'S for every predictor.
 X1   X2   X3   X4   X5   X6   X7   X8   X9  X10  X11  X12  X13  X14  X15  X16  X17  X18  X19  X20  X21  X22  X23  X24  X25  X26  X27  X28  X29  X30 
 NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN 

What is causing this?  Data is sensitive so I am not including it.

```{r}
suppressMessages(library(car))
vif(lm_fit)

MM

The variables may be perfectly collinear (aka “aliased”). Check the residuals from summary(your_lm) to see if they are all 0. If so, there are no degrees of freedom, so of course \dots

Residuals are not all zero but large in absolute value. All predictor correlations are above .7.

           51           720           730          2712          4922           605 
  291.1227154   141.5564672  -155.7914623  -252.5188850   -58.3384906   390.6453679

As @technocrat says, all your variables may be perfectly collinear. That does not necessarily mean that the residuals all equal zero though.

Are you using the standard car data built into R? If so , it's hard to see why it's sensitive.

If it's something else, perhaps you can post a subset of it as well as the lm() command you used.

1 Like

I won't be able to help further without a reprex. If the data are sensitive they can be anonymized.

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.