Path: news.mathworks.com!not-for-mail
From: Peter Perkins <Peter.Perkins@MathRemoveThisWorks.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Why p-value is NaN or 0 using corrcoef ?
Date: Tue, 14 Apr 2009 10:56:14 -0400
Organization: The MathWorks, Inc.
Lines: 22
Message-ID: <gs286e$qjv$1@fred.mathworks.com>
References: <gs0631$am3$1@fred.mathworks.com>
NNTP-Posting-Host: perkinsp.dhcp.mathworks.com
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: fred.mathworks.com 1239720974 27263 172.31.57.88 (14 Apr 2009 14:56:14 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 14 Apr 2009 14:56:14 +0000 (UTC)
User-Agent: Thunderbird 2.0.0.21 (Windows/20090302)
In-Reply-To: <gs0631$am3$1@fred.mathworks.com>
Xref: news.mathworks.com comp.soft-sys.matlab:532640


Kuo-Hsien wrote:
> I play around with [R,sig] = corrcoef(a,b)

I recommend typing "which -all corrcoef".  It appears that you are not using the corrcoef that ships with MATLAB, or at least not from anything like a recent version.  The correct behavior would be this:

>> a = [1 2 3 4 5 6]';
>> b = [3 4 5 6 7 8]';
>> [R,sig] = corrcoef(a,b)
R =
     1     1
     1     1
sig =
     1     0
     0     1

and NaNs in your other cases, whcih should lead you to read this:

        'rows'     Either 'all' (default) to use all rows, 'complete' to
                   use rows with no NaN values, or 'pairwise' to compute
                   R(i,j) using rows with no NaN values in column i or j.

in the help for corrcoef.