OddFisher
oddfisher fisher exact test includes the odds ratio parameter, which is equivalent to or parameter from fisher.test in R, where or is hypothesized odds ratio. This parameter is currently not available in fisher exact test in scipy.stats package, and I hope to benefit the python users, looking for python-based fisher exact test with with hypothesized odds ratio parameter.
Please note that this code is based on R fisher-test implementation, relying on the scipy.stats package to achieve equivalency around the negative hypergeometric distribution functions.
Instruction
Clone the repo
> git clone git@github.com:happysadderman/oddfisher.git
> cd oddfisher
> poetry install .
To run, check out the usage with help menu
> oddfisher fisherexact -h
Altermatively, if you want to use the fisher exact test as stand-alone script, you can run the code using
> python fisher.py fisherexact 1 2 3 4 --odd-ratio 10
> python fisher.py fisherexact 1 2 3 4 # default fisher-exact with no hypothesized odd-ratio
Example command
Example code shows how parameter –odd-ratio can be used during the fisher exact test. When –odd-ratio parameter is not used, it defaults to odd-ratio of 1.
> oddfisher fisherexact --odd-ratio 10 1 2 3 4
Results
-------------------
p-value: {'two-sided': np.float64(0.07542579075425782), 'less': 0.07542579075425782, 'greater': 0.997566909975669}
confidence interval at 0.95: (0.008503581019485222, 20.296323344994953)
odds ratio: 0.6937896639529924
Above is equivalent to R fisher.test, with or=10
> d <- matrix(c(1, 2, 3, 4), nrow=2)
> fisher.test(d, or=10)
Fisher's Exact Test for Count Data
data: d
p-value = 0.07543
alternative hypothesis: true odds ratio is not equal to 10
95 percent confidence interval:
0.008512238 20.296715040
sample estimates:
odds ratio
0.693793
Metadata
Release files for oddfisher 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| oddfisher-0.1.1.tar.gz | 6.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| oddfisher-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 15.9 kB
Release files / oddfisher-0.1.1.tar.gz
| Download URL | oddfisher-0.1.1.tar.gz |
|---|---|
| Size | 6.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2bf6b2e9d39b05dda3bd6a514a522abcde8bd999600f63438a0116e1ea5989f4
|
|
BLAKE2b-256 checksum How to use checksums |
ea6c9fd74a4dbaa7df8747eff34e4e3c08d1172cdbfd77cfea6cb07fe2843db1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.1 CPython/3.12.5
|
Release files / oddfisher-0.1.1-py3-none-any.whl
| Download URL | oddfisher-0.1.1-py3-none-any.whl |
|---|---|
| Size | 9.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b2463d3a9317333fa2c76042c01a0b3ef8fec90d0d907a4679886055ab64335b
|
|
BLAKE2b-256 checksum How to use checksums |
eefd77da3e3c80c5656c83bc8ba27f7a6d3677275443c75d5d72459efeb554b0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.1 CPython/3.12.5
|
Security for oddfisher 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.