{
  "aliases": null,
  "backlinks": null,
  "body": "\n## Definition\n\nLet $Z = (Z_1, \\dots, Z_N)$ be a random vector, and let $S_N$ be the [[symmetric group|0RJMNEN3BJ]], acting on $\\R^N$ by $(\\pi z)_i = z_{\\pi^{-1}(i)}$.\nLet $H_0$ be a null hypothesis under which $Z$ is exchangeable, that is, $\\pi Z$ has the same law as $Z$ for every $\\pi \\in S_N$.\nLet $T \\colon \\R^N \\to \\R$ be a [[statistic|036756NFD6]].\nThe *permutation p-value* is\n$$p(Z) = \\frac{1}{N!} \\, \\#\\set{\\pi \\in S_N : T(\\pi Z) \\ge T(Z)}.$$\nThe *permutation test* at level $\\alpha$ rejects $H_0$ when $p(Z) \\le \\alpha$.\n\n## Remarks\n\nUnder $H_0$, $P(p(Z) \\le \\alpha) \\le \\alpha$ for every $\\alpha \\in [0, 1]$, so the test has level $\\alpha$, whatever the law of $Z$.\nIn the two-sample problem, $Z$ is the pooled sample $X_1, \\dots, X_m, Y_1, \\dots, Y_n$ with $N = m + n$, and $H_0$ says that all $N$ values are i.i.d.\nSince $T$ usually depends only on which values fall in the first group, one may count the $\\binom{N}{m}$ splits instead of the $N!$ permutations.\nWhen $N!$ is too large, one uses a random sample of permutations, which gives a Monte Carlo approximation of $p(Z)$.\n\nExample: $X = (3, 5)$, $Y = (1, 4)$ and $T = \\bar X - \\bar Y$, so $T = 4 - 2.5 = 1.5$.\nThe $6$ splits of $\\set{1, 3, 4, 5}$ give the $X$-pairs $\\set{1,3}, \\set{1,4}, \\set{1,5}, \\set{3,4}, \\set{3,5}, \\set{4,5}$ and the values $-2.5, -1.5, -0.5, 0.5, 1.5, 2.5$.\nTwo of them are at least $1.5$, so $p = 2/6 = 1/3$.\n\nNon-example: if under $H_0$ the two groups have the same mean but different variances, the pooled vector is not exchangeable.\nThe clause on exchangeability fails, and the test of equal means need not have level $\\alpha$.\n\nThe [[Mann–Whitney U test|CKF9KDXBP7]] is a permutation test whose statistic depends only on the ranks.\n",
  "commit": "ff8a40749dc16545e3d2fc637f6b0196e81d0bfa",
  "front": {
    "defines": "2ECAM46NE2",
    "kind": "definition",
    "msc": [
      "62G10",
      "62G09"
    ],
    "name": "Permutation test",
    "sources": [
      {
        "url": "https://en.wikipedia.org/wiki/Permutation_test"
      }
    ],
    "tag": "YA786MZ8QD",
    "uses": [
      "087P03NEND",
      "0EHYZFZ4PK",
      "036756NFD6",
      "0RJMNEN3BJ"
    ]
  },
  "kind": "definition",
  "link": "https://tamnd.github.io/math2/node/YA786MZ8QD/",
  "links": [
    {
      "field": "defines",
      "target": "2ECAM46NE2"
    },
    {
      "field": "uses",
      "target": "087P03NEND"
    },
    {
      "field": "uses",
      "target": "0EHYZFZ4PK"
    },
    {
      "field": "uses",
      "target": "036756NFD6"
    },
    {
      "field": "uses",
      "target": "0RJMNEN3BJ"
    }
  ],
  "markdown": "https://tamnd.github.io/math2/node/YA786MZ8QD.md",
  "msc": [
    "62G10",
    "62G09"
  ],
  "name": "Permutation test",
  "prov": null,
  "role": "",
  "source": "https://github.com/tamnd/math2/blob/main/nodes/YA7/YA786MZ8QD.md",
  "status": null,
  "tag": "YA786MZ8QD",
  "uri": "m2://YA786MZ8QD",
  "url": "https://tamnd.github.io/math2/wiki/permutation-test-definition/",
  "writing": {
    "tag": "YA786MZ8QD",
    "kind": "definition",
    "level": "W0",
    "next": [
      {
        "what": "an inventory row",
        "note": "the row of the inventory that the node accounts for",
        "have": 0,
        "want": 1
      },
      {
        "what": "a source with a locator",
        "have": 0,
        "want": 1
      }
    ]
  }
}
