NOTES ON STATISTICS, PROBABILITY and MATHEMATICS


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
## Loading required package: carData
    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

NOTE: These are tentative notes on different topics for personal use - expect mistakes and misunderstandings.