cor.test() p 值与手动不同?
cor.test() p value different than by hand?
使用 cor.test() 的 p 值与手动不同。我不知道我到底错过了什么。任何帮助将不胜感激!
Pearson's product-moment correlation
data: GSSE_new$MusicPerceptionScores and GSSE_new$MusicAptitudeScores
t = 27.152, df = 148, p-value < 2.2e-16
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
0.8811990 0.9359591
sample estimates:
cor
0.9125834
#######
2*pt(q=MPMA_cortest$statistic, df=MPMA_cortest$parameter, lower.tail=FALSE)
[1] 2.360846e-59
由于您没有提供 Minimal Reproducible Example 实际数据,我无法确认您自己的数据,但这里有一个程序显示手动版本等于 cor.test
p 值:
MPMA_cortest <- cor.test(mtcars$hp, mtcars$mpg)
p_manual <- pt(
q = abs(MPMA_cortest$statistic),
df = MPMA_cortest$parameter,
lower.tail = FALSE) * 2
p_manual == MPMA_cortest$p.value
#> t
#> TRUE
编辑:另请注意,cor.test
打印输出仅显示 p-value < 2.2e-16
。这两个值很可能完全相等(你的值较小,因此满足不等式条件)。
使用 cor.test() 的 p 值与手动不同。我不知道我到底错过了什么。任何帮助将不胜感激!
Pearson's product-moment correlation
data: GSSE_new$MusicPerceptionScores and GSSE_new$MusicAptitudeScores
t = 27.152, df = 148, p-value < 2.2e-16
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
0.8811990 0.9359591
sample estimates:
cor
0.9125834
#######
2*pt(q=MPMA_cortest$statistic, df=MPMA_cortest$parameter, lower.tail=FALSE)
[1] 2.360846e-59
由于您没有提供 Minimal Reproducible Example 实际数据,我无法确认您自己的数据,但这里有一个程序显示手动版本等于 cor.test
p 值:
MPMA_cortest <- cor.test(mtcars$hp, mtcars$mpg)
p_manual <- pt(
q = abs(MPMA_cortest$statistic),
df = MPMA_cortest$parameter,
lower.tail = FALSE) * 2
p_manual == MPMA_cortest$p.value
#> t
#> TRUE
编辑:另请注意,cor.test
打印输出仅显示 p-value < 2.2e-16
。这两个值很可能完全相等(你的值较小,因此满足不等式条件)。