| vif_df | R Documentation |
Computes the pairwise correlation matrix between all pairs of predictors via cor_df() and cor_matrix(), applies vif() to the resulting matrix to compute Variance Inflation Factors, and returns the result as a dataframe.
vif_df(df = NULL, predictors = NULL, quiet = FALSE, ...)
df |
(required; dataframe, tibble, or sf) A dataframe with responses
(optional) and predictors. Must have at least 10 rows for pairwise
correlation analysis, and |
predictors |
(optional; character vector or NULL) Names of the
predictors in |
quiet |
(optional; logical) If FALSE, messages are printed. Default: FALSE. |
... |
(optional) Internal args (e.g. |
dataframe with columns:
predictor: Character, predictor name.
vif: Numeric, variance inflation factor
VIF for predictor a is computed as 1/(1-R^2), where R^2 is
the multiple R-squared from regressing a on the other predictors.
Recommended maximums commonly used are 2.5, 5, and 10.
David A. Belsley, D.A., Kuh, E., Welsch, R.E. (1980). Regression Diagnostics: Identifying Influential Data and Sources of Collinearity. John Wiley & Sons. DOI: 10.1002/0471725153.
Other multicollinearity_assessment:
collinear_stats(),
cor_clusters(),
cor_cramer(),
cor_df(),
cor_matrix(),
cor_stats(),
vif(),
vif_stats()
data(vi_smol)
# ## OPTIONAL: parallelization setup
# ## irrelevant when all predictors are numeric
# ## only worth it for large data with many categoricals
# future::plan(
# future::multisession,
# workers = future::availableCores() - 1
# )
# ## OPTIONAL: progress bar
# progressr::handlers(global = TRUE)
#predictors
predictors = c(
"koppen_zone", #character
"soil_type", #factor
"topo_elevation", #numeric
"soil_temperature_mean" #numeric
)
x <- vif_df(
df = vi_smol,
predictors = predictors
)
x
## OPTIONAL: disable parallelization
#future::plan(future::sequential)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.