calc_vif: Variance inflation factor (VIF)

View source: R/calc_vif.R

calc_vifR Documentation

Variance inflation factor (VIF)

Description

Calculates variance-inflation linear, generalized linear, and other models.

I found this function on StackOverflow The function vif from the car package would be my preference but I wanted to put this one somewhere for posterity.

Usage

calc_vif(fit)

Arguments

fit

An lm or glm object

Value

A tbl_df

Examples

library(car)

# Using the car package
car::vif(lm(prestige ~ income + education, data = Duncan))
car::vif(lm(prestige ~ income + education + type, data = Duncan))

# User defined function
calc_vif(lm(prestige ~ income + education, data = Duncan))
calc_vif(lm(prestige ~ income + education + type, data = Duncan))

# Another example using glm
model1 <- glm(case ~ spontaneous + induced,
              data = infert,
              family = binomial(link = "logit"))
summary(model1)
car::vif(model1)
calc_vif(model1)

emilelatour/lamisc documentation built on April 9, 2024, 10:33 a.m.