[R] How to calculate average correlation coefficient of a correlation matrix ?

2009-10-13 Thread Amit Kumar
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

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] How to calculate average correlation coefficient of a correlation matrix ?

2009-10-13 Thread Chuck Cleland
On 10/13/2009 10:13 AM, Amit Kumar wrote:
 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.

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

 Amit
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code. 

-- 
Chuck Cleland, Ph.D.
NDRI, Inc. (www.ndri.org)
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 512-0171 (M, W, F)
fax: (917) 438-0894

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.