16  Converting to Pearson Correlation

Keywords

collaboration, confidence interval, effect size, open educational resource, open scholarship, open science

16.1 From \(t\)-statistic

From a \(t\) statistic calculated from a correlational test or an independent samples t-test, we can calculate the correlation coefficient using,

\[ r = \frac{t}{\sqrt{t^2 + n-2}}. \tag{16.1}\]

Where \(n\) is the sample size. Using the escalc() function in the metafor package (Viechtbauer 2010) we can convert \(t\) to \(r\) and we can convert the p-value from the test to \(r\).

library(metafor)

# Example:
# t = 4.14, n = 50

# calculate correlation 
# note: measure = "ZCOR" will give z-transformed correlations
stats <- escalc(measure = "COR",
                ti = 4.14,
                ni = 50,
                var.names = c("r","variance"))

# display results
summary(stats)

       r variance    sei     zi   pval  ci.lb  ci.ub 
1 0.5130   0.0111 0.1053 4.8728 <.0001 0.3066 0.7193 
# Example:
# p = .00014, n = 50

# using the p-value from the test
stats <- escalc(measure = "COR", 
                pi = .00014, 
                ni = 50)

# display results
summary(stats)

      yi     vi    sei     zi   pval  ci.lb  ci.ub 
1 0.5129 0.0111 0.1053 4.8714 <.0001 0.3065 0.7192 

16.2 From Cohen’s \(d\)

From a between groups (i.e., groups \(A\) and \(B\)) Cohen’s \(d\) value (\(d_p\)), we can calculate the correlation coefficient with the following formula:

\[ r = \frac{d_p}{\sqrt{d_p^2+\frac{n_A+n_B-2}{n_A} + \frac{n_A+n_B-2}{n_B}}} \tag{16.2}\]

Using the d_to_r function in the effectsize package we can convert \(d_p\) to \(r\).

library(effectsize)

# Example:
# d = 0.60, nA = 50, nB = 70

# calculate and display correlation
d_to_r(d = 0.60, 
       n1 = 50, 
       n2 = 70)
[1] 0.2858532

16.3 From Odds-Ratio

The correlation coefficient from an odds ratio can be calculated with the following formula:

\[ r = \frac{\log(OR)\times\sqrt{3}}{\pi\sqrt{\frac{3\log(OR)^2}{\pi^2}+\frac{n_1+n_2-2}{n_1} + \frac{n_1+n_2-2}{n_2}}} \tag{16.3}\]

Using the oddsratio_to_r() function in the effectsize package we can convert \(OR\) to \(r\).

library(effectsize)

# Example:
# OR = 2.21, n1 = 50, n2 = 70

# calculate and display correlation
oddsratio_to_r(OR = 2.21, 
               n1 = 50, 
               n2 = 70)
[1] 0.2124017