vif
calculates variance-inflation and generalized variance-inflation factors for linear, generalized linear to identify collinearity among explanatory variables.
vif(model, merge_coef = FALSE)
A model object.
Logical, whether to merge with coefficients of model summary matrix. Defaults to FALSE.
A data frame with columns for variable and gvif, or additional columns for df and gvif^(1/(2*df)) if provided model uses factor variable.
data(germancredit)
# Example I
fit1 = glm(creditability~ age.in.years + credit.amount +
present.residence.since, family = binomial(), data = germancredit)
vif(fit1)
#> variable gvif
#> <char> <num>
#> 1: age.in.years 1.068963
#> 2: credit.amount 1.006434
#> 3: present.residence.since 1.063583
vif(fit1, merge_coef=TRUE)
#> variable Estimate Std. Error z value Pr(>|z|) gvif
#> <char> <num> <num> <num> <num> <num>
#> 1: (Intercept) 0.6360894980 0.2774 2.2927 0.0219 NA
#> 2: age.in.years 0.0215127873 0.0068 3.1789 0.0015 1.068963
#> 3: credit.amount -0.0001159332 0.0000 -4.8739 0.0000 1.006434
#> 4: present.residence.since -0.0514901312 0.0658 -0.7831 0.4336 1.063583
# Example II
fit2 = glm(creditability~ status.of.existing.checking.account +
credit.history + credit.amount, family = binomial(), data = germancredit)
vif(fit2)
#> variable gvif df gvif^(1/(2*df))
#> <char> <num> <num> <num>
#> 1: status.of.existing.checking.account 1.054607 3 1.008901
#> 2: credit.history 1.061760 4 1.007519
#> 3: credit.amount 1.049244 1 1.024326
vif(fit2, merge_coef=TRUE)
#> Warning: The summary matrix cant merge with vif.
#> variable gvif df gvif^(1/(2*df))
#> <char> <num> <num> <num>
#> 1: status.of.existing.checking.account 1.054607 3 1.008901
#> 2: credit.history 1.061760 4 1.007519
#> 3: credit.amount 1.049244 1 1.024326