0
$\begingroup$

I am trying to measure the effect size of some variables between two different groups.

I've taken some python code from a few tutorials, but they seem to be calculating it in different ways.

I have two groups: group_1 and group_2.

First method squares the standard deviations and divides by 2 (from datacamp.com):

pooled_standard_deviation = sqrt((group_1.std()**2 + group_2.std()**2)/2 )

cohens_d = difference_in_means / pooled_standard_deviation 

Second method multiplies the sample size by the variance (machinelearningmastery.com):

# n1,n2 = sample sizes of groups 1 and 2

# s1,s2  = variances of groups 1 and 2

# u1,u2 = means of groups 1 and 2

pooled_standard_deviation  = sqrt(((n1 - 1) * s1 + (n2 - 1) * s2) / (n1 + n2 - 2))

cohens_d = (u1 - u2) / s

Which one is correct?

I'm guessing there's a very obvious reason for the difference but I just have no idea. (not a stats expert)

$\endgroup$
2
  • 2
    $\begingroup$ The first one assumes that the sample sizes are equal, it also does not make a correction for the fact that the variances are sample variances by not using the n-1 correction. The second is correct. $\endgroup$
    – spdrnl
    Feb 20, 2020 at 14:40
  • $\begingroup$ Thanks. My sample sizes are definitely not equal. $\endgroup$
    – SCool
    Feb 20, 2020 at 15:01

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.