[R] cor(X) with P-Value

From: Worik Turei stanton <turwa720_at_student.otago.ac.nz>
Date: Sat 23 Jul 2005 - 20:33:55 EST


Friends

I am new to R (and statistics) so am struggling a bit.

Briefly...

I am interested in getting the P-Value from cor(X) where X is a matrix.

I have found cor.test.

Verbosely...

I have 4 vectors and can generate the corellation matrix...

> cor(cbind(X1, X2, X3, X4))

            X1 X2 X3 X4

X1  1.00000000 -0.06190365 -0.156972795  0.182547517
X2 -0.06190365  1.00000000  0.264352860  0.146750844
X3 -0.15697279  0.26435286  1.000000000 -0.006380052
X4  0.18254752  0.14675084 -0.006380052  1.000000000

But I want the P-Values (gives me the significance I belive).

> cor.test(X2, X3)

        Pearson's product-moment correlation

data: X2 and X3
t = 3.3346, df = 148, p-value = 0.001080 alternative hypothesis: true correlation is not equal to 0 95 percent confidence interval:
 0.1086963 0.4073565
sample estimates:

      cor
0.2643529

is very cool. Just what I want. But there is too much information for too little data.

What I would like to do is some thing like...

cor_with_p_test(cbind(X1, X2, X3, X4))

     X1           X2              X3
X1    1          -0.06190365      -0.1569728...
P                0.4517           0.05507   ...

X2  -0.06190365  1                0.2643529 ...
P   0.4517                        0.001080  ...
:
:

I think I could write a function for it if such a function does not exist if I could do...

> CT23 <- cor.test(X2, X3)
> CT23$P

0.001080
> CT23$V

0.2643529

But I do not know how.

cheers
Worik



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Sat Jul 23 20:40:53 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:33:58 EST