Bayesian hierarchical model (source code)

= Bayesian hierarchical model
{c}

A \b[Bayesian hierarchical model] is a <statistical model> used in <Bayesian statistics>, in which parameters at one level have a <prior distribution> controlled by parameters at another level. Those shared <hyperparameters> can themselves receive a <hyperprior>. For grouped observations $y_j$, group parameters $\theta_j$ and shared parameters $\phi$, one common conditional-independence structure is
$$
p(y,\theta,\phi)=p(\phi)\prod_jp(\theta_j\mid\phi)\,p(y_j\mid\theta_j).
$$
The hierarchy specifies how information can be shared; the data are not assumed to become independent merely because they are listed in different groups.<Stan User's Guide by Stan Development Team>[Regression Models, Hierarchical regression and Hierarchical priors]{ref}

A <normal distribution> example makes <partial pooling> explicit. Let $\bar y_j\mid\theta_j\sim\mathcal N(\theta_j,\sigma^2/n_j)$ and $\theta_j\mid\mu,\tau\sim\mathcal N(\mu,\tau^2)$. Conditional on known $\mu,\tau,\sigma$, completing the square gives the <posterior mean>
$$
E(\theta_j\mid\bar y_j,\mu,\tau,\sigma)=w_j\bar y_j+(1-w_j)\mu,\qquad w_j=\frac{n_j\tau^2}{\sigma^2+n_j\tau^2}.
$$
For $n_j=4$, $\sigma^2=4$, $\tau^2=1$, $\mu=2$ and $\bar y_j=6$, this is4, halfway between the group mean and the shared mean. More precise group data increase $w_j$. In a full hierarchy with uncertain <hyperparameters>, their <posterior distribution> must also be integrated over; simply fixing fitted values omits that uncertainty.

A measurement application appears in <Blaza Toman>'s2017 calibration study. Shared uncertain calibration inputs induce correlations among results; the <Bayesian hierarchical model> represents this structure within the model rather than treating all replicates as independent.<Rigorous evaluation of chemical measurement uncertainty: Liquid chromatographic analysis methods using detector response factor calibration by Blaza Toman and others>[Introduction and §3.2: Bayesian observation model and shared calibration inputs]{ref}