[R] Individual p-values for correlation matrices

January Weiner january.weiner at gmail.com
Sat Aug 13 16:43:45 CEST 2011


Dear all,

I am calculating each-against-each correlations for a number of
variables, in order to use the correlations as distances. This is easy
enough using just cor(), but not if I want to have a p-value for each
calculated correlation, and especially if I want to correct them for
multiple testing (but see below). I do that currently "on foot",
looping around the variables to apply cor.test to each combination of
two variables. Is there a function or a package that would do that for
me?

Specifically, what I do is

# a is the data matrix
for( i in 1:ncol( a ) ) {
  for( j in (i+1):ncol(a) ) {
    result <- cor.test( a[,i], a[,j], method="spear" )
    # store the result somehow
  }
}

This is slow and I seek a better solution.

As I mentioned before, I correct the p-values using Bonferroni
correction, which does not assume independence of the hypotheses to be
tested (obviously that is the case here). However, is there a better
method to do this? Bonferroni results in a large number of false
negatives.

Kind regards,

j.

-- 
-------- Dr. January Weiner 3 --------------------------------------



More information about the R-help mailing list