nispace.stats.effectsize.cohen_paired
- nispace.stats.effectsize.cohen_paired(a, b)[source]
Cohen’s d for paired/dependent samples: mean difference over SD of differences.
- Parameters:
a (array_like, shape (n_obs, n_features)) – Matched-pair samples; must have identical shape (row i in a is paired with row i in b).
b (array_like, shape (n_obs, n_features)) – Matched-pair samples; must have identical shape (row i in a is paired with row i in b).
- Returns:
d
- Return type:
np.ndarray, shape (n_features,)
- Raises:
ValueError – If a.shape != b.shape.
Notes
Uses plain np.mean/np.std (ddof=1) on a - b – NaN in either array propagates. Not called anywhere in NiSpace’s internal pipeline (no pairedcohen entry currently uses this function; the paired-cohen formula path in core/transform_y.py dispatches to the numba-jitted cohen_paired_nan_fast).
This is Cohen’s d_z (mean difference over the SD of the difference scores itself), not d_avg (mean difference over the average of each condition’s own, unpaired variance – the formula pingouin’s compute_effsize(paired=True) uses by default). The two aren’t interchangeable: d_z’s denominator folds in the correlation between the paired conditions (var(diff) = var_a + var_b - 2*cov(a,b)), while d_avg discards it entirely. d_z is the internally-consistent choice here because it’s the standardized member of the same family as NiSpace’s other paired Y_transform options (prc/logfc/plain difference) – all of them, d_z included, are pure functions of the paired observations alone. d_avg would break that by pulling in each condition’s unpaired variance, a quantity none of the others touch.
References
[39].