Giter Site home page Giter Site logo

odds_ratio's Introduction

Odds Ratio Calculator

Odds Ratio Calculator and Fisher's Exact Test

Definition

An odds ratio (OR) is a measure of association between an exposure and an outcome. The OR represents the odds that an outcome will occur given a particular exposure, compared to the odds of the outcome occurring in the absence of that exposure. Odds ratios are most commonly used in case-control studies, however they can also be used in cross-sectional and cohort study designs as well.

Odds ratios are used to compare the relative odds of the occurrence of the outcome of interest (e.g. disease or disorder), given exposure to the variable of interest (e.g. health characteristic, aspect of medical history). The odds ratio can also be used to determine whether a particular exposure is a risk factor for a particular outcome, and to compare the magnitude of various risk factors for that outcome.

  • OR=1 Exposure does not affect odds of outcome
  • OR>1 Exposure associated with higher odds of outcome
  • OR<1 Exposure associated with lower odds of outcome

Calculation

$OR = \frac{a/c}{b/d} = \frac{ad}{bc}$

  • a - positive (bad) cases in exposed group
  • b - negative (good) cases in exposed group
  • c - positive (bad) cases in control group
  • d - negative (good) cases in control group

Haldane-Anscombe correction for zero:add 0.5 for a/b/c/d.

Confidence interval (CI)

The 95% confidence interval (CI) is used to estimate the precision of the OR. A large CI indicates a low level of precision of the OR, whereas a small CI indicates a higher precision of the OR. It is important to note however, that unlike the p value, the 95% CI does not report a measure’s statistical significance. In practice, the 95% CI is often used as a proxy for the presence of statistical significance if it does not overlap the null value (e.g. OR=1). Nevertheless, it would be inappropriate to interpret an OR with 95% CI that spans the null value as indicating evidence for lack of association between the exposure and outcome.

Fisher's Exact Test

Fisher’s Exact Test is used to determine whether or not there is a significant association between two categorical variables. It is typically used as an alternative to the Chi-Square Test of Independence when one or more of the cell counts in a 2×2 table is less than 5.

Installation

  1. pip install scipy
  2. git clone https://github.com/JiguangPeng/odds_ratio

Usage

Module mode

from odds_ratio import OddsRatio

test = OddsRatio(18, 2, 10, 10)

# Odds Ratio
test.odds_ratio          # 9.0

# The 95% confidence interval (CI)
test.odds_ratio_lower    # 1.6381043384832557
test.odds_ratio_upper    # 49.447399715087194
test.odds_ratio_ci       # '[1.64, 49.45]'

# Fisher's Exact Test
test.pvalue       # 0.013814147851967653
test.prob         # 0.006283257673691489

Command mode

python3 odds_ratio.py -i 18 2 10 10

# OR

python odds_ratio.py -a 18 -b 2 -c 10 -d 10

#Odds Ratio: 9.00
#Odds Ratio CI: 1.64-49.45
#P-value: 0.0138
#Probability: 0.00628

Reference

odds_ratio's People

Contributors

jiguangpeng avatar

Watchers

 avatar

Forkers

bgidx

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.