# pingouin.compute_effsize

pingouin.compute_effsize(x, y, paired=False, eftype='cohen')[source]

Calculate effect size between two set of observations.

Parameters
xnp.array or list

First set of observations.

ynp.array or list

Second set of observations.

pairedboolean

If True, uses Cohen d-avg formula to correct for repeated measurements (Cumming 2012)

eftypestring

Desired output effect size. Available methods are

'none' : no effect size
'cohen' : Unbiased Cohen d
'hedges' : Hedges g
'glass': Glass delta
'r' : correlation coefficient
'eta-square' : Eta-square
'odds-ratio' : Odds ratio
'AUC' : Area Under the Curve
'CLES' : Common language effect size

Returns
effloat

Effect size

convert_effsize

Conversion between effect sizes.

compute_effsize_from_t

Convert a T-statistic to an effect size.

Notes

Missing values are automatically removed from the data. If x and y are paired, the entire row is removed.

If x and y are independent, the Cohen’s d is:

$d = \frac{\overline{X} - \overline{Y}} {\sqrt{\frac{(n_{1} - 1)\sigma_{1}^{2} + (n_{2} - 1) \sigma_{2}^{2}}{n1 + n2 - 2}}}$

If x and y are paired, the Cohen $$d_{avg}$$ is computed:

$d_{avg} = \frac{\overline{X} - \overline{Y}} {0.5 * (\sigma_1 + \sigma_2)}$

The Cohen’s d is a biased estimate of the population effect size, especially for small samples (n < 20). It is often preferable to use the corrected effect size, or Hedges’g, instead:

$g = d * (1 - \frac{3}{4(n_1 + n_2) - 9})$

If eftype = ‘glass’, the Glass $$\delta$$ is reported, using the group with the lowest variance as the control group:

$\delta = \frac{\overline{X} - \overline{Y}}{\sigma_{control}}$

References

1

Lakens, D., 2013. Calculating and reporting effect sizes to facilitate cumulative science: a practical primer for t-tests and ANOVAs. Front. Psychol. 4, 863. https://doi.org/10.3389/fpsyg.2013.00863

2

Cumming, Geoff. Understanding the new statistics: Effect sizes, confidence intervals, and meta-analysis. Routledge, 2013.

Examples

1. Compute Cohen d from two independent set of observations.

>>> import numpy as np
>>> from pingouin import compute_effsize
>>> np.random.seed(123)
>>> x = np.random.normal(2, size=100)
>>> y = np.random.normal(2.3, size=95)
>>> d = compute_effsize(x=x, y=y, eftype='cohen', paired=False)
>>> print(d)
-0.2835170152506578

1. Compute Hedges g from two paired set of observations.

>>> import numpy as np
>>> from pingouin import compute_effsize
>>> x = [1.62, 2.21, 3.79, 1.66, 1.86, 1.87, 4.51, 4.49, 3.3 , 2.69]
>>> y = [0.91, 3., 2.28, 0.49, 1.42, 3.65, -0.43, 1.57, 3.27, 1.13]
>>> g = compute_effsize(x=x, y=y, eftype='hedges', paired=True)
>>> print(g)
0.8370985097811404

1. Compute Glass delta from two independent set of observations. The group with the lowest variance will automatically be selected as the control.

>>> import numpy as np
>>> from pingouin import compute_effsize
>>> np.random.seed(123)
>>> x = np.random.normal(2, scale=1, size=50)
>>> y = np.random.normal(2, scale=2, size=45)
>>> d = compute_effsize(x=x, y=y, eftype='glass')
>>> print(d)
-0.1170721973604153