# Converting between correlation and effect size (Cohen's d)

Several sources (here here here) claim that there is a relation between Cohen's d and Pearson's r if the data is paired (bivariate). This strikes me as odd since, for example, evaluating a "before and after" scenario, one could end up with "after" values being the same as "before". This would yield a Cohen's d = 0 (the mean did not change) but Pearson's r = 1 (correlation of x = y). The result in this case is completely turned around.

I'd appreciate if someone would give an explanation why this relation makes sense. Worked-out examples would also be welcome.

The relationship described for Cohen's d and Pearson's r isn't for paired data. It's for unpaired data. For r, one variable is the two groups and the other is measurement variable. I've attached a plot to illustrate this, and some R code that works through an example. As is, I think it only works if the two samples have equal numbers of observations.

Note that for the simplest statement of this relationship, d = 2*r / sqrt(1 - r^2), that the formula for Cohen's d needs to use n in the denominator for the pooled standard deviation and not n - 2, as is common. Also note that I think the formulas presented work only with equal sample sizes. The webpages provided don't seem to address these assumptions.

### At the time of writing,
###  the following code will run on https://rdrr.io/snippets/

if(!require(lsr)){install.packages("lsr")}
library(lsr)

Y = c(1,2,3,4,5,6,7,8,9,10,3,4,5,6,7,8,9,10,11,12)
Group = rep(c("A","B"), 1, each=10)
Group.n = as.numeric(factor(Group))

cohensD(Y ~ Group, method="raw")

### Note that this method uses n in the denominator,
###  not n-2, as is more usual.

### [1] 0.6963106

r = cor(Y, Group.n)
r

### [1] 0.328798

d =  2*r/sqrt(1-r^2)
d

### [1] 0.6963106

if(!require(ggplot2)){install.packages("ggplot2")}
library(ggplot2)

qplot(Group.n, Y)