4

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?

4

2 回答 2

4
>> [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

相关性为 -0.3331,p 值为 0.3811。后者是当真正的相关性为零时,随机获得高达 -0.3331 的相关性的概率。p 值很大,因此我们不能在任何合理的显着性水平上拒绝无相关性的原假设。

于 2013-03-27T11:00:55.620 回答
3

这里的相关系数是

r(1,2)
ans =
  -0.3331

这是-33.3%的相关性,它告诉您两个数据集呈负线性相关。您可以通过绘制它们来看到这一点:

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

在此处输入图像描述

相关性的 p 值为

p(1,2)
ans =
  0.3811

这告诉您,即使两个随机变量之间没有相关性,那么在 9 个观察值的样本中,您预计在大约 38.1% 的时间里会看到至少与 -33.3% 一样极端的相关性。

至少在极端情况下,我们的意思是样本中测得的相关性低于 -33.3%,或高于 33.3%。

鉴于 p 值如此之大,您无法可靠地得出关于是否应拒绝零相关性的原假设的任何结论。

于 2013-03-27T11:06:17.750 回答