auto_vif {spatialRF}R Documentation

Multicollinearity reduction via Variance Inflation Factor

Description

Selects predictors that are not linear combinations of other predictors by using computing their variance inflation factors (VIF). Allows the user to define an order of preference for the selection of predictors. Warning: variables in preference.order not in colnames(x), and non-numeric columns are removed silently from x and preference.order. The same happens with rows having NA values (na.omit() is applied). The function issues a warning if zero-variance columns are found.

Usage

auto_vif(
  x = NULL,
  preference.order = NULL,
  vif.threshold = 5,
  verbose = TRUE
)

Arguments

x

A data frame with predictors or the result of auto_cor(). Default: NULL.

preference.order

a character vector with columns names of x ordered by the user preference, Default: NULL.

vif.threshold

Numeric between 2.5 and 10 defining the selection threshold for the VIF analysis. Higher numbers result in a more relaxed variable selection. Default: 5.

verbose

Logical. if TRUE, describes the function operations to the user. Default:: TRUE

Details

This function has two modes of operation:

Can be chained together with auto_cor() through pipes, see the examples below.

Value

List with three slots:

See Also

auto_cor()

Examples

if(interactive()){

#loading data
data(plant_richness_df)

#on a data frame
out <- auto_vif(x = plant_richness_df[, 5:21])

#getting out the vif data frame
out$vif

#getting the names of the selected variables
out$selected.variables

#getting the data frame of selected variables
out$selected.variables.df

#on the result of auto_cor
out <- auto_cor(x = plant_richness_df[, 5:21])
out <- auto_vif(x = out)

#with pipes
out <- plant_richness_df[, 5:21] %>%
 auto_cor() %>%
 auto_vif()

}

[Package spatialRF version 1.1.4 Index]