Calculates variance-inflation and generalized variance-inflation factors (VIFs and GVIFs) for linear, generalized linear, and other regression models.
vif(mod, ...)# S3 method for default
vif(mod, ...)
# S3 method for lm
vif(mod, type=c("terms", "marginal", "high-order"), ...)
# S3 method for merMod
vif(mod, ...)
# S3 method for polr
vif(mod, ...)
# S3 method for svyolr
vif(mod, ...)
for the default method, an object that responds to
coef
, vcov
, and
model.matrix
, such as a glm
object.
for unweighted lm
objects only, how to handle models that contain interactions: see Details below.
not used.
A vector of VIFs, or a matrix containing one row for each term, and columns for the GVIF, df, and \(GVIF^{1/(2\times df)}\), the last of which is intended to be comparable across terms of different dimension.
If all terms in an unweighted linear model have 1 df, then the usual variance-inflation factors are calculated.
If any terms in an unweighted linear model have more than 1 df, then generalized variance-inflation factors (Fox and Monette, 1992) are calculated. These are interpretable as the inflation in size of the confidence ellipse or ellipsoid for the coefficients of the term in comparison with what would be obtained for orthogonal data.
The generalized VIFs are invariant with respect to the coding of the terms in the model (as long as the subspace of the columns of the model matrix pertaining to each term is invariant). To adjust for the dimension of the confidence ellipsoid, the function also prints \(GVIF^{1/(2\times df)}\) where \(df\) is the degrees of freedom associated with the term.
Through a further generalization, the implementation here is applicable as well to other sorts of models, in particular weighted linear models, generalized linear models, and mixed-effects models.
Three methods of computing GVIFs are provided for unweighted linear models:
Setting type="terms"
(the default) behaves like the default method, and computes the GIF for each term in the model, ignoring relations of marginality among the terms in models with interactions.
Setting type="marginal"
focuses in turn on each term in the model but ignores terms that are higher-order relatives of the focal term; e.g., in the model with formula y ~ a*b + c
, the the GVIF for the main effect a
ignores the interaction a:b
to which a
is marginal.
Setting type="high-order"
computes a GVIF for each high-order term in the model, absorbing the lower-order relatives of the term (i.e., terms that are marginal to the focal term); thus, in the model with formula y ~ a*b + c
, GVIFs are computed for a:b
and c
, and the former includes the terms a
, b
, and a:b
(and is labelled a*b
).
Specific methods are provided for ordinal regression model objects produced by polr
in the MASS package and svyolr
in the survey package, which are "intercept-less"; VIFs or GVIFs for linear and similar regression models without intercepts are generally not sensible.
Fox, J. and Monette, G. (1992) Generalized collinearity diagnostics. JASA, 87, 178--183.
Fox, J. (2016) Applied Regression Analysis and Generalized Linear Models, Third Edition. Sage.
Fox, J. and Weisberg, S. (2018) An R Companion to Applied Regression, Third Edition, Sage.
# NOT RUN {
vif(lm(prestige ~ income + education, data=Duncan))
vif(lm(prestige ~ income + education + type, data=Duncan))
vif(lm(prestige ~ (income + education)*type, data=Duncan),
type="high-order")
vif(lm(prestige ~ (income + education)*type, data=Duncan),
type="marginal")
# }
Run the code above in your browser using DataLab