Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Caret package findCorrelation() function

Hello I am having trouble with the findCorrelation() function, Here is my input and the output:

findCorrelation(train, cutoff = .50, verbose = FALSE)

Error in findCorrelation_exact(x = x, cutoff = cutoff, verbose = verbose) : correlation matrix is not symmetric

Does anyone know why this is happening?

like image 513
statsstudent718 Avatar asked Jan 29 '16 23:01

statsstudent718


2 Answers

the findCorrelation function expects a correlation matrix as x value, so try this instead:

findCorrelation(cor(train), cutoff = .50, verbose = FALSE)

Reference: Caret pre-processing

like image 102
wotter Avatar answered Nov 12 '22 05:11

wotter


Well, it happens because the matrix possibly does not have as many columns as rows (or vice versa). E.g.

library(caret)
train <- cor(mtcars)
findCorrelation(train, cutoff = .50, verbose = FALSE)
# works
findCorrelation(train[, -1], cutoff = .50, verbose = FALSE)
# Error in findCorrelation_exact(x = x, cutoff = cutoff, verbose = verbose) : 
#   correlation matrix is not symmetric
dim(train[, -1])
# [1] 11 10

(At least that would be my guess according to the error message.)

like image 4
lukeA Avatar answered Nov 12 '22 06:11

lukeA