Skip to main content

No project description provided

Project description

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

  1. Clone the repo

> git clone git@github.com:happysadderman/oddfisher.git
> cd oddfisher
> poetry install .
  1. 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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

oddfisher-0.1.1.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

oddfisher-0.1.1-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file oddfisher-0.1.1.tar.gz.

File metadata

  • Download URL: oddfisher-0.1.1.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for oddfisher-0.1.1.tar.gz
Algorithm Hash digest
SHA256 2bf6b2e9d39b05dda3bd6a514a522abcde8bd999600f63438a0116e1ea5989f4
MD5 347c4a62168cdcfa639f1a1c216e8003
BLAKE2b-256 ea6c9fd74a4dbaa7df8747eff34e4e3c08d1172cdbfd77cfea6cb07fe2843db1

See more details on using hashes here.

File details

Details for the file oddfisher-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: oddfisher-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 9.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for oddfisher-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b2463d3a9317333fa2c76042c01a0b3ef8fec90d0d907a4679886055ab64335b
MD5 5971aa68866091fbd521f1b7a0186851
BLAKE2b-256 eefd77da3e3c80c5656c83bc8ba27f7a6d3677275443c75d5d72459efeb554b0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page