Cohen's h effect size for two proportions — a value-exact, faster
statsmodels.stats.proportion.proportion_effectsize.
The effect size uses the variance-stabilising arcsine transform (the only
method statsmodels implements, named normal):
h = 2 * (arcsin(sqrt(prop1)) - arcsin(sqrt(prop2)))
This is the quantity power calculations for two-proportion tests need (R's
pwr.p2.test, pwr::ES.h).
cargo install rsomics-proportion-effectsize
Single pair:
rsomics-proportion-effectsize --prop1 0.5 --prop2 0.4
0.20135792079033088
Many pairs (whitespace- or tab-separated prop1 prop2 rows, one h per
output line):
rsomics-proportion-effectsize --batch pairs.tsv
--json emits the result inside the standard rsomics envelope (the single
value as cohens_h, or a count in batch mode); -q/--quiet silences
progress.
Both proportions must lie in [0, 1]. Outside that range the arcsine
transform is undefined — statsmodels returns nan; this tool fails loud with
a clear error instead, since a silent wrong number poisons a power analysis. A
genuine nan input still propagates to a nan result, matching statsmodels.
Any --method other than normal errors, matching statsmodels' ValueError.
np.arcsin(np.sqrt(prop)) under the hood is the platform libm asin/sqrt,
the same pair NumPy/SciPy use, evaluated in the same operation order
(2 * (arcsin(sqrt(prop1)) - arcsin(sqrt(prop2)))), so the result is
bit-identical to statsmodels.
This crate is an independent Rust reimplementation of
statsmodels.stats.proportion.proportion_effectsize based on:
- Cohen, J. (1988). Statistical Power Analysis for the Behavioral Sciences (2nd ed.). Lawrence Erlbaum. (Cohen's h, the arcsine effect size.)
- The statsmodels source for
proportion_effectsize(BSD-3-Clause): the2 * (arcsin(sqrt(prop1)) - arcsin(sqrt(prop2)))formula, thenormalmethod name, and theValueErrorraised for any other method.
License: MIT OR Apache-2.0. Upstream credit: statsmodels (BSD-3-Clause), https://www.statsmodels.org.