Home > Enterprise >  R - Compute a parwise Cohen's d
R - Compute a parwise Cohen's d

Time:10-15

I have two df reporting the means and sd of two groups observed by the same variables. Now I'd like to compute the Cohen's d to pairwise data. Do I have to merge the df and then execute the Cohen's d? Or there is just a faster way to do it? Thank you in advice.

tab1<-data.frame(variables=c(1:7),means=c(10.45,40.35,30.15,86.60,5.63,20.81,50.34), 
                 sd=c(2.32,9.51,3.87,17.11,3.45,5.45,4.62))

tab2<-data.frame(variables=c(1:7),means=c(10.38,32.29,27.69,88.74,4.93,13.37,51.50), 
                 sd=c(2.33,10.21,4.59,15.79,3.44,7.16,4.69))

CodePudding user response:

So you calculate by hand with:

cohens_d <- (tab1$means - tab2$means) / sqrt(0.5*(tab1$sd   tab2$sd))

which gives:

[1]  0.04590781  2.56682691  1.19609293 -0.52763163  0.37714072  2.96299139 -0.53764814
  • Related