0

While looking at the cor.test function in R, used to compute (among others) the Pearson correlation, I saw that the t-statistics, used later to calculate the p-value is

    STATISTIC <- c(t = sqrt(df) * r/sqrt(1 - r^2))

where r is the correlation measure, and df is the number of degrees of freedom.

But the t-test for a Pearson correlation seems rather to be: (cf. http://en.wikipedia.org/wiki/Pearson_product-moment_correlation_coefficient#Testing_using_Student.27s_t-distribution)

sqrt( ( n - 2 ) / ( 1 - r^2 ) )

As always, given that the cor.test is widely used I suspect first a misunderstanding from my side. Does anyone know whether the definition used in cor.test is correct?

Thanks

4

1 回答 1

3

如果您进一步查看代码,您会发现它们实际上是等价的。

首先,您忘记了r维基百科等式中的 。你的方程应该是:

t = r*sqrt((n-2)/(1-r^2))

现在,让我们做一些简化STATISTIC <- c(t = sqrt(df) * r/sqrt(1 - r^2))

df实际上是n-2

t = sqrt(n-2)*r/sqrt(1-r^2)

重写

t = r * sqrt(n-2)/sqrt(1-r^2)

简化

t = r*sqrt((n-2)/(1-r^2))

你有你的等价物。

于 2014-11-12T16:29:22.170 回答