Learn R Programming

rfUtilities (version 2.1-5)

multi.collinear: Multi-collinearity test

Description

Test for multi-collinearity in data using qr-matrix decomposition

Usage

multi.collinear(x, perm = FALSE, leave.out = FALSE, n = 99,
  p = 0.0000001, na.rm = FALSE)

Arguments

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

Value

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.

References

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.

Examples

Run this code
# 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