Short R script to plot effect sizes (Cohen’s d) and shade overlapping area

Introduction to effect sizes

Many times you read in a study that “x and y were significantly different, p < .05”, which is another way of saying that “assuming that the null hypothesis is true, the probability of getting the observed value simply by chance alone is less than 0.05” But that’s not really that interesting, though is it? Say you are reading an intervention study that are comparing a treatment group to a control group, I bet you are more interested in finding out the amount of difference between the groups, rather than the chances of the differences popping up under the null hypothesis. Luckily it’s getting more and more common to also report effect sizes in addition to p-values. Effect sizes, in this case, are metrics that represent the amount of differences between two sample means. One of the most common effect size measure in psychology is Cohen’s d or the standardized mean difference. As you can see by the name it’s a measure of the standardized difference between two means. Commonly Cohen’s d is categorized in 3 broad categories: 0.2–0.3 represents a small effect, ~0.5 a medium effect and over 0.8 to infinity represents a large effect. What that means is that with two samples with a standard deviation of 1, the mean of group 1 is 0.8 sd away from the other group’s mean if Cohen’s d = 0.8. That might sound very intuitive to some, but I find it’s more explanatory to present different d values visually. Which is really easy to do in R statistical software.

Some quick R code to visualize Cohen’s d

The thing I actually wanted to try out here was to shade the overlapping area of the two distributions. It turned to be pretty easy to do in R.