getVIF | R Documentation |
Calculates the varience inflation factors (VIF) for linear and generalized linear models.
getVIF(mod)
mod |
A lm or glm object. |
VIF is a measure of multicolinearity. See https://en.wikipedia.org/wiki/Variance_inflation_factor for more details.
This function is a slight modificaton of the vif
function in the car
package. It has been included here to (a) reduce external dependancies, and (b) deal with some evironment name confusion (e.g. the orginal calls model.matrix
which is in both the stats
package and the SparseM
package, and in some situations the latter was incorrectly called).
For more details on the vif calculation see vif
in the car
package.
# Running a linear regression on the mtcars data set...
# ...predicting miles per gallon
m1 = lm( mpg ~ factor(cyl) + gear + carb + gear*carb,data=mtcars)
# compare VIF...
v = getVIF(m1)
# ...to tolerance (converting to numeric)
tol = as.numeric(getCoeffTolerance(m1)[-1])
# tol = 1 / vif
# but getCoeffTolerance repeats vif across factor levels
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.