{ } Raw JSON

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 ints

A 2x2 contingency table. Elements must be non-negative integers.

kind : str, optional

Which 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` instance

The returned object has two computed attributes:

statistic

statistic

The object has the method confidence_interval that 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
For this sample, the odds of getting the disease for those who have been exposed to the chemical are almost 3.8 times that of those who have not been exposed. We can compute the 95% confidence interval for the odds ratio:
res.confidence_interval(confidence_level=0.95)
The 95% confidence interval for the conditional odds ratio is approximately (1.25, 10.4). For a more detailed example, see :ref:`hypothesis_odds_ratio`.

See also

hypothesis_odds_ratio

Extended example

relative_risk
scipy.stats.fisher_exact

Aliases

  • scipy.stats._odds_ratio.odds_ratio

Referenced by