Effect sizes

Effect sizes#

Outputs of spm1d.stats methods have an effect_size method that calculates the effect size(s) associated with a particular test:

  • t contrast: Cohen’s d and Hedges’ g

  • F contrast: partial eta squared; for ANOVA: also eta squared and omega squared

  • Hotelling’s T²: Mahalanobis distance

  • multivariate F: multivariate partial eta squared

See also: EffectSize attributes.


0D examples#

Example 1: Cohen’s d and Hedges’ g for a two-sample t test.

import spm1d
import jikudata as jd

dataset = jd.R_Sleep2Test()
y, A    = dataset.y, dataset.x  # (20,) arrays of responses and group labels
yA, yB  = y[ A == 0 ], y[ A == 1 ]
spm     = spm1d.stats.ttest2( yA, yB )
es      = spm.effect_size()
print( es )
Effect size (0D)
   measure      :  Cohen's d
   standardizer :  classical
   df           :  (1, 17.776)
   z            :  -0.83218
   d            :  -0.83218
   g            :  -0.79648
   eta2p        :  0.16303


Example 2: partial eta squared, eta squared and omega squared for a one-way ANOVA.

dataset = jd.R_ChickWeights()
y, A    = dataset.y, dataset.x  # (71,) arrays of responses and group labels
es      = spm1d.stats.anova1( y, A ).effect_size()
print( es )
Effect size (0D)
   measure      :  partial eta squared
   standardizer :  classical
   df           :  (4.603, 59.463)
   z            :  0.54573
   eta2p        :  0.54573
   eta2         :  0.54169
   omega2       :  0.50569

1D example#

For 1D data each effect size is a continuum with one value per domain node. The example below uses the plantar arch angle data from First analyses.

dataset = jd.PlantarArchAngle()
y, A    = dataset.y, dataset.x  # (20,101) array and (20,) array
yA, yB  = y[ A == 0 ], y[ A == 1 ]
spm     = spm1d.stats.ttest_paired( yA, yB )
es      = spm.effect_size()
print( es )
print( es.d.max() )
Effect size (1D)
   measure      :  Cohen's d
   standardizer :  classical
   df           :  (1, 9)
   z            :  (101,) array
   d            :  (101,) array
   g            :  (101,) array
   eta2p        :  (101,) array

2.071848362323722

The effect size continuum can be plotted using es.plot().

Cohen's d continuum of the paired t test, drawn by es.plot() Cohen's d continuum of the paired t test, drawn by es.plot()