{
  "aliases": null,
  "backlinks": null,
  "body": "\n## Definition\n\nLet $X$ and $Y$ be real random variables and let $Z$ be a random vector in $\\R^k$, all with finite second moments.\nAssume that the [[covariance matrix|0V7G6WMFK0]] $\\Sigma_{ZZ}$ of $Z$ is [[invertible|0EB9N0S33C]].\nWrite $\\Sigma_{XZ}$ for the row vector of [[covariances|0KBFAWYRTE]] $\\operatorname{Cov}(X, Z_j)$, and similarly $\\Sigma_{YZ}$.\nThe residuals of the best linear predictions of $X$ and $Y$ from $Z$ are\n$$e_X = X - \\mathbb{E}X - \\Sigma_{XZ} \\Sigma_{ZZ}^{-1} (Z - \\mathbb{E}Z), \\qquad e_Y = Y - \\mathbb{E}Y - \\Sigma_{YZ} \\Sigma_{ZZ}^{-1} (Z - \\mathbb{E}Z).$$\nIf $\\operatorname{Var}(e_X) \u003e 0$ and $\\operatorname{Var}(e_Y) \u003e 0$, the *partial correlation* of $X$ and $Y$ given $Z$ is the [[correlation coefficient|0DNN9B6Q2F]]\n$$\\rho_{XY \\cdot Z} = \\operatorname{Corr}(e_X, e_Y).$$\n\n## Remarks\n\nExample: let $Z, U, V$ be uncorrelated with variance $1$ and mean $0$, and let $X = Z + U$, $Y = Z + V$.\nThen $\\Sigma_{XZ} = \\Sigma_{YZ} = 1$ and $\\Sigma_{ZZ} = 1$, so $e_X = U$ and $e_Y = V$, and $\\rho_{XY \\cdot Z} = 0$.\nYet $\\operatorname{Corr}(X, Y) = 1/2$.\nNon-example: if $X = Z$, then $e_X = 0$, so $\\operatorname{Var}(e_X) = 0$ and the partial correlation is not defined.\n\nFor a single control variable $Z$, with $\\rho_{XY}$, $\\rho_{XZ}$, $\\rho_{YZ}$ the pairwise correlations,\n$$\\rho_{XY \\cdot Z} = \\frac{\\rho_{XY} - \\rho_{XZ} \\rho_{YZ}}{\\sqrt{(1 - \\rho_{XZ}^2)(1 - \\rho_{YZ}^2)}}.$$\nIf $P = (p_{ij})$ is the inverse of the covariance matrix of $(X, Y, Z)$, then $\\rho_{XY \\cdot Z} = -p_{12} / \\sqrt{p_{11} p_{22}}$.\nThe sample partial correlation uses the sample covariances, or equivalently the residuals of least squares fits on the data.\n",
  "commit": "ff8a40749dc16545e3d2fc637f6b0196e81d0bfa",
  "front": {
    "defines": "TT3BXBR4DB",
    "kind": "definition",
    "msc": [
      "62H20"
    ],
    "name": "Partial correlation",
    "sources": [
      {
        "url": "https://en.wikipedia.org/wiki/Partial_correlation"
      }
    ],
    "tag": "RVVRYKVGXK",
    "uses": [
      "0DNN9B6Q2F",
      "0KBFAWYRTE",
      "0V7G6WMFK0",
      "0EB9N0S33C"
    ]
  },
  "kind": "definition",
  "link": "https://tamnd.github.io/math2/node/RVVRYKVGXK/",
  "links": [
    {
      "field": "defines",
      "target": "TT3BXBR4DB"
    },
    {
      "field": "uses",
      "target": "0DNN9B6Q2F"
    },
    {
      "field": "uses",
      "target": "0KBFAWYRTE"
    },
    {
      "field": "uses",
      "target": "0V7G6WMFK0"
    },
    {
      "field": "uses",
      "target": "0EB9N0S33C"
    }
  ],
  "markdown": "https://tamnd.github.io/math2/node/RVVRYKVGXK.md",
  "msc": [
    "62H20"
  ],
  "name": "Partial correlation",
  "prov": null,
  "role": "",
  "source": "https://github.com/tamnd/math2/blob/main/nodes/RVV/RVVRYKVGXK.md",
  "status": null,
  "tag": "RVVRYKVGXK",
  "uri": "m2://RVVRYKVGXK",
  "url": "https://tamnd.github.io/math2/wiki/partial-correlation-definition/",
  "writing": {
    "tag": "RVVRYKVGXK",
    "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
      }
    ]
  }
}
