Caret package findCorrelation() function
10,235
Solution 1
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
Solution 2
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.)
Solution 3
If you are using a data frame then you may have to make it into a matrix first.
corval <- findCorrelation(cor(as.matrix(train)), cutoff = 0.80, verbose = FALSE, names = FALSE)
Author by
Admin
Updated on June 17, 2022Comments
-
Admin almost 2 years
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?
-
wotter over 4 yearsI tend to agree 😀