Skip to content

omics-rust/rsomics-proportion-effectsize

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rsomics-proportion-effectsize

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).

Install

cargo install rsomics-proportion-effectsize

Usage

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.

Method

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.

Origin

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): the 2 * (arcsin(sqrt(prop1)) - arcsin(sqrt(prop2))) formula, the normal method name, and the ValueError raised for any other method.

License: MIT OR Apache-2.0. Upstream credit: statsmodels (BSD-3-Clause), https://www.statsmodels.org.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages