Adds the variance inflation factor (VIF) of each term of the model, or,
when a term has more than one coefficient, the generalized VIF (GVIF),
its degrees of freedom and the adjusted GVIF, GVIF^(1/(2 df)), on the
label rows of a tbl_regression() table. The factors are the ones
car::vif() reports, computed here in base R from the model's coefficient
covariance: for each term, the determinant of the correlation matrix of
its coefficients times that of the other coefficients, over the
determinant of the whole, after an intercept is set aside. A model with a
single term or aliased coefficients is an error.
Usage
add_vif(x, statistic = NULL, estimate_fun = label_style_sigfig(digits = 2))Arguments
- x
(
tbl_regression)
A regression table.- statistic
(
character)
The columns to add:"VIF"when every term has one coefficient, or any of"GVIF","aGVIF"and"df"otherwise, in the order given. Default isNULL, the factors the model has:"VIF", or"GVIF"and"aGVIF".- estimate_fun
(
function)
Formats the factors. Default islabel_style_sigfig(digits = 2).
See also
Other regression tables:
add_glance_table(),
add_global_p(),
add_n_regression,
add_nevent(),
add_significance_stars(),
combine_terms(),
glance_fun_s3(),
global_pvalue_fun(),
tbl_regression(),
tbl_uvregression()
Examples
# Example 1 ----------------------------------
lm(age ~ grade + marker, trial) |>
tbl_regression() |>
add_vif()
# Example 2 ----------------------------------
lm(age ~ grade + marker, trial) |>
tbl_regression() |>
add_vif(c("aGVIF", "df"))