Tutorials › Bayesian Clinical Trials › Deriving Posterior Covariance Across Subgroups

Hierarchical Models and Basket Trials · Tutorial 466 of 696

Deriving Posterior Covariance Across Subgroups

Derive and interpret cross-subgroup posterior covariance, separating the effect of within-subgroup uncertainty from uncertainty in the shared population mean.

Advanced 12 min read

What You'll Learn

  • State the assumptions for deriving cross-subgroup covariance in a normal-normal hierarchy.
  • Derive the covariance using the law of total covariance.
  • Calculate posterior covariance, marginal variances, and correlation from hypothetical subgroup data.
  • Explain how additional subgroup information can reduce covariance through the shared mean.
  • Distinguish marginal posterior dependence from conditional independence and from complete pooling.
  • Identify modeling and calculation checks that reveal common covariance errors.

Why Posterior Covariance Matters

In a hierarchical trial, subgroup effects can be conditionally independent given a shared population mean and still be dependent in the posterior distribution after that mean is integrated out. The distinction matters: posterior covariance describes how uncertainty in one subgroup effect moves with uncertainty in another, and it can affect joint summaries and decisions involving more than one subgroup.

This tutorial derives that covariance for a normal-normal hierarchy with known sampling variances and known between-subgroup variance. The calculation isolates the role of uncertainty in the shared mean. It does not imply that two subgroup effects are identical, nor does it measure their clinical similarity by itself.

Model and assumptions: For subgroups \(j=1,\ldots,J\), let \(y_j\) be an estimated subgroup effect with known sampling variance \(v_j\). Assume \(y_j\mid\theta_j\sim N(\theta_j,v_j)\), independently across subgroups conditional on the effects; \(\theta_j\mid\mu\sim N(\mu,\tau^2)\), independently across subgroups conditional on the shared mean \(\mu\); and \(\mu\sim N(m_0,s_0^2)\). Here \(\tau^2\), \(v_j\), and \(s_0^2\) are known and positive. The effects and their variances are on a common scale.

The assumptions specify both levels of the model. The observed estimates are independent conditional on their subgroup effects, and the subgroup effects are independent conditional on \(\mu\). Dependence between effects can nevertheless appear after integrating over the uncertain \(\mu\). The known-variance assumption makes the derivation conjugate and exact; it is not a claim that a real clinical analysis must know these variances perfectly.

Deriving the Covariance

First condition on \(\mu\). Combining the normal sampling model and normal subgroup prior gives

$$ \theta_j\mid\mu,y_j\sim N\left(A_jy_j+C_j\mu,\ r_j\right), \qquad A_j=\frac{\tau^2}{\tau^2+v_j},\quad C_j=\frac{v_j}{\tau^2+v_j},\quad r_j=\frac{\tau^2v_j}{\tau^2+v_j}. $$

The weights \(A_j\) and \(C_j\) sum to one. Conditional on \(\mu\), each subgroup estimate is blended with the shared mean; \(r_j\) is the conditional posterior variance. Because the subgroup effects are conditionally independent given \(\mu\) and the data, their conditional covariance is zero for distinct subgroups \(i\ne j\).

The marginal posterior for \(\mu\) is also normal. Integrating out each \(\theta_j\) gives \(y_j\mid\mu\sim N(\mu,\tau^2+v_j)\), independently across \(j\). Thus, writing \(V_\mu=\operatorname{Var}(\mu\mid y_1,\ldots,y_J)\) and \(M=E(\mu\mid y_1,\ldots,y_J)\),

$$ V_\mu=\left(\frac{1}{s_0^2}+\sum_{j=1}^{J}\frac{1}{\tau^2+v_j}\right)^{-1}, \qquad M=V_\mu\left(\frac{m_0}{s_0^2}+\sum_{j=1}^{J}\frac{y_j}{\tau^2+v_j}\right). $$

Now apply the law of total covariance, conditioning on \(\mu\). For distinct subgroups, the first term below is zero, while the second term captures the covariance between the conditional posterior means.

$$ \begin{aligned} \operatorname{Cov}(\theta_i,\theta_j\mid y) &=E\left\{\operatorname{Cov}(\theta_i,\theta_j\mid\mu,y)\mid y\right\} +\operatorname{Cov}\left\{E(\theta_i\mid\mu,y),E(\theta_j\mid\mu,y)\mid y\right\}\\ &=0+\operatorname{Cov}(A_i y_i+C_i\mu,\ A_j y_j+C_j\mu\mid y)\\ &=C_iC_jV_\mu,\qquad i\ne j. \end{aligned} $$

The subgroup observations are fixed when calculating this posterior covariance, so only the shared \(\mu\) varies in the conditional means. The coefficients \(C_i\) and \(C_j\) quantify how much the respective subgroup effects respond to uncertainty in that shared mean. Under the stated model they are positive, as is \(V_\mu\), so the covariance is positive.

Theorem: Under the stated known-variance normal-normal model, the posterior covariance between two distinct subgroup effects is \(C_iC_jV_\mu\). The covariance is induced by uncertainty in the shared population mean; it is not the conditional covariance given that mean.

Worked Calculations

Worked Example: Two Subgroups With Different Precision

Suppose two hypothetical subgroups have observed effect estimates \(y_1=5\) and \(y_2=1\), in the same clinical effect units. Let \(v_1=4\), \(v_2=9\), \(\tau^2=4\), and \(\mu\sim N(0,100)\). These assumed variances are known for this calculation.

The marginal variances for the subgroup observations given \(\mu\) are \(\tau^2+v_1=8\) and \(\tau^2+v_2=13\). Therefore,

$$ V_\mu=\left(\frac{1}{100}+\frac{1}{8}+\frac{1}{13}\right)^{-1} =\left(\frac{551}{2600}\right)^{-1} =\frac{2600}{551}\approx4.7187. $$

The posterior mean of the shared mean is

$$ M=V_\mu\left(\frac{0}{100}+\frac{5}{8}+\frac{1}{13}\right) =\frac{2600}{551}\left(\frac{73}{104}\right) =\frac{1825}{551}\approx3.3122. $$

The coefficients on \(\mu\) in the subgroup conditional means are \(C_1=4/(4+4)=1/2\) and \(C_2=9/(4+9)=9/13\). Hence the cross-subgroup posterior covariance is

$$ \operatorname{Cov}(\theta_1,\theta_2\mid y) =\frac{1}{2}\frac{9}{13}\frac{2600}{551} =\frac{11700}{7163} \approx1.6334 $$

in squared effect units. For context, the marginal posterior means are \(A_1y_1+C_1M=0.5(5)+0.5(3.3122)\approx4.156\) and \(A_2y_2+C_2M=(4/13)(1)+(9/13)(3.3122)\approx2.601\). These are distinct subgroup effects, not a single pooled effect.

Worked Example: Turning Covariance Into Correlation

Using the same hypothetical model and data, calculate the marginal posterior variances of the two subgroup effects and their posterior correlation. The conditional variance of \(\theta_j\) given \(\mu,y_j\) is \(r_j=\tau^2v_j/(\tau^2+v_j)\). The law of total variance adds the variance of the conditional mean:

$$ \operatorname{Var}(\theta_j\mid y)=r_j+C_j^2V_\mu. $$

For subgroup 1, \(r_1=(4)(4)/8=2\) and \(C_1=1/2\). Thus

$$ \operatorname{Var}(\theta_1\mid y)=2+\left(\frac{1}{2}\right)^2(4.7187) \approx3.1797. $$

For subgroup 2, \(r_2=(4)(9)/13=36/13\) and \(C_2=9/13\), giving

$$ \operatorname{Var}(\theta_2\mid y)=\frac{36}{13}+\left(\frac{9}{13}\right)^2(4.7187) \approx5.0309. $$

Correlation is covariance divided by the product of posterior standard deviations:

$$ \operatorname{Corr}(\theta_1,\theta_2\mid y) =\frac{1.6334}{\sqrt{(3.1797)(5.0309)}} \approx0.4084. $$

The posterior correlation is about 0.408, a dimensionless measure of positive linear association between the two uncertain effects. The covariance, by contrast, is expressed in squared effect units. Neither quantity says that a one-unit change in one subgroup causes a change in the other.

Worked Example: Additional Information About the Shared Mean

Keep the two original subgroups, but suppose a third hypothetical subgroup is also observed, with \(v_3=1\) and the same \(\tau^2=4\). The third estimate's value changes the posterior mean \(M\), but with the variances fixed it is the added precision that changes \(V_\mu\). Its contribution to the precision for \(\mu\) is \(1/(\tau^2+v_3)=1/5\).

$$ V_\mu^{\text{new}} =\left(\frac{551}{2600}+\frac{1}{5}\right)^{-1} =\left(\frac{1071}{2600}\right)^{-1} =\frac{2600}{1071} \approx2.4276. $$

The coefficients \(C_1=1/2\) and \(C_2=9/13\) for the original two subgroups have not changed. Their posterior covariance after including the third subgroup is therefore

$$ \operatorname{Cov}(\theta_1,\theta_2\mid y_1,y_2,y_3) =\frac{1}{2}\frac{9}{13}\frac{2600}{1071} =\frac{100}{119} \approx0.8403. $$

In this fixed-variance example, the third subgroup supplies information about the common mean, reducing its posterior variance and consequently reducing the covariance between the first two effects. This is a property of the assumed shared-mean model, not proof that the three subgroups have identical treatment effects.

Reading the Result and Checking the Model

The formula \(C_iC_jV_\mu\) helps separate three sources of the covariance's magnitude: how uncertain the common mean remains, and how strongly each subgroup effect responds to it. If the shared mean were known exactly, \(V_\mu=0\), and distinct subgroup effects would have zero posterior covariance under this model. If the mean is uncertain but an effect has little dependence on it, its \(C_j\) is small and its contribution to cross-subgroup covariance is correspondingly limited.

Useful checks include the following:

  • Check the conditioning. Conditional independence given \(\mu\) does not imply marginal posterior independence after \(\mu\) is integrated out.
  • Check the coefficient. The coefficient of \(\mu\) is \(C_j=v_j/(\tau^2+v_j)\), not \(A_j=\tau^2/(\tau^2+v_j)\). The latter multiplies the observed estimate.
  • Check the units. \(V_\mu\) and the covariance have squared effect units; \(C_i\) and \(C_j\) are dimensionless.
  • Check the bounds on correlation. A calculated correlation must lie between \(-1\) and \(1\). A value outside that range signals an arithmetic or variance calculation error.
  • Check the model assumptions. Unexpected negative dependence or a large mismatch between model-based dependence and clinical knowledge may indicate that the shared-mean structure is inadequate or that important subgroup differences are not represented.

A common mistake is to substitute the posterior mean \(M\) for \(\mu\) and conclude that the subgroup effects have zero covariance because they are independent conditional on that fixed value. That calculation describes a conditional posterior with \(\mu\) held fixed, not the marginal posterior. The correction is to integrate over posterior uncertainty in \(\mu\), using the law of total covariance; in this model that adds \(C_iC_jV_\mu\).

Comparison and Limitations

The result applies to the specified normal-normal hierarchy. It should not be transferred unchanged to models with non-normal outcomes, correlated sampling errors, or additional shared parameters. If \(\tau^2\) is itself uncertain, conditioning on it and then integrating it out can add further dependence; the simple expression derived here assumes \(\tau^2\) is fixed and known.

ApproachRelation between distinct subgroup effectsWhat it represents
Shared uncertain \(\mu\), as derived herePositive marginal posterior covariance \(C_iC_jV_\mu\)Partial pooling with posterior uncertainty in the common mean retained
Shared \(\mu\) fixed at a known valueZero covariance under the conditional independence assumptionsDependence through uncertainty in the mean has been removed
No pooling with independent subgroup priorsZero covariance if no other shared parameters link the subgroupsEach subgroup is analyzed without a shared population distribution
Complete poolingEffects are constrained to be the same parameterA different model and estimand, not merely a covariance adjustment

Partial pooling can be useful when subgroup effects are plausibly related but not identical. The covariance quantifies one consequence of that structure, but it does not settle whether exchangeability is scientifically appropriate. In particular, a positive covariance is not evidence that treatment effects are causally linked across subgroups. Its meaning depends on the trial design, the effect scale, and the plausibility of the shared-mean assumptions.

Key takeaway: In the known-variance normal-normal hierarchy, distinct subgroup effects are conditionally independent given the shared mean, but their marginal posterior covariance is \(C_iC_jV_\mu\). Retaining uncertainty in the shared mean is essential to the calculation.

Check Your Understanding

Use the model and assumptions stated above. Solutions follow the questions so that each calculation can be checked.

  1. In a two-subgroup model, \(C_1=0.4\), \(C_2=0.7\), and \(V_\mu=2\). Find the posterior covariance and state its units relative to the effect scale.
  2. Why can the subgroup effects have nonzero posterior covariance even though they are independent conditional on \(\mu\)?
  3. If \(\mu\) is known exactly and the conditional independence assumptions hold, what is the covariance between distinct subgroup effects?
  4. In the first worked example, what role does the third subgroup play in changing the covariance of the first two effects?

Solutions. (1) The covariance is \(C_1C_2V_\mu=(0.4)(0.7)(2)=0.56\), in squared effect units. (2) Integrating over uncertain \(\mu\) makes the conditional posterior means move together; the covariance of those means is \(C_1C_2V_\mu\). (3) It is zero, since \(V_\mu=0\) and the conditional covariance is zero. (4) Its observed value affects the posterior mean, while its known sampling and hierarchy variances add \(1/5\) to the precision for \(\mu\); this lowers \(V_\mu\) from \(2600/551\) to \(2600/1071\), reducing the covariance of the first two effects to \(100/119\approx0.8403\).

Clinical Biostats