Last chance! 50% off unlimited learning
Sale ends in
Test for multi-collinearity in data using qr-matrix decomposition
multi.collinear(x, perm = FALSE, leave.out = FALSE, n = 99,
p = 0.0000001, na.rm = FALSE)
data.frame or matrix object
(FALSE/TRUE) Should a permutation be applied
(FALSE/TRUE) Should a variable be left out at each permutation
Number of permutations
multi-collinearity threshold
(FALSE/TRUE) Remove NA values
If perm == TRUE a data.frame of indicating the frequency that a variable was collinear and, if leave.out = TRUE the number of times it was omitted. Otherwise, a vector of collinear variables is returned. If no colinear variables are identified a NULL is returned.
Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) The New S Language. Wadsworth & Brooks/Cole. Dongarra, J. J., Bunch, J. R., Moler, C. B. and Stewart, G. W. (1978) LINPACK Users Guide. Philadelphia: SIAM Publications.
# NOT RUN {
test <- data.frame(v1=seq(0.1, 5, length=100), v2=seq(0.1, 5, length=100),
v3=dnorm(runif(100)), v4=dnorm(runif(100)))
# Single test
( cl <- multi.collinear(test) )
# Permutated test with leave out
( cl.test <- multi.collinear(test, perm = TRUE, leave.out = TRUE, n = 999) )
cl.test[cl.test$frequency > 0,]$variables
# Remove identified variable(s)
head( test[,-which(names(test) %in% cl.test[cl.test$frequency > 0,]$variables)] )
# }
Run the code above in your browser using DataLab