[英]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
。 這兩個值可能完全相等(您的值較小,因此滿足不等式條件)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.