Skip to content

How to calculate average correlation coefficient of a correlation matrix ?

2 messages · Amit Kumar, Chuck Cleland

#
Hi! All,
I have large correlation matrix Cor. I wish to calculate average
correlation coefficient for this matrix.
Is there any function in R to do this?
Thanks in advance.

Amit
#
On 10/13/2009 10:13 AM, Amit Kumar wrote:
cormat <- cor(iris[,1:4])

corlowtri <- cormat[lower.tri(cormat)]

corlowtri
[1] -0.1175698  0.8717538  0.8179411 -0.4284401 -0.3661259  0.9628654

mean(corlowtri)
[1] 0.2900708

mean(abs(corlowtri))
[1] 0.594116

avgcor <- function(x){mean(abs(x[lower.tri(x)]))}

avgcor(cor(iris[,1:4]))
[1] 0.594116