Tutorials › Generalized Linear Mixed Models (GLMM) › Wishart Priors and Covariance-Scale Dependence

Bayesian GLMM and Prior Specification for Variance Components · Tutorial 259 of 698

Wishart Priors and Covariance-Scale Dependence

You will learn to interpret Wishart and inverse-Wishart covariance priors, check their existence conditions, and identify scale–correlation dependence induced by their joint density.

Advanced 12 min read

What You'll Learn

  • Distinguish Wishart priors on covariance matrices from Wishart priors on precision matrices.
  • Check propriety and finite-mean conditions for inverse-Wishart priors.
  • Derive how an inverse-Wishart prior couples marginal variances and correlations.
  • Interpret the role and units of a prior scale matrix.
  • Compare covariance-matrix priors with separate scale and correlation specifications.
  • Recognize prior checks that can reveal unintended covariance behavior.

Why Matrix Priors Need Careful Interpretation

A random-effects covariance matrix must be positive definite, so a prior on its entries cannot be chosen as if each entry varied independently over the real line. Wishart and inverse-Wishart distributions provide distributions supported on positive-definite matrices. Their convenience comes with an important cost: a prior that looks simple in matrix form can imply non-obvious marginal distributions for standard deviations and correlations. In particular, the scales and correlations need not be prior-independent.

For a GLMM with a \(q\)-dimensional random effect, write its covariance matrix as \(\Sigma\). Its diagonal entries are random-effect variances, and its off-diagonal entries describe covariances. The corresponding correlations are obtained by dividing each covariance by the product of the two associated standard deviations. The introductory material on constructing covariance matrices from scales and correlations establishes this decomposition; here the focus is how matrix-distribution priors behave under it.

Definition: A \(p\times p\) matrix \(\Sigma\) is positive definite if it is symmetric and \(a^\mathsf{T}\Sigma a>0\) for every nonzero vector \(a\). A covariance matrix prior must assign probability only to such matrices. In the conventions here, \(W_p(\nu,V)\) denotes a Wishart distribution with degrees of freedom \(\nu\) and scale matrix \(V\); \(IW_p(\nu,\Psi)\) denotes an inverse-Wishart distribution with degrees of freedom \(\nu\) and scale matrix \(\Psi\).

Wishart and Inverse-Wishart Conventions

Both distributions require a positive-definite matrix parameter. The following parameterizations fix what “scale matrix” means, since other references sometimes use different parameter conventions. Let \(|A|\) denote the determinant of a matrix \(A\), and let \(\operatorname{tr}(A)\) denote its trace. The multivariate gamma function is \(\Gamma_p(a)=\pi^{p(p-1)/4}\prod_{j=1}^{p}\Gamma(a+(1-j)/2)\).

$$ f_W(S)= \frac{|S|^{(\nu-p-1)/2} \exp\{-\tfrac12\operatorname{tr}(V^{-1}S)\}} {2^{\nu p/2}|V|^{\nu/2}\Gamma_p(\nu/2)}, \qquad S>0,\quad \nu>p-1. $$

For \(S\sim W_p(\nu,V)\), the mean exists and is \(E(S)=\nu V\). When \(\nu\) is a positive integer, this distribution can be represented as the sum of \(\nu\) outer products of independent \(N_p(0,V)\) vectors; the density also defines it for real \(\nu>p-1\). A Wishart prior is often placed on a precision matrix \(\Omega=\Sigma^{-1}\), rather than directly on a covariance matrix.

$$ f_{IW}(\Sigma)= \frac{|\Psi|^{\nu/2}} {2^{\nu p/2}\Gamma_p(\nu/2)} |\Sigma|^{-(\nu+p+1)/2} \exp\{-\tfrac12\operatorname{tr}(\Psi\Sigma^{-1})\}, \qquad \Sigma>0,\quad \nu>p-1. $$

If \(\Sigma\sim IW_p(\nu,\Psi)\), then \(\Sigma^{-1}\sim W_p(\nu,\Psi^{-1})\). The inverse-Wishart distribution is proper when \(\nu>p-1\), but its mean exists only when \(\nu>p+1\), in which case \(E(\Sigma)=\Psi/(\nu-p-1)\). These conditions are distinct: propriety does not guarantee a finite covariance mean. The entries of \(\Psi\) have the units of covariance entries, but \(\Psi\) is not generally the prior mean.

Worked Example: Checking an Inverse-Wishart Mean

Suppose a three-dimensional random-effect covariance matrix has prior \(\Sigma\sim IW_3(5,\Psi)\), where \(\Psi=\operatorname{diag}(2,3,4)\) in the relevant squared units. Check propriety and calculate the prior mean.

Here \(p=3\). Propriety requires \(\nu>p-1\), and \(5>3-1=2\), so the prior is proper. A finite mean requires \(\nu>p+1\), and \(5>3+1=4\), so the mean exists. Its value is

$$ E(\Sigma)=\frac{\Psi}{\nu-p-1} =\frac{\operatorname{diag}(2,3,4)}{5-3-1} =\operatorname{diag}(2,3,4). $$

Thus the prior mean variances are \(2\), \(3\), and \(4\) in the corresponding squared units. The mean is not a statement that the standard deviations equal the square roots of those values: in general \(E(\sqrt{\Sigma_{jj}})\ne\sqrt{E(\Sigma_{jj})}\).

How the Inverse-Wishart Couples Scales and Correlations

The coupling can be seen directly in dimension two. Write the covariance matrix in terms of variances \(v_1,v_2>0\) and correlation \(-1<\rho<1\):

$$ \Sigma= \begin{pmatrix} v_1 & \rho\sqrt{v_1v_2}\\ \rho\sqrt{v_1v_2} & v_2 \end{pmatrix}, \qquad |\Sigma|=v_1v_2(1-\rho^2). $$

Positive definiteness is equivalent here to \(v_1>0\), \(v_2>0\), and \(|\rho|<1\). The absolute Jacobian determinant for transforming from \((v_1,v_2,\rho)\) to the three distinct entries of \(\Sigma\) is \(\sqrt{v_1v_2}\). Substitution into the inverse-Wishart density, including this Jacobian, gives the joint density on variances and correlation, up to a constant independent of those variables:

$$ f(v_1,v_2,\rho)\ \propto\ (v_1v_2)^{-(\nu+2)/2}(1-\rho^2)^{-(\nu+3)/2} \exp\left[ -\frac{\Psi_{11}/v_1+\Psi_{22}/v_2 -2\Psi_{12}\rho/\sqrt{v_1v_2}} {2(1-\rho^2)} \right]. $$

This expression is not generally a product of a function of \(v_1,v_2\) and a function of \(\rho\). Even when \(\Psi\) is diagonal, the exponent contains the scale-dependent quantity \(\Psi_{11}/v_1+\Psi_{22}/v_2\), divided by \(1-\rho^2\). Consequently, the conditional distribution of \(\rho\) changes with the variances. The coupling is a feature of the induced prior, not a dependence introduced by observing data.

Worked Example: Comparing Conditional Correlation Densities

Let \(\Sigma\sim IW_2(5,I_2)\). This is proper because \(5>2-1\). For a fixed pair of variances \(v_1=v_2=v\), derive the ratio of the conditional density of \(\rho=0.8\) to that of \(\rho=0\), then compare \(v=1\) with \(v=4\). These are density ratios, not probabilities at individual points.

With \(\Psi_{11}=\Psi_{22}=1\) and \(\Psi_{12}=0\), factors not depending on \(\rho\) cancel. Since \((\nu+3)/2=4\), the conditional density is proportional to \((1-\rho^2)^{-4}\exp\{-1/[v(1-\rho^2)]\}\). Therefore,

$$ \frac{f(\rho=0.8\mid v,v)}{f(\rho=0\mid v,v)} =(0.36)^{-4} \exp\left\{-\frac{1}{v}\left(\frac{1}{0.36}-1\right)\right\}. $$

The determinant factor is \((0.36)^{-4}\approx59.53\), and \(1/0.36-1\approx1.7778\). At \(v=1\), the ratio is \(59.53e^{-1.7778}\approx10.10\). At \(v=4\), it is \(59.53e^{-0.4444}\approx38.20\). Thus the relative conditional density at correlation \(0.8\), compared with correlation zero, differs substantially across these two scale settings. This demonstrates scale–correlation dependence under this prior. It does not imply that either ratio is a posterior probability or that \(\rho=0.8\) is likely in an unconditional draw.

Wishart Priors on Precision and Their Covariance Implications

A Wishart prior is often used for a precision matrix. This choice should be interpreted on the covariance scale before it is adopted for random effects. If \(\Omega\sim W_p(\nu,V)\) and \(\Sigma=\Omega^{-1}\), then the induced covariance prior is \(IW_p(\nu,V^{-1})\). When its mean exists,

$$ E(\Sigma)=\frac{V^{-1}}{\nu-p-1}, \qquad \nu>p+1. $$

Thus \(V\) is the Wishart scale for precision, not a covariance target. Inverting the mean of \(\Omega\) is not the same operation as taking the mean of \(\Omega^{-1}\).

Worked Example: Translating a Wishart Precision Prior

For two random effects, suppose \(\Omega\sim W_2(6,V)\), with \(V=\operatorname{diag}(2,0.5)\), where entries are expressed in precision units. Find the induced covariance prior and its mean.

The inverse-Wishart scale is \(V^{-1}=\operatorname{diag}(0.5,2)\), so \(\Sigma\sim IW_2(6,\operatorname{diag}(0.5,2))\). The prior is proper because \(6>2-1\), and its mean exists because \(6>2+1\). The denominator is \(6-2-1=3\), giving

$$ E(\Sigma)=\frac{\operatorname{diag}(0.5,2)}{3} =\operatorname{diag}(0.1667,0.6667). $$

The resulting expected variances are \(0.1667\) and \(0.6667\) in their respective squared units. This calculation illustrates why the prior must be assessed on the covariance scale relevant to the random effects, even when it was specified on precision.

Assumptions, Diagnostics, and Alternatives

These distributions are mathematically defined on positive-definite matrices, but mathematical validity alone does not establish that a prior is appropriate for a GLMM. The model must identify which random effects the matrix describes, and their units and scaling must be clear. For random slopes, changing the units or centering of a predictor changes the interpretation of the covariance entries and correlations. A prior specified before such a transformation need not express the same substantive beliefs afterward.

Useful prior checks include drawing covariance matrices from the prior and examining the implied standard deviations, correlations, and resulting random-effect values on the model’s linear-predictor scale. Check the probability of near-zero or very large scales, the frequency of correlations near \(-1\) or \(1\), and whether plausible combinations of scales and correlations occur together. If the inverse-Wishart mean does not exist, do not summarize its covariance prior using a finite mean; inspect quantiles or prior draws instead.

Common warning signs include a scale parameter interpreted as a mean when it is not, a Wishart prior placed on covariance when precision was intended, and apparently reasonable marginal scale summaries paired with undesirable joint behavior. A prior-predictive check should preserve the joint draws: independently recombining sampled scales and correlations would erase the dependence being assessed.

ApproachWhat is specified directlyKey consideration
Inverse-Wishart on covarianceA single positive-definite covariance matrix distributionScales and correlations are generally coupled; degrees of freedom affect the entire joint prior.
Wishart on precisionA positive-definite precision matrix distributionTranslate to the induced inverse-Wishart covariance prior and check its scales and moments.
Separate priors on scales and correlationsMarginal standard deviations and a correlation matrixAllows more direct calibration, while the resulting covariance must still be positive definite.

Separate scale and correlation priors, including the LKJ family for correlation matrices, can make substantive calibration more transparent. That flexibility does not automatically make a prior suitable: the selected scale distributions, correlation concentration, predictor coding, and joint prior predictions still require assessment. A matrix prior may remain useful when its dependence structure is intended or when its algebraic convenience is valuable, but convenience is not a substitute for examining its induced behavior.

Common pitfall: “The inverse-Wishart scale matrix is the prior mean covariance, and its scales and correlations can be interpreted separately.” Both claims are generally wrong. The mean is \(\Psi/(\nu-p-1)\) only when \(\nu>p+1\), and the transformed joint density usually couples variances and correlations. Calculate the existence conditions and inspect the induced joint prior before interpreting it.

Check Your Understanding

Answer each question, then compare with the short solutions.

  1. For \(\Sigma\sim IW_4(5,\Psi)\), is the prior proper? Does its covariance mean exist?
  2. For \(\Sigma\sim IW_3(6,\Psi)\), what is \(E(\Sigma)\), if it exists?
  3. Why does a diagonal inverse-Wishart scale matrix not generally make the induced variances and correlation independent?
  4. If \(\Omega\sim W_3(7,V)\) and \(\Sigma=\Omega^{-1}\), what inverse-Wishart parameters describe \(\Sigma\), and does its mean exist?

Solutions. (1) Propriety requires \(5>4-1=3\), so it is proper. A finite mean requires \(5>4+1=5\), which is false; the mean does not exist as a finite matrix. (2) Since \(6>3+1=4\), the mean exists and is \(E(\Sigma)=\Psi/(6-3-1)=\Psi/2\). (3) Even if \(\Psi_{12}=0\), the joint density contains the factor \(\exp\{-[\Psi_{11}/v_1+\Psi_{22}/v_2]/[2(1-\rho^2)]\}\), which depends jointly on variances and correlation. (4) The induced distribution is \(\Sigma\sim IW_3(7,V^{-1})\). Its mean exists because \(7>3+1=4\), and \(E(\Sigma)=V^{-1}/(7-3-1)=V^{-1}/3\).

Clinical Biostats