bundles / scipy 1.17.1 / scipy / stats / _odds_ratio / odds_ratio
function
scipy.stats._odds_ratio:odds_ratio
source: /scipy/stats/_odds_ratio.py :324
Signature
def odds_ratio ( table , * , kind = conditional ) Summary
Compute the odds ratio for a 2x2 contingency table.
Parameters
table: array_like of intsA 2x2 contingency table. Elements must be non-negative integers.
kind: str, optionalWhich kind of odds ratio to compute, either the sample odds ratio (
kind='sample') or the conditional odds ratio (kind='conditional'). Default is'conditional'.
Returns
result: `~scipy.stats._result_classes.OddsRatioResult` instanceThe returned object has two computed attributes:
statistic
statistic
The object has the method
confidence_intervalthat computes the confidence interval of the odds ratio.
Notes
The conditional odds ratio was discussed by Fisher (see "Example 1" of [1]). Texts that cover the odds ratio include [2] and [3].
Examples
In epidemiology, individuals are classified as "exposed" or "unexposed" to some factor or treatment. If the occurrence of some illness is under study, those who have the illness are often classified as "cases", and those without it are "noncases". The counts of the occurrences of these classes gives a contingency table:: exposed unexposed cases a b noncases c d The sample odds ratio may be written ``(a/c) / (b/d)``. ``a/c`` can be interpreted as the odds of a case occurring in the exposed group, and ``b/d`` as the odds of a case occurring in the unexposed group. The sample odds ratio is the ratio of these odds. If the odds ratio is greater than 1, it suggests that there is a positive association between being exposed and being a case. Interchanging the rows or columns of the contingency table inverts the odds ratio, so it is important to understand the meaning of labels given to the rows and columns of the table when interpreting the odds ratio. Consider a hypothetical example where it is hypothesized that exposure to a certain chemical is associated with increased occurrence of a certain disease. Suppose we have the following table for a collection of 410 people:: exposed unexposed cases 7 15 noncases 58 472 The question we ask is "Is exposure to the chemical associated with increased risk of the disease?" Compute the odds ratio:from scipy.stats.contingency import odds_ratio res = odds_ratio([[7, 15], [58, 472]]) res.statistic✓
res.confidence_interval(confidence_level=0.95)
✓See also
- hypothesis_odds_ratio
Extended example
- relative_risk
- scipy.stats.fisher_exact
Aliases
-
scipy.stats._odds_ratio.odds_ratio