{
  "aliases": null,
  "backlinks": null,
  "body": "\n## Definition\n\nA *Bayesian hierarchical model* (with two levels of prior) consists of the following.\n\n1. A [[parametric model|Q0DXKAQXE1]] for the data: given a parameter $\\theta \\in \\Theta$, the data $x$ have density $f(x \\mid \\theta)$.\n2. A [[prior|00NBBSXRQS]] for $\\theta$ that depends on a hyperparameter $\\varphi \\in \\Phi$: given $\\varphi$, the parameter $\\theta$ has density $\\pi(\\theta \\mid \\varphi)$.\n3. A hyperprior: a probability distribution on $\\Phi$ with density $\\pi(\\varphi)$.\n\nThe joint density of $(x, \\theta, \\varphi)$ is $f(x \\mid \\theta)\\,\\pi(\\theta \\mid \\varphi)\\,\\pi(\\varphi)$, and the [[posterior|0KJ7ZS8AJA]] of $(\\theta, \\varphi)$ given $x$ is proportional to it, by [[Bayes' theorem|0NM6E9VW04]].\n\n## Remarks\n\nModels with more levels add further hyperpriors in the same way.\nExample: data in $J$ groups with $X_{ij} \\mid \\theta_j \\sim \\mathcal{N}(\\theta_j, \\sigma^2)$, group means $\\theta_j \\mid \\mu, \\tau \\sim \\mathcal{N}(\\mu, \\tau^2)$ i.i.d., and a hyperprior on $(\\mu, \\tau)$.\nAll three clauses hold, with $\\theta = (\\theta_1, \\dots, \\theta_J)$ and $\\varphi = (\\mu, \\tau)$.\nGiven $\\mu$ and $\\tau$, the posterior mean of each $\\theta_j$ lies between the sample mean of group $j$ and the overall level $\\mu$.\nNon-example: the same model with $\\mu$ and $\\tau$ fixed numbers has no hyperprior, so clause 3 fails; it is an ordinary one-level Bayesian model.\nIntegrating out $\\theta$ gives the marginal $\\int f(x \\mid \\theta)\\pi(\\theta \\mid \\varphi)\\,d\\theta$; estimating $\\varphi$ from it instead of using a hyperprior is the empirical Bayes approach.\n",
  "commit": "ff8a40749dc16545e3d2fc637f6b0196e81d0bfa",
  "front": {
    "defines": "P944X6S117",
    "kind": "definition",
    "msc": [
      "62F15"
    ],
    "name": "Bayesian hierarchical model",
    "sources": [
      {
        "url": "https://en.wikipedia.org/wiki/Bayesian_hierarchical_modeling"
      }
    ],
    "tag": "PTK8XCQ0GK",
    "uses": [
      "Q0DXKAQXE1",
      "00NBBSXRQS",
      "0KJ7ZS8AJA",
      "0NM6E9VW04"
    ]
  },
  "kind": "definition",
  "link": "https://tamnd.github.io/math2/node/PTK8XCQ0GK/",
  "links": [
    {
      "field": "defines",
      "target": "P944X6S117"
    },
    {
      "field": "uses",
      "target": "Q0DXKAQXE1"
    },
    {
      "field": "uses",
      "target": "00NBBSXRQS"
    },
    {
      "field": "uses",
      "target": "0KJ7ZS8AJA"
    },
    {
      "field": "uses",
      "target": "0NM6E9VW04"
    }
  ],
  "markdown": "https://tamnd.github.io/math2/node/PTK8XCQ0GK.md",
  "msc": [
    "62F15"
  ],
  "name": "Bayesian hierarchical model",
  "prov": null,
  "role": "",
  "source": "https://github.com/tamnd/math2/blob/main/nodes/PTK/PTK8XCQ0GK.md",
  "status": null,
  "tag": "PTK8XCQ0GK",
  "uri": "m2://PTK8XCQ0GK",
  "url": "https://tamnd.github.io/math2/wiki/bayesian-hierarchical-model-definition/",
  "writing": {
    "tag": "PTK8XCQ0GK",
    "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
      }
    ]
  }
}
