Skip to contents

This function takes a dataframe with several models and calculates the maximum Variance Inflation Factor (VIF) for a given model. And either filters out the ones with high collinearity or it flags them accordingly

Usage

filter_vif(
  all_forms,
  env_data,
  ncores = 2,
  filter = TRUE,
  threshold = 5,
  verbose = TRUE
)

Arguments

all_forms

A data frame generated by make_models

env_data

A dataset with the variables described in all_froms

ncores

An integer specifying the number of cores to use for parallel processing

filter

logical, if TRUE it filters out the models with a maximum VIF of high or higher, if FALSE it generates a new column called collinearity, wich will

threshold

A numeric value specifying the threshold for filtering models based on maximum VIF (default is 5)

verbose

logical, defaults TRUE, sends messages about processing times

Value

A data.frame with the models, fitering out the ones with high collinearity or flagginf them.

Examples

# \donttest{
library(vegan)
data(dune)
data(dune.env)
AllModels <- make_models(vars = c("A1", "Moisture", "Manure"))
#> 1 of 3 ready 2024-01-22 11:57:54.822996
#> 2 of 3 ready 2024-01-22 11:57:57.647361
#> 3 of 3 ready 2024-01-22 11:57:59.192774

filter_vif(
  all_forms = AllModels,
  env_data = dune.env
)
#>                                form  max_vif
#> 1                     Distance ~ A1 0.000000
#> 2               Distance ~ Moisture 0.000000
#> 3                 Distance ~ Manure 0.000000
#> 4          Distance ~ A1 + Moisture 3.000000
#> 5            Distance ~ A1 + Manure 4.000000
#> 6      Distance ~ Moisture + Manure 4.000000
#> 7 Distance ~ A1 + Moisture + Manure 4.508169
#> 8                      Distance ~ 1 0.000000
# }