0

The p-value using cor.test() is different than by hand. I can't figure out what in the world I'm missing. Any help would be greatly appreciated!


    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
mlm1477
  • 5
  • 3

1 Answers1

1

Since you have not supplied a Minimal Reproducible Example with actual data, I cannot confirm with your own data, but here is a procedure that shows the manual version is equal to the cor.test p value:

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

Edit: Also note that the cor.test printout only says p-value < 2.2e-16. The two values may well be exactly equal (yours is smaller, thus meeting the inequality condition).

Vincent
  • 15,809
  • 7
  • 37
  • 39