{
  "__type": "IngestedDoc",
  "__tag": 4010,
  "_content": {
    "Notes": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Boschloo's test is an exact test used in the analysis of contingency tables. It examines the association of two categorical variables, and is a uniformly more powerful alternative to Fisher's exact test for 2x2 contingency tables."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Boschloo's exact test uses the p-value of Fisher's exact test as a statistic, and Boschloo's p-value is the probability under the null hypothesis of observing such an extreme value of this statistic."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Let's define "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "X_0"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " a 2x2 matrix representing the observed sample, where each column stores the binomial experiment, as in the example below. Let's also define "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "p_1, p_2"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " the theoretical binomial probabilities for  "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "x_{11}"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " and "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "x_{12}"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ". When using Boschloo exact test, we can assert three different alternative hypotheses:"
            }
          ]
        },
        {
          "__type": "BulletList",
          "__tag": 4053,
          "ordered": false,
          "start": 1,
          "children": [
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "InlineMath",
                      "__tag": 4057,
                      "value": "H_0 : p_1=p_2"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " versus "
                    },
                    {
                      "__type": "InlineMath",
                      "__tag": 4057,
                      "value": "H_1 : p_1 < p_2"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ",   with "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "alternative"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " = \"less\""
                    }
                  ]
                }
              ]
            },
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "InlineMath",
                      "__tag": 4057,
                      "value": "H_0 : p_1=p_2"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " versus "
                    },
                    {
                      "__type": "InlineMath",
                      "__tag": 4057,
                      "value": "H_1 : p_1 > p_2"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ",   with "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "alternative"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " = \"greater\""
                    }
                  ]
                }
              ]
            },
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "InlineMath",
                      "__tag": 4057,
                      "value": "H_0 : p_1=p_2"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " versus "
                    },
                    {
                      "__type": "InlineMath",
                      "__tag": 4057,
                      "value": "H_1 : p_1 \\neq p_2"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ",   with "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "alternative"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " = \"two-sided\" (default)"
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "There are multiple conventions for computing a two-sided p-value when the null distribution is asymmetric. Here, we apply the convention that the p-value of a two-sided test is twice the minimum of the p-values of the one-sided tests (clipped to 1.0). Note that "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "fisher_exact",
              "reference": {
                "__type": "LocalRef",
                "__tag": 4022,
                "kind": "module",
                "path": "scipy.stats._stats_py:fisher_exact"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " follows a different convention, so for a given "
            },
            {
              "__type": "ParamRef",
              "__tag": 4071,
              "name": "table"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", the statistic reported by "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "boschloo_exact",
              "reference": {
                "__type": "LocalRef",
                "__tag": 4022,
                "kind": "module",
                "path": "scipy.stats._hypotests:boschloo_exact"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " may differ from the p-value reported by "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "fisher_exact",
              "reference": {
                "__type": "LocalRef",
                "__tag": 4022,
                "kind": "module",
                "path": "scipy.stats._stats_py:fisher_exact"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " when "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "alternative='two-sided'"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "."
            }
          ]
        },
        {
          "__type": "Admonition",
          "__tag": 4056,
          "kind": "versionadded",
          "base_type": "neutral",
          "children": [
            {
              "__type": "AdmonitionTitle",
              "__tag": 4055,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "versionadded 1.7.0"
                }
              ]
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Strong",
              "__tag": 4048,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "Array API Standard Support"
                }
              ]
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "boschloo_exact",
              "reference": {
                "__type": "LocalRef",
                "__tag": 4022,
                "kind": "module",
                "path": "scipy.stats._hypotests:boschloo_exact"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " has experimental support for Python Array API Standard compatible backends in addition to NumPy. Please consider testing these features by setting an environment variable "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "SCIPY_ARRAY_API=1"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " and providing CuPy, PyTorch, JAX, or Dask arrays as array arguments. The following combinations of backend and device (or other capability) are supported."
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "====================  ====================  ====================\nLibrary               CPU                   GPU\n====================  ====================  ====================\nNumPy                 ✅                     n/a                 \nCuPy                  n/a                   ⛔                   \nPyTorch               ⛔                     ⛔                   \nJAX                   ⛔                     ⛔                   \nDask                  ⛔                     n/a                 \n====================  ====================  ====================",
          "execution_status": null
        },
        {
          "__type": "Blockquote",
          "__tag": 4059,
          "children": [
            {
              "__type": "Paragraph",
              "__tag": 4045,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "See "
                },
                {
                  "__type": "InlineRole",
                  "__tag": 4003,
                  "value": "dev-arrayapi",
                  "domain": null,
                  "role": "ref",
                  "inventory": null
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": " for more information."
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Warns": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Raises": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Yields": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Methods": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Returns": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Parameters",
          "__tag": 4026,
          "children": [
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "ber",
              "annotation": "BoschlooExactResult",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "A result object with the following attributes."
                    }
                  ]
                },
                {
                  "__type": "DefList",
                  "__tag": 4033,
                  "children": [
                    {
                      "__type": "DefListItem",
                      "__tag": 4037,
                      "dt": {
                        "__type": "Paragraph",
                        "__tag": 4045,
                        "children": [
                          {
                            "__type": "Text",
                            "__tag": 4046,
                            "value": "statistic"
                          }
                        ]
                      },
                      "dd": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "statistic"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "__type": "DefListItem",
                      "__tag": 4037,
                      "dt": {
                        "__type": "Paragraph",
                        "__tag": 4045,
                        "children": [
                          {
                            "__type": "Text",
                            "__tag": 4046,
                            "value": "pvalue"
                          }
                        ]
                      },
                      "dd": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "pvalue"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Perform Boschloo's exact test on a 2x2 contingency table."
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Receives": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Warnings": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Attributes": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Parameters": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Parameters",
          "__tag": 4026,
          "children": [
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "table",
              "annotation": "array_like of ints",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "A 2x2 contingency table.  Elements should be non-negative integers."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "alternative",
              "annotation": "{'two-sided', 'less', 'greater'}, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Defines the null and alternative hypotheses. Default is 'two-sided'. Please see explanations in the Notes section below."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "n",
              "annotation": "int, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Number of sampling points used in the construction of the sampling method. Note that this argument will automatically be converted to the next higher power of 2 since "
                    },
                    {
                      "__type": "CrossRef",
                      "__tag": 4002,
                      "value": "scipy.stats.qmc.Sobol",
                      "reference": {
                        "__type": "RefInfo",
                        "__tag": 4000,
                        "module": "scipy",
                        "version": "*",
                        "kind": "api",
                        "path": "scipy.stats._qmc:Sobol"
                      },
                      "kind": "module"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " is used to select sample points. Default is 32. Must be positive. In most cases, 32 points is enough to reach good precision. More points comes at performance cost."
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Extended Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Other Parameters": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    }
  },
  "_ordered_sections": [
    "Summary",
    "Extended Summary",
    "Parameters",
    "Attributes",
    "Methods",
    "Returns",
    "Yields",
    "Receives",
    "Other Parameters",
    "Raises",
    "Warns",
    "Warnings",
    "Notes"
  ],
  "item_file": "/scipy/stats/_hypotests.py",
  "item_line": 1259,
  "item_type": "function",
  "aliases": [
    "scipy.stats.boschloo_exact"
  ],
  "example_section_data": {
    "__type": "Section",
    "__tag": 4015,
    "children": [
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "In the following example, we consider the article \"Employee\nattitudes and job satisfaction\" [3]_\nwhich reports the results of a survey from 63 scientists and 117 college\nprofessors. Of the 63 scientists, 31 said they were very satisfied with\ntheir jobs, whereas 74 of the college professors were very satisfied\nwith their work. Is this significant evidence that college\nprofessors are happier with their work than scientists?\nThe following table summarizes the data mentioned above::\n\n                     college professors   scientists\n    Very Satisfied   74                     31\n    Dissatisfied     43                     32\n\nWhen working with statistical hypothesis testing, we usually use a\nthreshold probability or significance level upon which we decide\nto reject the null hypothesis :math:`H_0`. Suppose we choose the common\nsignificance level of 5%.\n\nOur alternative hypothesis is that college professors are truly more\nsatisfied with their work than scientists. Therefore, we expect\n:math:`p_1` the proportion of very satisfied college professors to be\ngreater than :math:`p_2`, the proportion of very satisfied scientists.\nWe thus call `boschloo_exact` with the ``alternative=\"greater\"`` option:\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "import scipy.stats as stats\nres = stats.boschloo_exact([[74, 31], [43, 32]], alternative=\"greater\")\n",
        "execution_status": "success"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "res.statistic\nres.pvalue\n",
        "execution_status": "failure"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nUnder the null hypothesis that scientists are happier in their work than\ncollege professors, the probability of obtaining test\nresults at least as extreme as the observed data is approximately 3.55%.\nSince this p-value is less than our chosen significance level, we have\nevidence to reject :math:`H_0` in favor of the alternative hypothesis."
      }
    ],
    "title": [],
    "level": 0,
    "target": null
  },
  "see_also": [
    {
      "__type": "SeeAlsoItem",
      "__tag": 4028,
      "name": {
        "__type": "CrossRef",
        "__tag": 4002,
        "value": "barnard_exact",
        "reference": {
          "__type": "LocalRef",
          "__tag": 4022,
          "kind": "module",
          "path": "scipy.stats._hypotests:barnard_exact"
        },
        "kind": "module"
      },
      "descriptions": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Barnard's exact test, which is a more powerful alternative than Fisher's exact test for 2x2 contingency tables."
            }
          ]
        }
      ],
      "type": "func"
    },
    {
      "__type": "SeeAlsoItem",
      "__tag": 4028,
      "name": {
        "__type": "CrossRef",
        "__tag": 4002,
        "value": "chi2_contingency",
        "reference": {
          "__type": "LocalRef",
          "__tag": 4022,
          "kind": "module",
          "path": "scipy.stats.contingency:chi2_contingency"
        },
        "kind": "module"
      },
      "descriptions": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Chi-square test of independence of variables in a contingency table."
            }
          ]
        }
      ],
      "type": "func"
    },
    {
      "__type": "SeeAlsoItem",
      "__tag": 4028,
      "name": {
        "__type": "CrossRef",
        "__tag": 4002,
        "value": "fisher_exact",
        "reference": {
          "__type": "LocalRef",
          "__tag": 4022,
          "kind": "module",
          "path": "scipy.stats._stats_py:fisher_exact"
        },
        "kind": "module"
      },
      "descriptions": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Fisher exact test on a 2x2 contingency table."
            }
          ]
        }
      ],
      "type": "func"
    }
  ],
  "signature": {
    "__type": "SignatureNode",
    "__tag": 4029,
    "kind": "function",
    "parameters": [
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "table",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": {
          "__type": "Empty",
          "__tag": 4031
        }
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "alternative",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "two-sided"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "n",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "32"
      }
    ],
    "return_annotation": {
      "__type": "Empty",
      "__tag": 4031
    },
    "target_name": "boschloo_exact"
  },
  "references": [
    ".. [1] R.D. Boschloo. \"Raised conditional level of significance for the",
    "   2 x 2-table when testing the equality of two probabilities\",",
    "   Statistica Neerlandica, 24(1), 1970",
    "",
    ".. [2] \"Boschloo's test\", Wikipedia,",
    "   https://en.wikipedia.org/wiki/Boschloo%27s_test",
    "",
    ".. [3] Lise M. Saari et al. \"Employee attitudes and job satisfaction\",",
    "   Human Resource Management, 43(4), 395-407, 2004,",
    "   :doi:`10.1002/hrm.20032`."
  ],
  "qa": "scipy.stats._hypotests:boschloo_exact",
  "arbitrary": [],
  "local_refs": [
    "alternative",
    "ber",
    "n",
    "table"
  ]
}