vif_step | R Documentation |
Detects and removes multi-collinearity via step-wise VIF selection.
vif_step(data, ignore = c(), thresh = 5, trace = TRUE, remove = TRUE)
data |
dataset to be analysed. |
ignore |
columns in dataset to be not removed. Only relevant if |
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 |
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.
list containing dataset with variables with high VIF removed and a data.table of VIF for final selected variables.
## Not run:
if(interactive()){
data(property_prices)
vif_data(property_prices, thresh = 2, trace = TRUE, remove = TRUE)
}
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.