Emma
Emma

Reputation: 618

matlab correlation and significant values

I have a rather simple question that needs addressing in matlab. I think I understand but I need someone to clarify I'm doing this correctly:

In the following example I'm trying to calculate the correlation between two vectors and the p values for the correlation.

dat = [1,3,45,2,5,56,75,3,3.3];
dat2 = [3,33,5,6,4,3,2,5,7];

[R,p] = corrcoef(dat,dat2,'rows','pairwise');
R2 = R(1,2).^2;
pvalue = p(1,2);

From this I have a R2 value of 0.11 and a p value of 0.38. Does this mean that the vectors are correlated by 0.11 (i.e. 11%) and this would be expected to occur 38 % of the same, so 62 % of the time a different correlation could occur?

Upvotes: 4

Views: 6403

Answers (2)

Chris Taylor
Chris Taylor

Reputation: 47392

The correlation coefficient here is

r(1,2)
ans =
  -0.3331

which is a correlation of -33.3%, which tells you that the two datasets are negatively linearly correlated. You can see this by plotting them:

plot(dat, dat2, '.'), grid, lsline

enter image description here

The p-value of the correlation is

p(1,2)
ans =
  0.3811

This tells you that even if there was no correlation between two random variables, then in a sample of 9 observations you would expect to see a correlation at least as extreme as -33.3% about 38.1% of the time.

By at least as extreme we mean that the measured correlation in a sample would be below -33.3%, or above 33.3%.

Given that the p value is so large, you cannot reliably make any conclusions about whether the null hypothesis of zero correlation should be rejected or not.

Upvotes: 3

NPE
NPE

Reputation: 500663

>> [R,p] = corrcoef(dat,dat2,'rows','pairwise')

R =

    1.0000   -0.3331
   -0.3331    1.0000


p =

    1.0000    0.3811
    0.3811    1.0000

The correlation is -0.3331 and the p-value is 0.3811. The latter is the probability of getting a correlation as large as -0.3331 by random chance, when the true correlation is zero. The p-value is large, so we cannot reject the null hypothesis of no correlation at any reasonable significance level.

Upvotes: 4

Related Questions