Description Usage Arguments Value Note Author(s) References Examples
View source: R/multi.collinear.R
Test for multi-collinearity in data using qr-matrix decomposition
1 2 | multi.collinear(x, perm = FALSE, leave.out = FALSE, n = 99,
p = 0.0000001, na.rm = FALSE)
|
x |
data.frame or matrix object |
perm |
(FALSE/TRUE) Should a permutation be applied |
leave.out |
(FALSE/TRUE) Should a variable be left out at each permutation |
n |
Number of permutations |
p |
multi-collinearity threshold |
na.rm |
(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.
A permutation approach is not available where, at each iteration, the columns are randomly rearranged and a parameter dropped. The frequency that a variable is identified as collinear is accumulated. The multi-collinearity threshold needs to be adjusted based on number of parameters. For small number(s) of variables (<20) use ~1e-07 and for larger ~0.05
Jeffrey S. Evans <jeffrey_evans<at>tnc.org>
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.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
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)] )
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.