Re: corr & corrcoef
- From: "Tom Lane" <tlane@xxxxxxxxxxxxx>
- Date: Thu, 26 Jun 2008 14:49:28 -0400
Yes, we are talking about the diagonal of the Pvalue ...
Let me try:
r =x = rand(10,2);
[r,p] = corrcoef(x)
1.0000 0.2682
0.2682 1.0000
p =
1.0000 0.4537
0.4537 1.0000
r =[r,p] = corr(x)
1.0000 0.2682
0.2682 1.0000
p =
0 0.4537
0.4537 0
Both corr and corrcoef produce the same correlation between the x columns
(0.2682) and the same p-value for it (0.4537).
It generally doesn't make sense to test whether a variable is correlated
with itself. So corrcoef gives 1 along the diagonal of the correlation
matrix, but gives 1 as its p-value. That way if you search for significant
correlations, you'll never flag the diagonal as significant.
The corr function is a little more general and can compute correlations
between pairs of columns from two different inputs. In that case the result
won't necessarily be square, it won't necessarily have 1's along the
diagonal, and a correlation of 1 is highly significant. So it gives the
p-value as 0 when the correlation is 1. But still, if you compute a
correlation matrix for a single input, the entries along the diagonal are
necessarily 1 and the p-value is not meaningful.
So it's perhaps unfortunate that these two functions have adopted different
conventions for what to put along the diagonal for the matrix of p-values
when there's a single input matrix, but you don't want to use those diagonal
values anyway.
-- Tom
.
- References:
- corr & corrcoef
- From: Lorenzo Guerrasio
- Re: corr & corrcoef
- From: Peter Perkins
- Re: corr & corrcoef
- From: Lorenzo Guerrasio
- Re: corr & corrcoef
- From: Peter Perkins
- Re: corr & corrcoef
- From: Lorenzo Guerrasio
- Re: corr & corrcoef
- From: Peter Perkins
- Re: corr & corrcoef
- From: Lorenzo Guerrasio
- Re: corr & corrcoef
- From: Peter Perkins
- corr & corrcoef
- Prev by Date: Re: How to get only odd numbers or even number from a given series
- Next by Date: Re: Aliasing demonstration
- Previous by thread: Re: corr & corrcoef
- Next by thread: Convert .txt to .jpg
- Index(es):
Relevant Pages
|