VIF CALCULATION:



The function comes in the package {car} in R.

Running some regression models using the mtcars package in R, I can get the VIF both using the function and manually, when the regressor is a continuous variable:

    require(car)
## Loading required package: car
    attach(mtcars)

    fit1 <- lm(mpg ~ wt + hp + disp)     # The model we want.
    fit_wt <- lm(wt ~ hp + disp)         # Regressing wt against other regressors.
    rsq_wt <- summary(fit_wt)$r.square   # Detecting the R square of the model
    (v_wt <- 1/(1 - (rsq_wt)))           # Actual formula for VIF
## [1] 4.844618
    vif(fit1)                            # R built-in function
##       wt       hp     disp 
## 4.844618 2.736633 7.324517



Home Page