Calculates the maximum absolute correlation between two matrices along the columns
calc.maxcor(x1, x2)
x1 | Named matrix 1 |
---|---|
x2 | Named matrix 2 |
A vector of maximum absolute correlations
This function calculates the maximum absolute correlation for each column of
x2
against each column of x1
. The matrices are named and if
the names overlap between x1
and x2
, the correlation between
the same named entries is set to zero.
x1 <- matrix(rnorm(500), 100, 5) x2 <- x1 + matrix(rnorm(500), 100, 5) colnames(x1) <- c("A", "B", "C", "D", "E") colnames(x2) <- c("A", "B", "C", "D", "E") cor(x1, x2)#> A B C D E #> A 0.74255671 -0.1274772 -0.001755278 0.18580206 -0.074205800 #> B 0.07273502 0.7648151 0.228241533 0.05528077 -0.002939389 #> C 0.11720824 0.1535741 0.711288565 -0.06448206 -0.011112761 #> D 0.13072425 0.1485269 -0.174989494 0.73573306 0.135864247 #> E -0.14547079 0.1061166 0.039027398 0.11145791 0.741516176calc.maxcor(x1, x2)#> A B C D E #> 0.1454708 0.1535741 0.2282415 0.1858021 0.1358642