Thread Subject: calculate P value from r

Subject: calculate P value from r

From: Diego Lass

Date: 13 Jun, 2009 04:30:18

Message: 1 of 2

Hi
I want to calculate P value from r without using function [r, P]=corrcoef() (because computation complexity issues):

for example:
v1 = [1 2 3 4];
v2 = [3 4 5 6];

r = v1 * ( v2' ) / sqrt( ( v1 * v1' ) * ( v2 * v2' ) );

now I want to get P from this r, how can I do it?

diego

Subject: calculate P value from r

From: Tom Lane

Date: 16 Jun, 2009 15:11:54

Message: 2 of 2

> I want to calculate P value from r without using function [r,
> P]=corrcoef() (because computation complexity issues):
...
> r = v1 * ( v2' ) / sqrt( ( v1 * v1' ) * ( v2 * v2' ) );

Diego, your formula is for a correlation coefficient not corrected for the
mean of each sample (assuming each mean is known to be zero). That's not the
usual thing done in statistics, but perhaps it is appropriate for your case.

Even if you don't want to use corrcoef, you may want to look inside that
file. There's code to transform the correlation to a t statistic, and
there's code to compute the p-value for that statistic. You'll want to use
N-1 rather than N-2 as your degrees of freedom value if you don't correct
for the mean. Alternatively, if the sample size is large, you could just use
a normal approximation to the p-value, in place of one based on Student's t
distribution.

Check out a book on regression analysis for more details.

-- Tom

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
stat Diego Lass 13 Jun, 2009 00:34:04
rssFeed for this Thread

Contact us at files@mathworks.com