You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since the commit f2ad13509ba3d6ab28069840c9631a66a9e7ecc8 the function findCorrelation_exact in the row 38 are computing the wrong mean absolute correlation to the mn2. The function are calculating the mean of the matrix without the variable j instead of calculate the mean of variable j against the another variables.
Have 2 possible solutions, the first one is remove the minus sign of the j, so you will compare 2 different rows of the matrix, but the output when the verbose = TRUE prints: "Compare row i and column j with corr..." and even if the row and column are mirrored(the same) this is a incorrect text. Then we have the second option: remove the minus sign and change the j to the column position.
#before the commit
(mean(x[i, -i]) > mean(x[-j, j]) #compare the mean of two vectors#after the commitmn1<- mean(x2[i,], na.rm=TRUE) #return the mean of a vectormn2<- mean(x2[-j,], na.rm=TRUE) #return the mean of a matrix#possible solution 1mn2<- mean(x2[j,], na.rm=TRUE) #return the mean of the row #possible solution2mn2<- mean(x2[, j], na.rm=TRUE) #return the mean of the column
reprex:
require(tidyverse)
#> Carregando pacotes exigidos: tidyverseiris<-datasets::iriscor_mat<- as.matrix(iris[,1:4]) %>% cor()
#Finding correlation manually ----## Example with row 3 and column 4 ----
diag(cor_mat) <-NAcor_mat<- abs(cor_mat)
i<-3#simulating the i-th iteraction when i = 3j<-4#simulating the j-th iteraction when j = 4mn1<- mean(cor_mat[i,], na.rm=TRUE)
mn2<- mean(cor_mat[,j], na.rm=TRUE)
cat("Compare row", i, " and column ", j,
"with corr ", round(cor_mat[i,j], 3), "\n",
" Means: ", round(mn1, 3), "vs", round(mn2,3))
#> Compare row 3 and column 4 with corr 0.963 #> Means: 0.754 vs 0.716## Example with row 4 and column 1 ----cor_mat[3,] <-NA#removing row 3 and column 3 to simulate the iteraction of the function, based on the previous stepcor_mat[,3] <-NAi<-4#simulating the i-th iteraction when i = 3j<-1#simulating the j-th iteraction when j = 4mn1<- mean(cor_mat[i,], na.rm=TRUE)
mn2<- mean(cor_mat[,j], na.rm=TRUE)
cat("Compare row", i, " and column ", j,
"with corr ", round(cor_mat[i,j], 3), "\n",
" Means: ", round(mn1, 3), "vs", round(mn2,3))
#> Compare row 4 and column 1 with corr 0.818 #> Means: 0.592 vs 0.468#Finding correlation with findCorrelation_exact ----iris<-datasets::iriscor_mat<- as.matrix(iris[,1:4]) %>% cor()
vars_cor<-caret::findCorrelation(
cor_mat,
cutoff=0.7,
names=T,
exact=T,
verbose=T)
#> Compare row 3 and column 4 with corr 0.963 #> Means: 0.754 vs 0.554 so flagging column 3 #> Compare row 4 and column 1 with corr 0.818 #> Means: 0.592 vs 0.417 so flagging column 4 #> All correlations <= 0.7
I'm not sure which package this issue is meant to target, but it's not reprex. reprex is just a reporting tool, i.e. the thing that helps you render the code above nicely, for pasting into a GitHub issue. But it still needs to go into the GitHub issues of the package you're struggling with (caret maybe?). If I'm right, this is the place to go: https://github.com/topepo/caret/issues.
Since the commit
f2ad13509ba3d6ab28069840c9631a66a9e7ecc8
the functionfindCorrelation_exact
in the row 38 are computing the wrong mean absolute correlation to themn2
. The function are calculating the mean of the matrix without the variablej
instead of calculate the mean of variablej
against the another variables.Have 2 possible solutions, the first one is remove the minus sign of the
j
, so you will compare 2 different rows of the matrix, but the output when theverbose = TRUE
prints: "Compare row i and column j with corr..." and even if the row and column are mirrored(the same) this is a incorrect text. Then we have the second option: remove the minus sign and change the j to the column position.reprex:
Created on 2024-10-23 with reprex v2.1.1
The text was updated successfully, but these errors were encountered: