Matrix with p-values with reference to a correlation matrix

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Matrix with p-values with reference to a correlation matrix

Smit, R. (Robin)
Dear mailing list member

 

I have got the following question:

The function "cor.test(x1, x2)$p.value" computes the statistical
significance of the correlation between vectors x1 and x2.

However, I have got a data matrix with many variables.

Instead of typing in all possible combinations, I was wondering if there
is perhaps an R-function that produces a matrix showing the statistical
significance (p-value) of each correlation (with a similar format as the
correlation matrix).

 

Kind regards,
Robin Smit


This e-mail and its contents are subject to the DISCLAIMER at http://www.tno.nl/disclaimer/email.html
        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: Matrix with p-values with reference to a correlation matrix

Frank Harrell
Smit, R. (Robin) wrote:

> Dear mailing list member
>
>  
>
> I have got the following question:
>
> The function "cor.test(x1, x2)$p.value" computes the statistical
> significance of the correlation between vectors x1 and x2.
>
> However, I have got a data matrix with many variables.
>
> Instead of typing in all possible combinations, I was wondering if there
> is perhaps an R-function that produces a matrix showing the statistical
> significance (p-value) of each correlation (with a similar format as the
> correlation matrix).
>
>  
>
> Kind regards,
> Robin Smit

This was answered just a few days ago in r-help.  One way is

library(Hmisc)
rcorr(data matrix)

--
Frank E Harrell Jr   Professor and Chair           School of Medicine
                      Department of Biostatistics   Vanderbilt University

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Frank Harrell
Department of Biostatistics, Vanderbilt University