Path: news.mathworks.com!not-for-mail
From: "Tom Lane" <tlane@mathworks.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: calculate P value from r
Date: Tue, 16 Jun 2009 11:11:54 -0400
Organization: The MathWorks, Inc
Lines: 22
Message-ID: <h18cnq$8f9$1@fred.mathworks.com>
References: <h0va0q$qo3$1@fred.mathworks.com>
Reply-To: "Tom Lane" <tlane@mathworks.com>
NNTP-Posting-Host: lanet.dhcp.mathworks.com
X-Trace: fred.mathworks.com 1245165114 8681 172.31.57.151 (16 Jun 2009 15:11:54 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 16 Jun 2009 15:11:54 +0000 (UTC)
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.5512
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579
Xref: news.mathworks.com comp.soft-sys.matlab:547953


> 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