Skip to content

Effect sizes

Continuous and categorical effect-size helpers.

cohen_d

cohen_d(a: Series | ndarray, b: Series | ndarray) -> float | None

Cohen's d using the pooled standard deviation.

Parameters:

Name Type Description Default
a Series | ndarray

Two independent samples (pandas.Series or 1-D numpy array). Non-numeric entries are coerced; NaN rows are dropped per array. Each sample must contain at least two finite values.

required
b Series | ndarray

Two independent samples (pandas.Series or 1-D numpy array). Non-numeric entries are coerced; NaN rows are dropped per array. Each sample must contain at least two finite values.

required

Returns:

Type Description
float or None

d = (μ_a − μ_b) / s_pool, where the pooled SD weights the two samples by their degrees of freedom: s_pool = sqrt(((n_a − 1)·s_a² + (n_b − 1)·s_b²) / (n_a + n_b − 2)). Returns None if either sample has fewer than 2 finite observations. Returns 0.0 if the pooled SD is zero and the two means are identical; inf if the pooled SD is zero but the means differ (degenerate constant-sample case).

References

Cohen, J. (1988). Statistical Power Analysis for the Behavioral Sciences (2nd ed.). Lawrence Erlbaum.

hedges_g

hedges_g(a: Series | ndarray, b: Series | ndarray) -> float | None

Hedges' g — Cohen's d with the small-sample bias correction.

g = d · J, where J ≈ 1 − 3/(4(n_a+n_b) − 9) (Hedges 1981).

eta_squared

eta_squared(values: Series, groups: Series) -> float | None

One-way ANOVA effect size: between-group / total sum-of-squares.

Ranges [0, 1]. Small ≈ 0.01, medium ≈ 0.06, large ≈ 0.14 (Cohen 1988).

omega_squared

omega_squared(values: Series, groups: Series) -> float | None

Less-biased counterpart to eta_squared (Hays 1973).

cramers_v

cramers_v(values: Series, groups: Series) -> float | None

Cramér's V — chi-square effect size normalised to [0, 1].

V = √(χ² / (N · (min(R, C) − 1))).

phi_coefficient

phi_coefficient(values: Series, groups: Series) -> float | None

Phi — Cramér's V special case for 2×2 tables; φ = √(χ²/N).

auto_effect_size

auto_effect_size(values: Series, groups: Series) -> tuple[str, float | None]

Pick a sensible effect size for the variable kind / number of groups.

Returns (name, value) so callers can both display the metric and label it in a footnote.