Interpreting and plotting car::vif() with categorical variable

Viewed 14

I am trying to use vif() from the car package to calculate VIF values after a regression based on this guide.

Without any categorical variables you get output that looks like this:

#code    
model <- lm(mpg ~ disp + hp + wt + drat, data = mtcars)
vif_values <- vif(model)
vif_values
barplot(vif_values, main = "VIF Values", horiz = TRUE, col = "steelblue")
abline(v = 5, lwd = 3, lty = 2)

    disp       hp       wt     drat 
8.209402 2.894373 5.096601 2.279547 

enter image description here

However, the output changes if you add a categorical variable:

mtcars$cat <- sample(c("a", "b", "c"), size = nrow(mtcars), replace = TRUE)
model <- lm(mpg ~ disp + hp + wt + drat + cat, data = mtcars)
vif_values <- vif(model)
vif_values

         GVIF Df GVIF^(1/(2*Df))
disp 8.462128  1        2.908974
hp   3.235798  1        1.798832
wt   5.462287  1        2.337154
drat 2.555776  1        1.598679
cat  1.321969  2        1.072273

Two questions: 1. How do I interpret this different output? Is the GVIF equivalent to the numbers output in the first version? 2. How do I make a nice bar chart with this the way the guide shows?

0 Answers
Related