Given the following parameters, how do I calculate the effect size of an independent unequal sample size t test?
sample 1: size = 32 mean = 845.1 std = 46.7 sample 2: size = 53 mean = 829.1 std = 33.8 test results: tstat = 1.83 p value = .035 df = 83
asked May 21, 2015 at 20:31
asdflkjwqerqwr asdflkjwqerqwr
388 3 3 silver badges 9 9 bronze badges
$\begingroup$ Sample size doesn't come into the calculation of the effect size. Same way you'd calculate it if they had the same sample (if you're talking about Cohen's d). $\endgroup$
Commented May 21, 2015 at 20:41$\begingroup$ But you can calculate a pooled SD with sample size adjustment in order to get the best estimate of the population SD. $\endgroup$
Commented May 21, 2015 at 20:49 $\begingroup$ @Hotaka Yes that's the calculation I'm looking for. $\endgroup$ Commented May 21, 2015 at 21:40Here is the python script to calculate the values you are interested in. Following code is also available here - https://gist.github.com/sriisking/10716f107ed30f4911639d695e3fbe49
from scipy.stats import ttest_ind_from_stats import numpy as np #We use Welch's t-Test as the sample sizes are different def statistical_significance_welch_ttest(mean1,std1,count1,mean2,std2,count2): t_statistic, p_value = ttest_ind_from_stats(mean1, std1, count1, mean2, std2, count2, equal_var=False) return t_statistic, p_value #Here the pooled standard deviation accounts for unequal sample sizes def effect_size_cohensD(mean1,std1,count1,mean2,std2,count2): dof = (count1 + count2 - 2) cohens_d = (mean1 - mean2) / np.sqrt(((count1 - 1) * std1 ** 2 + (count2 - 1) * std2 ** 2) / dof) return cohens_d if __name__ == '__main__': mean1 = 845.1; std1 = 46.7;count1 = 32 mean2 =829.1; std2 =33.8; count2 = 53 t_statistic, p_value = statistical_significance_welch_ttest(mean1,std1,count1,mean2,std2,count2) print t_statistic, p_value cohens_d = effect_size_cohensD(mean1, std1, count1, mean2, std2, count2) print cohens_d