vif_step: Step-wise VIF Selection

View source: R/vif_step.R

vif_stepR Documentation

Step-wise VIF Selection

Description

Detects and removes multi-collinearity via step-wise VIF selection.

Usage

vif_step(data, ignore = c(), thresh = 5, trace = TRUE, remove = TRUE)

Arguments

data

dataset to be analysed.

ignore

columns in dataset to be not removed. Only relevant if remove is TRUE.

thresh

threshold of VIF for variables to be removed.

trace

a logical to indicate if the sequence of which variables are removed should be printed to the console.

remove

a logical to indicate if variables with VIF higher than thresh should be removed. #' If FALSE, only the VIF for each variable will be output and no variables will be removed. #' Default is TRUE.

Details

Calculates the VIF for each variable in the dataset. If remove is FALSE, then a data.table of the VIFs will be output. If remove is TRUE, then if the variable with the highest VIF has a VIF greater than thresh, that variable will be removed. This process is repeated sequentially until all variables have a VIF lower than thresh. Specifying trace to be TRUE will print the VIFs of the current selection of variables for each iteration of the above process. The ignore argument only applies when remove has been set to TRUE. It is a vector of variables in the dataset which should not be removed. However, the VIFs for these variables are still calculated and output.

Value

list containing dataset with variables with high VIF removed and a data.table of VIF for final selected variables.

Examples

## Not run: 
if(interactive()){
 data(property_prices)
 vif_data(property_prices, thresh = 2, trace = TRUE, remove = TRUE)
 }

## End(Not run)

Nanoputian628/nano documentation built on Oct. 30, 2023, 3:28 p.m.