Skip to contents

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 is NULL, the factors the model has: "VIF", or "GVIF" and "aGVIF".

estimate_fun

(function)
Formats the factors. Default is label_style_sigfig(digits = 2).

Value

The table with one column per statistic.

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"))