drop_multicollin | R Documentation |
Drops multicollinear columns in order of highest correlation using the correlation matrix.
This function uses the cor
function from the stats
package to calculate the correlations
between columns.
drop_multicollin(allx, printprogress = TRUE)
allx |
a matrix of data to check for multicollinearity. All columns must be numeric. |
printprogress |
logical to indicate if progress should be printed out to the command line. Default is |
A list containing:
allx_noMC |
resulting data matrix of full rank after multicollinear columns have been dropped. |
dropped_cols |
column names of the dropped columns. |
# Create data with multicollinearity
data <- data.frame(x = rnorm(100),
y = sample.int(100, 100),
z = runif(100, 3, 6))
test = data.frame(mc_1 = data$x,
mc_2 = data$x * 2 + data$y - data$z)
dat = cbind(test, data)
# Run function
mc_check = drop_multicollin(dat)
mc_check$dropped_cols
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.