{
  "__type": "IngestedDoc",
  "__tag": 4010,
  "_content": {
    "Notes": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "As noted in "
            },
            {
              "__type": "FootnoteReference",
              "__tag": 4066,
              "label": "1"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", \"the "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "n"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " 'treatments' could just as well represent "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "n"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " objects or events or performances or persons or trials ranked.\" Similarly, the "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "m"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " 'subjects' could equally stand for "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "m"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " \"groupings by ability or some other control variable, or judges doing the ranking, or random replications of some other sort.\""
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "The procedure for calculating the "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "L"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " statistic, adapted from "
            },
            {
              "__type": "FootnoteReference",
              "__tag": 4066,
              "label": "1"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", is:"
            }
          ]
        },
        {
          "__type": "BulletList",
          "__tag": 4053,
          "ordered": true,
          "start": 1,
          "children": [
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "\"Predetermine with careful logic the appropriate hypotheses    concerning the predicted ordering of the experimental results.    If no reasonable basis for ordering any treatments is known, the    "
                    },
                    {
                      "__type": "InlineMath",
                      "__tag": 4057,
                      "value": "L"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " test is not appropriate.\""
                    }
                  ]
                }
              ]
            },
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "\"As in other experiments, determine at what level of confidence    you will reject the null hypothesis that there is no agreement of    experimental results with the monotonic hypothesis.\""
                    }
                  ]
                }
              ]
            },
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "\"Cast the experimental material into a two-way table of "
                    },
                    {
                      "__type": "InlineMath",
                      "__tag": 4057,
                      "value": "n"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "    columns (treatments, objects ranked, conditions) and "
                    },
                    {
                      "__type": "InlineMath",
                      "__tag": 4057,
                      "value": "m"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "    rows (subjects, replication groups, levels of control variables).\""
                    }
                  ]
                }
              ]
            },
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "\"When experimental observations are recorded, rank them across each    row\", e.g. "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "ranks = scipy.stats.rankdata(data, axis=1)"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "\"Add the ranks in each column\", e.g.    "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "colsums = np.sum(ranks, axis=0)"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "\"Multiply each sum of ranks by the predicted rank for that same    column\", e.g. "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "products = predicted_ranks * colsums"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "\"Sum all such products\", e.g. "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "L = products.sum()"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "."
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "FootnoteReference",
              "__tag": 4066,
              "label": "1"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " continues by suggesting use of the standardized statistic"
            }
          ]
        },
        {
          "__type": "Math",
          "__tag": 4058,
          "value": "\\chi_L^2 = \\frac{\\left[12L-3mn(n+1)^2\\right]^2}{mn^2(n^2-1)(n+1)}"
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "\"which is distributed approximately as chi-square with 1 degree of freedom. The ordinary use of "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "\\chi^2"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " tables would be equivalent to a two-sided test of agreement. If a one-sided test is desired, "
            },
            {
              "__type": "Emphasis",
              "__tag": 4047,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "as will almost always be the case"
                }
              ]
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", the probability discovered in the chi-square table should be "
            },
            {
              "__type": "Emphasis",
              "__tag": 4047,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "halved"
                }
              ]
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ".\""
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "However, this standardized statistic does not distinguish between the observed values being well correlated with the predicted ranks and being _anti_-correlated with the predicted ranks. Instead, we follow "
            },
            {
              "__type": "FootnoteReference",
              "__tag": 4066,
              "label": "2"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " and calculate the standardized statistic"
            }
          ]
        },
        {
          "__type": "Math",
          "__tag": 4058,
          "value": "\\Lambda = \\frac{L - E_0}{\\sqrt{V_0}},"
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "where "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "E_0 = \\frac{1}{4} mn(n+1)^2"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " and "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "V_0 = \\frac{1}{144} mn^2(n+1)(n^2-1)"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", \"which is asymptotically normal under the null hypothesis\"."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "The "
            },
            {
              "__type": "Emphasis",
              "__tag": 4047,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "p"
                }
              ]
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "-value for "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "method='exact'"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " is generated by comparing the observed value of "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "L"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " against the "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "L"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " values generated for all "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "(n!)^m"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " possible permutations of ranks. The calculation is performed using the recursive method of [5]."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "The "
            },
            {
              "__type": "Emphasis",
              "__tag": 4047,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "p"
                }
              ]
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "-values are not adjusted for the possibility of ties. When ties are present, the reported  "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "'exact'"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " "
            },
            {
              "__type": "Emphasis",
              "__tag": 4047,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "p"
                }
              ]
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "-values may be somewhat larger (i.e. more conservative) than the true "
            },
            {
              "__type": "Emphasis",
              "__tag": 4047,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "p"
                }
              ]
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "-value "
            },
            {
              "__type": "FootnoteReference",
              "__tag": 4066,
              "label": "2"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ". The "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "'asymptotic'`"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " "
            },
            {
              "__type": "Emphasis",
              "__tag": 4047,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "p"
                }
              ]
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "-values, however, tend to be smaller (i.e. less conservative) than the "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "'exact'"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " "
            },
            {
              "__type": "Emphasis",
              "__tag": 4047,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "p"
                }
              ]
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "-values."
            }
          ]
        },
        {
          "__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": "page_trend_test",
              "reference": {
                "__type": "LocalRef",
                "__tag": 4022,
                "kind": "module",
                "path": "scipy.stats._page_trend_test:page_trend_test"
              },
              "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": "res",
              "annotation": "PageTrendTestResult",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "An object containing 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"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "__type": "DefListItem",
                      "__tag": 4037,
                      "dt": {
                        "__type": "Paragraph",
                        "__tag": 4045,
                        "children": [
                          {
                            "__type": "Text",
                            "__tag": 4046,
                            "value": "method"
                          }
                        ]
                      },
                      "dd": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "method"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Perform Page's Test, a measure of trend in observations between treatments."
            }
          ]
        }
      ],
      "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": "data",
              "annotation": "array-like",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "A "
                    },
                    {
                      "__type": "InlineMath",
                      "__tag": 4057,
                      "value": "m \\times n"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " array; the element in row "
                    },
                    {
                      "__type": "InlineMath",
                      "__tag": 4057,
                      "value": "i"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " and column "
                    },
                    {
                      "__type": "InlineMath",
                      "__tag": 4057,
                      "value": "j"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " is the observation corresponding with subject "
                    },
                    {
                      "__type": "InlineMath",
                      "__tag": 4057,
                      "value": "i"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " and treatment "
                    },
                    {
                      "__type": "InlineMath",
                      "__tag": 4057,
                      "value": "j"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ". By default, the columns are assumed to be arranged in order of increasing predicted mean."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "ranked",
              "annotation": "boolean, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "By default, "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "data"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " is assumed to be observations rather than ranks; it will be ranked with "
                    },
                    {
                      "__type": "CrossRef",
                      "__tag": 4002,
                      "value": "scipy.stats.rankdata",
                      "reference": {
                        "__type": "RefInfo",
                        "__tag": 4000,
                        "module": "scipy",
                        "version": "*",
                        "kind": "api",
                        "path": "scipy.stats._stats_py:rankdata"
                      },
                      "kind": "module"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " along "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "axis=1"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ". If "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "data"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " is provided in the form of ranks, pass argument "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "True"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "predicted_ranks",
              "annotation": "array-like, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "The predicted ranks of the column means. If not specified, the columns are assumed to be arranged in order of increasing predicted mean, so the default "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "predicted_ranks"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " are "
                    },
                    {
                      "__type": "InlineMath",
                      "__tag": 4057,
                      "value": "[1, 2, \\dots, n-1, n]"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "method",
              "annotation": "{'auto', 'asymptotic', 'exact'}, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Selects the method used to calculate the "
                    },
                    {
                      "__type": "Emphasis",
                      "__tag": 4047,
                      "children": [
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": "p"
                        }
                      ]
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "-value. The following options are available."
                    }
                  ]
                },
                {
                  "__type": "BulletList",
                  "__tag": 4053,
                  "ordered": false,
                  "start": 1,
                  "children": [
                    {
                      "__type": "ListItem",
                      "__tag": 4054,
                      "children": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "'auto': selects between 'exact' and 'asymptotic' to   achieve reasonably accurate results in reasonable time (default)"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "__type": "ListItem",
                      "__tag": 4054,
                      "children": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "'asymptotic': compares the standardized test statistic against   the normal distribution"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "__type": "ListItem",
                      "__tag": 4054,
                      "children": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "'exact': computes the exact "
                            },
                            {
                              "__type": "Emphasis",
                              "__tag": 4047,
                              "children": [
                                {
                                  "__type": "Text",
                                  "__tag": 4046,
                                  "value": "p"
                                }
                              ]
                            },
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "-value by comparing the observed   "
                            },
                            {
                              "__type": "InlineMath",
                              "__tag": 4057,
                              "value": "L"
                            },
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": " statistic against those realized by all possible   permutations of ranks (under the null hypothesis that each   permutation is equally likely)"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Extended Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Page's Test (also known as Page's "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "L"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " test) is useful when:"
            }
          ]
        },
        {
          "__type": "BulletList",
          "__tag": 4053,
          "ordered": false,
          "start": 1,
          "children": [
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "there are "
                    },
                    {
                      "__type": "InlineMath",
                      "__tag": 4057,
                      "value": "n \\geq 3"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " treatments,"
                    }
                  ]
                }
              ]
            },
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "InlineMath",
                      "__tag": 4057,
                      "value": "m \\geq 2"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " subjects are observed for each treatment, and"
                    }
                  ]
                }
              ]
            },
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "the observations are hypothesized to have a particular order."
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Specifically, the test considers the null hypothesis that"
            }
          ]
        },
        {
          "__type": "Math",
          "__tag": 4058,
          "value": "m_1 = m_2 = m_3 \\cdots = m_n,"
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "where "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "m_j"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " is the mean of the observed quantity under treatment "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "j"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", against the alternative hypothesis that"
            }
          ]
        },
        {
          "__type": "Math",
          "__tag": 4058,
          "value": "m_1 \\leq m_2 \\leq m_3 \\leq \\cdots \\leq m_n,"
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "where at least one inequality is strict."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "As noted by "
            },
            {
              "__type": "FootnoteReference",
              "__tag": 4066,
              "label": "4"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", Page's "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "L"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " test has greater statistical power than the Friedman test against the alternative that there is a difference in trend, as Friedman's test only considers a difference in the means of the observations without considering their order. Whereas Spearman "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "\\rho"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " considers the correlation between the ranked observations of two variables (e.g. the airspeed velocity of a swallow vs. the weight of the coconut it carries), Page's "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "L"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " is concerned with a trend in an observation (e.g. the airspeed velocity of a swallow) across several distinct treatments (e.g. carrying each of five coconuts of different weight) even as the observation is repeated with multiple subjects (e.g. one European swallow and one African swallow)."
            }
          ]
        }
      ],
      "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/_page_trend_test.py",
  "item_line": 20,
  "item_type": "function",
  "aliases": [
    "scipy.stats.page_trend_test"
  ],
  "example_section_data": {
    "__type": "Section",
    "__tag": 4015,
    "children": [
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "We use the example from [3]_: 10 students are asked to rate three\nteaching methods - tutorial, lecture, and seminar - on a scale of 1-5,\nwith 1 being the lowest and 5 being the highest. We have decided that\na confidence level of 99% is required to reject the null hypothesis in\nfavor of our alternative: that the seminar will have the highest ratings\nand the tutorial will have the lowest. Initially, the data have been\ntabulated with each row representing an individual student's ratings of\nthe three methods in the following order: tutorial, lecture, seminar.\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "table = [[3, 4, 3],\n         [2, 2, 4],\n         [3, 3, 5],\n         [1, 3, 2],\n         [2, 3, 2],\n         [2, 4, 5],\n         [1, 2, 4],\n         [3, 4, 4],\n         [2, 4, 5],\n         [1, 3, 4]]\n",
        "execution_status": "success"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nBecause the tutorial is hypothesized to have the lowest ratings, the\ncolumn corresponding with tutorial rankings should be first; the seminar\nis hypothesized to have the highest ratings, so its column should be last.\nSince the columns are already arranged in this order of increasing\npredicted mean, we can pass the table directly into `page_trend_test`.\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "from scipy.stats import page_trend_test\nres = page_trend_test(table)\n",
        "execution_status": "success"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "res\n",
        "execution_status": "failure"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nThis *p*-value indicates that there is a 0.1819% chance that\nthe :math:`L` statistic would reach such an extreme value under the null\nhypothesis. Because 0.1819% is less than 1%, we have evidence to reject\nthe null hypothesis in favor of our alternative at a 99% confidence level.\n\nThe value of the :math:`L` statistic is 133.5. To check this manually,\nwe rank the data such that high scores correspond with high ranks, settling\nties with an average rank:\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "from scipy.stats import rankdata\nranks = rankdata(table, axis=1)\nranks\n",
        "execution_status": "success"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nWe add the ranks within each column, multiply the sums by the\npredicted ranks, and sum the products.\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "import numpy as np\nm, n = ranks.shape\npredicted_ranks = np.arange(1, n+1)\nL = (predicted_ranks * np.sum(ranks, axis=0)).sum()\n",
        "execution_status": "success"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "res.statistic == L\n",
        "execution_status": "failure"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nAs presented in [3]_, the asymptotic approximation of the *p*-value is the\nsurvival function of the normal distribution evaluated at the standardized\ntest statistic:\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "from scipy.stats import norm\nE0 = (m*n*(n+1)**2)/4\nV0 = (m*n**2*(n+1)*(n**2-1))/144\nLambda = (L-E0)/np.sqrt(V0)\np = norm.sf(Lambda)\n",
        "execution_status": "success"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "p\n",
        "execution_status": "failure"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nThis does not precisely match the *p*-value reported by `page_trend_test`\nabove. The asymptotic distribution is not very accurate, nor conservative,\nfor :math:`m \\leq 12` and :math:`n \\leq 8`, so `page_trend_test` chose to\nuse ``method='exact'`` based on the dimensions of the table and the\nrecommendations in Page's original paper [1]_. To override\n`page_trend_test`'s choice, provide the `method` argument.\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "res = page_trend_test(table, method=\"asymptotic\")\n",
        "execution_status": "success"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "res\n",
        "execution_status": "failure"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nIf the data are already ranked, we can pass in the ``ranks`` instead of\nthe ``table`` to save computation time.\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "res = page_trend_test(ranks,             # ranks of data\n                      ranked=True,       # data is already ranked\n                      )\n",
        "execution_status": "success"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "res\n",
        "execution_status": "failure"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nSuppose the raw data had been tabulated in an order different from the\norder of predicted means, say lecture, seminar, tutorial.\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "table = np.asarray(table)[:, [1, 2, 0]]\n",
        "execution_status": "success"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nSince the arrangement of this table is not consistent with the assumed\nordering, we can either rearrange the table or provide the\n`predicted_ranks`. Remembering that the lecture is predicted\nto have the middle rank, the seminar the highest, and tutorial the lowest,\nwe pass:\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "res = page_trend_test(table,             # data as originally tabulated\n                      predicted_ranks=[2, 3, 1],  # our predicted order\n                      )\n",
        "execution_status": "success"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "res\n",
        "execution_status": "failure"
      }
    ],
    "title": [],
    "level": 0,
    "target": null
  },
  "see_also": [
    {
      "__type": "SeeAlsoItem",
      "__tag": 4028,
      "name": {
        "__type": "CrossRef",
        "__tag": 4002,
        "value": "friedmanchisquare",
        "reference": {
          "__type": "RefInfo",
          "__tag": 4000,
          "module": "current-module",
          "version": "current-version",
          "kind": "to-resolve",
          "path": "friedmanchisquare"
        },
        "kind": "module"
      },
      "descriptions": [],
      "type": "func"
    },
    {
      "__type": "SeeAlsoItem",
      "__tag": 4028,
      "name": {
        "__type": "CrossRef",
        "__tag": 4002,
        "value": "rankdata",
        "reference": {
          "__type": "RefInfo",
          "__tag": 4000,
          "module": "current-module",
          "version": "current-version",
          "kind": "to-resolve",
          "path": "rankdata"
        },
        "kind": "module"
      },
      "descriptions": [],
      "type": "func"
    },
    {
      "__type": "SeeAlsoItem",
      "__tag": 4028,
      "name": {
        "__type": "CrossRef",
        "__tag": 4002,
        "value": "spearmanr",
        "reference": {
          "__type": "RefInfo",
          "__tag": 4000,
          "module": "current-module",
          "version": "current-version",
          "kind": "to-resolve",
          "path": "spearmanr"
        },
        "kind": "module"
      },
      "descriptions": [],
      "type": "func"
    }
  ],
  "signature": {
    "__type": "SignatureNode",
    "__tag": 4029,
    "kind": "function",
    "parameters": [
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "data",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": {
          "__type": "Empty",
          "__tag": 4031
        }
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "ranked",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "False"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "predicted_ranks",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "None"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "method",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "auto"
      }
    ],
    "return_annotation": {
      "__type": "Empty",
      "__tag": 4031
    },
    "target_name": "page_trend_test"
  },
  "references": [
    ".. [1] Ellis Batten Page, \"Ordered hypotheses for multiple treatments:",
    "   a significant test for linear ranks\", *Journal of the American",
    "   Statistical Association* 58(301), p. 216--230, 1963.",
    "",
    ".. [2] Markus Neuhauser, *Nonparametric Statistical Test: A computational",
    "   approach*, CRC Press, p. 150--152, 2012.",
    "",
    ".. [3] Statext LLC, \"Page's L Trend Test - Easy Statistics\", *Statext -",
    "   Statistics Study*, https://www.statext.com/practice/PageTrendTest03.php,",
    "   Accessed July 12, 2020.",
    "",
    ".. [4] \"Page's Trend Test\", *Wikipedia*, WikimediaFoundation,",
    "   https://en.wikipedia.org/wiki/Page%27s_trend_test,",
    "   Accessed July 12, 2020.",
    "",
    ".. [5] Robert E. Odeh, \"The exact distribution of Page's L-statistic in",
    "   the two-way layout\", *Communications in Statistics - Simulation and",
    "   Computation*,  6(1), p. 49--61, 1977."
  ],
  "qa": "scipy.stats._page_trend_test:page_trend_test",
  "arbitrary": [],
  "local_refs": [
    "data",
    "method",
    "predicted_ranks",
    "ranked",
    "res"
  ]
}