Re: corr & corrcoef



Lorenzo Guerrasio wrote:
So the only difference is in how P is calculate?
x=0:0.1:10;
y=x.^2+rand(1,101);
plot(x,y)
X=[x(:),y(:)];
[a,b]=corrcoef(X)
[c,d]=corr(X)

b and d are different: diag(b)=1 1, diag(d)=0 0

Why is that?

Lorenzo, I'm curious what you think the right answer is, and why it would be useful.

CORRCOEF only accepts a single input, thus the diagonal elements necessarily correspond to a correlation of a variable with itself, which necessarily is 1, and therefore the p-value is 0. CORR allows "cross correlation" (although you aren't using that syntax), and so the diagonal elements could be correlations between two variables, and if the two vectors of values happen to be identical, then the correlation is 1, but the p-value is 0.
.



Relevant Pages

  • Re: corr & corrcoef
    ... Both corr and corrcoef produce the same correlation between the x columns ... and the same p-value for it. ...
    (comp.soft-sys.matlab)
  • What does it MEAN?
    ... Pearson Product Moment Correlation - Ungrouped Data ... p-value = 0.0249951301761135 ...
    (sci.stat.math)
  • Re: What does it MEAN?
    ... Pearson Product Moment Correlation - Ungrouped Data ... The way the P-value is ...
    (sci.stat.math)
  • Re: p-values for partial correlation
    ... > suppose I have computed a correlation between X and Y and I have ... When the sample size is large, the null distribution of a Spearman r ... is close to that of a Pearson r, and a p-value can be obtained by ... Spearman r as if it were a partial Pearson r: ...
    (sci.math)