Dear all, I have an n x n matrix of p-values. The matrix is symmetrical, as it describes the "each against each" p values of correlation coefficients. How can I best correct the p values of the matrix? Notably, the total number of the tests performed is n(n-1)/2, since I do not test the correlation of each variable with itself. That means, I only want to correct one half of the matrix, not including the diagonal. Therefore, simply writing pmat <- p.adjust( pmat, method= "fdr" ) # where pmat is an n x n matrix ...doesn't cut it. Of course, I can turn the matrix in to a three column data frame with n(n-1)/2 rows, but that is slow and not elegant. regards, j. -- -------- Dr. January Weiner 3 -------------------------------------- Max Planck Institute for Infection Biology Charit?platz 1 D-10117 Berlin, Germany Web?? : www.mpiib-berlin.mpg.de Tel? ?? : +49-30-28460514
1. This is not an R question, AFAICS. 2. Sounds like a research topic. I don't think there's a meaningful simple answer. I suspect it strongly depends on the model and context. -- Bert On Mon, Apr 4, 2011 at 8:02 AM, January Weiner <january.weiner at mpiib-berlin.mpg.de> wrote:> Dear all, > > I have an n x n matrix of p-values. The matrix is symmetrical, as it > describes the "each against each" p values of correlation > coefficients. > > How can I best correct the p values of the matrix? Notably, the total > number of the tests performed is n(n-1)/2, since I do not test the > correlation of each variable with itself. That means, I only want to > correct one half of the matrix, not including the diagonal. Therefore, > simply writing > > pmat <- p.adjust( pmat, method= "fdr" ) > # where pmat is an n x n matrix > > ...doesn't cut it. > > Of course, I can turn the matrix in to a three column data frame with > n(n-1)/2 rows, but that is slow and not elegant. > > regards, > j. > > -- > -------- Dr. January Weiner 3 -------------------------------------- > Max Planck Institute for Infection Biology > Charit?platz 1 > D-10117 Berlin, Germany > Web?? : www.mpiib-berlin.mpg.de > Tel? ?? : +49-30-28460514 > > ______________________________________________ > R-help at 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. >-- "Men by nature long to get on to the ultimate truths, and will often be impatient with elementary studies or fight shy of them. If it were possible to reach the ultimate truths without the elementary studies usually prefixed to them, these would not be preparatory studies but superfluous diversions." -- Maimonides (1135-1204) Bert Gunter Genentech Nonclinical Biostatistics
On Apr 4, 2011, at 17:02 , January Weiner wrote:> Dear all, > > I have an n x n matrix of p-values. The matrix is symmetrical, as it > describes the "each against each" p values of correlation > coefficients. > > How can I best correct the p values of the matrix? Notably, the total > number of the tests performed is n(n-1)/2, since I do not test the > correlation of each variable with itself. That means, I only want to > correct one half of the matrix, not including the diagonal. Therefore, > simply writing > > pmat <- p.adjust( pmat, method= "fdr" ) > # where pmat is an n x n matrix > > ...doesn't cut it. > > Of course, I can turn the matrix in to a three column data frame with > n(n-1)/2 rows, but that is slow and not elegant.I don't think there's a really elegant way (have a look inside pairwise.table if you care). If you start one step further back, you could just use pairwise.table with a suitably defined comparison function. Otherwise, how about ltri <- lower.tri(pmat) utri <- upper.tri(pmat) pmat[ltri] <- p.adjust(pmat[ltri], method = "fdr") pmat[utri] <- t(pmat)[utri] -- Peter Dalgaard Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com
How about as.matrix(p.adjust(as.dist(pmat))) Benno On 4.Apr.2011, at 17:02, January Weiner wrote:> Dear all, > > I have an n x n matrix of p-values. The matrix is symmetrical, as it > describes the "each against each" p values of correlation > coefficients. > > How can I best correct the p values of the matrix? Notably, the total > number of the tests performed is n(n-1)/2, since I do not test the > correlation of each variable with itself. That means, I only want to > correct one half of the matrix, not including the diagonal. Therefore, > simply writing > > pmat <- p.adjust( pmat, method= "fdr" ) > # where pmat is an n x n matrix > > ...doesn't cut it. > > Of course, I can turn the matrix in to a three column data frame with > n(n-1)/2 rows, but that is slow and not elegant. > > regards, > j. > > -- > -------- Dr. January Weiner 3 -------------------------------------- > Max Planck Institute for Infection Biology > Charit?platz 1 > D-10117 Berlin, Germany > Web : www.mpiib-berlin.mpg.de > Tel : +49-30-28460514 > > ______________________________________________ > R-help at 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. >
Possibly Parallel Threads
- add zero in front of numbers
- Crash after (wrongly) applying product operator on object from LIMMA package
- Crash after (wrongly) applying product operator on object from LIMMA package
- A few suggestions and perspectives from a PhD student
- '==' operator: inconsistency in data.frame(...) == NULL