为什么 Phi 系数近似于 Pearson 的相关性?

机器算法验证 r 相关性
2022-03-21 02:12:00

浏览关于 Phi 系数的Wiki 文章,我注意到对于成对的二进制数据,“为两个二进制变量估计的 Pearson 相关系数将返回 phi 系数”。

在运行快速模拟后,我发现情况并非如此。但是,似乎 phi 系数确实接近 pearson 的相关系数。

x <- c(1,   1,  0,  0,  1,  0,  1,  1,  1)
y <- c(1,   1,  0,  0,  0,  0,  1,  1,  1)
cor(x,y)
sqrt(chisq.test(table(x,y))$statistic/length(x)) # phi

x <- rep(x, 1000)
y <- rep(y, 1000)
sqrt(chisq.test(table(x,y))$statistic/length(x)) # phi
# it now DOES approximates the pearsons correlation.
cor(x,y)

但我不清楚为什么(数学上)会出现这种情况。

1个回答

默认情况下,chisq.test()在计算 2x2 表的检验统计量时应用连续性校正。如果您关闭此行为,则:

x = c(1,  1,  0,  0,  1,  0,  1,  1,  1)
y = c(1,  1,  0,  0,  0,  0,  1,  1,  1)
cor(x,y)
sqrt(chisq.test(table(x,y), correct=FALSE)$statistic/length(x)) # phi

会给你完全相同的答案。这基本上也回答了为什么χ2/n与连续性校正近似cor(x,y)- 如n增加,连续性校正对结果的影响越来越小。

这里描述了连续性校正:Yates's Correction for Continuous