def test2(self): R = """Anova: Single Factor on SUPPRESSION SUMMARY Groups Count Sum Average Variance ============================================== AA 128 2048 16 148.792 AB 128 2510.600 19.614 250.326 LAB 128 2945.000 23.008 264.699 O'BRIEN TEST FOR HOMOGENEITY OF VARIANCE Source of Variation SS df MS F P-value eta^2 Obs. power ============================================================================================ Treatments 1021873.960 2 510936.980 5.229 0.006 0.027 0.823 Error 37227154.824 381 97709.068 ============================================================================================ Total 38249028.783 383 ANOVA Source of Variation SS df MS F P-value eta^2 Obs. power ========================================================================================= Treatments 3144.039 2 1572.020 7.104 9.348e-04 0.036 0.922 Error 84304.687 381 221.272 ========================================================================================= Total 87448.726 383 POSTHOC MULTIPLE COMPARISONS Tukey HSD: Table of q-statistics AA AB LAB ============================== AA 0 2.749 ns 5.330 ** AB 0 2.581 ns LAB 0 ============================== + p < .10 (q-critical[3, 381] = 2.91125483514) * p < .05 (q-critical[3, 381] = 3.32766157576) ** p < .01 (q-critical[3, 381] = 4.14515568451)""" df = DataFrame() df.read_tbl('data/suppression~subjectXgroupXageXcycleXphase.csv') D = df.anova1way('SUPPRESSION', 'GROUP') self.assertEqual(str(D), R)
# instantiate DataFrame object to hold data df = DataFrame() # inherents a dict # put data into a DataFrame object df['data'] = data1 + data2 # build dummy code column df['conditions'] = ['A'] * len(data1) + ['B'] * len(data2) # visually verify data in DataFrame print(df) # run 1 way analysis of variance # returns another dict-like object aov = df.anova1way('data', 'conditions') # print anova results print(aov) # this is just to show the data in the aov object print(aov.keys()) # calculate omega-squared aov['omega-sq'] = (aov['ssbn'] - aov['dfbn']*aov['mswn']) / \ (aov['ssbn'] + aov['sswn'] + aov['mswn']) # you can access the results this way print(aov['omega-sq']) print(aov['f']) print(aov['p'])