Skip to content

Corr(): different formula of p-value between Corr() and .Corr()

In Corr(), the formula to calculate p-value is:

 t <- qt(siglev, eno - 2)
 p_val <- sqrt((t * t) / ((t * t) + eno - 2))

which returns the same value for all correlations as long as eno are the same.

But in its inner function .Corr(), the formula is:

  if (pval && (method == "pearson")) {
    t <-sqrt(CORR * CORR * (eno - 2) / (1 - (CORR ^ 2)))
    p_val <- pt(t, eno - 2, lower.tail = FALSE)
  } 

Another problem here is, only when method == 'pearson' will the function return p_val (and also conf). In Corr(), with whichever methods, the function returns p_val and conf.