Tutorials › Bayesian Clinical Trials › Mean Differences With a Shared Unknown Variance

Posterior Inference for Trial Endpoints · Tutorial 16 of 696

Mean Differences With a Shared Unknown Variance

Learn how a common unknown variance leads to a Student’s t posterior for a two-arm mean difference, and how to use it for trial inference.

Beginner 12 min read

What You'll Learn

  • State the shared-variance normal model and its conjugate prior.
  • Derive the posterior hyperparameter updates from two-arm trial summaries.
  • Calculate a marginal Student’s t posterior for the treatment-control mean difference.
  • Construct and interpret a posterior credible interval in outcome units.
  • Check the common-variance assumption and assess sensitivity to prior choices.

Why a Shared Unknown Variance Matters

A continuous endpoint in a two-arm trial is often summarized by the difference between the treatment-arm and control-arm means. When the arms are modeled as having a shared but unknown outcome variance, uncertainty about that variance carries through to uncertainty about the mean difference. Integrating over the variance gives a Student’s t posterior rather than a normal posterior.

This tutorial derives that result for a specified conjugate prior. The model is useful when a common variance is scientifically reasonable and a t-shaped posterior is a natural consequence of estimating it. The result depends on the variance being shared; it is not the same model as assigning each arm its own unrelated variance.

Definition: Let \(y_{0i}\) and \(y_{1i}\) be continuous outcomes for independent participants in control arm 0 and treatment arm 1. The shared-variance normal model is $$ y_{ji}\mid \mu_j,\sigma^2 \sim N(\mu_j,\sigma^2), \qquad j\in\{0,1\}, $$ with observations conditionally independent given the arm means and common variance. The target contrast is \(\Delta=\mu_1-\mu_0\), in the original outcome units.

Model, Prior, and Posterior Updates

For each arm, write \(n_j\), \(\bar{x}_j\), and \(s_j\) for the sample size, sample mean, and sample standard deviation. A conjugate prior places conditionally independent normal distributions on the arm means and an inverse-gamma distribution on the shared variance:

$$ \mu_j\mid\sigma^2 \sim N\left(m_{j0},\frac{\sigma^2}{\kappa_{j0}}\right),\qquad \sigma^2\sim \operatorname{InvGamma}(a_0,b_0). $$

The hyperparameters satisfy \(\kappa_{j0}>0\), \(a_0>0\), and \(b_0>0\). Here the inverse-gamma density is proportional to \((\sigma^2)^{-a_0-1}\exp(-b_0/\sigma^2)\); thus \(b_0\) is the scale parameter in the inverse-gamma density. The prior mean \(m_{j0}\) is measured in endpoint units, \(\kappa_{j0}\) controls the prior precision for that arm mean relative to \(\sigma^2\), and \(a_0,b_0\) govern prior information about the common variance. The prior for the two means is independent conditional on \(\sigma^2\), but the means are not marginally independent because they share that variance.

For \(N=n_0+n_1\), the posterior is another normal-inverse-gamma distribution. Its parameters are

$$ \kappa_{jn}=\kappa_{j0}+n_j,\qquad m_{jn}=\frac{\kappa_{j0}m_{j0}+n_j\bar{x}_j}{\kappa_{j0}+n_j}, $$ $$ a_n=a_0+\frac{N}{2},\qquad b_n=b_0+\frac{1}{2}\sum_{j=0}^1 \left[(n_j-1)s_j^2+ \frac{\kappa_{j0}n_j}{\kappa_{j0}+n_j}(\bar{x}_j-m_{j0})^2\right]. $$

The variance update uses the within-arm sums of squares and the extra terms measuring how far each observed arm mean lies from its prior mean. The posterior mean \(m_{jn}\) is a precision-weighted compromise between prior and data; it is not generally equal to the sample mean.

Why the Difference Has a Student’s t Posterior

Conditional on \(\sigma^2\) and the data, the arm means have independent normal posteriors with means \(m_{jn}\) and variances \(\sigma^2/\kappa_{jn}\). Therefore their difference, conditional on \(\sigma^2\), is normal:

$$ \Delta\mid\sigma^2,\text{data}\sim N\left(m_{1n}-m_{0n},\ \sigma^2\left(\frac{1}{\kappa_{1n}}+\frac{1}{\kappa_{0n}}\right)\right). $$

The posterior variance of \(\sigma^2\) follows an inverse-gamma distribution with parameters \(a_n,b_n\). Integrating this normal distribution over that inverse-gamma uncertainty produces a Student’s t distribution. In the location-scale parameterization, its degrees of freedom are \(2a_n\), its location is \(m_{1n}-m_{0n}\), and its scale is the quantity below:

Theorem: Under the stated model and prior, $$ \Delta\mid\text{data}\sim t_{2a_n}\left(m_{1n}-m_{0n},\ \sqrt{\frac{b_n}{a_n}\left(\frac{1}{\kappa_{1n}}+\frac{1}{\kappa_{0n}}\right)}\right). $$ The second argument is the Student’s t scale, not its standard deviation. A central \(100(1-\alpha)\%\) equal-tailed posterior credible interval is the location plus or minus the \(1-\alpha/2\) quantile of \(t_{2a_n}\) times this scale.

The shared variance affects both arms’ uncertainty together. The contrast’s conditional variance adds the two arm-specific mean variances, while the common posterior variance is integrated out only once. This is why replacing the shared-variance model with separate variance priors changes the calculation and generally does not yield this same t distribution.

Worked Trial Analysis

Worked Example: Updating the Common Variance Model

Suppose a hypothetical trial measures symptom score in points. In the control arm, \(n_0=12\), \(\bar{x}_0=10.0\) points, and \(s_0=2.0\) points. In the treatment arm, \(n_1=11\), \(\bar{x}_1=8.5\) points, and \(s_1=2.2\) points. Use \(m_{00}=m_{10}=10\) points, \(\kappa_{00}=\kappa_{10}=0.1\), \(a_0=2\), and \(b_0=4\) points squared. These are hypothetical summary data, and the calculation assumes independent normal observations and a common variance.

First update the mean parameters:

$$ \kappa_{0n}=0.1+12=12.1,\qquad m_{0n}=\frac{0.1(10)+12(10)}{12.1}=10.000\text{ points}, $$ $$ \kappa_{1n}=0.1+11=11.1,\qquad m_{1n}=\frac{0.1(10)+11(8.5)}{11.1} =\frac{94.5}{11.1}=8.5135\text{ points}. $$

The control mean equals its prior mean, so its update is unchanged. For treatment, the prior contribution is small but shifts the posterior mean slightly toward 10 points. The posterior location for treatment minus control is \(8.5135-10.000=-1.4865\) points.

Now update \(a_n\) and \(b_n\). The within-arm sums of squares are \(11(2.0^2)=44.0\) points squared and \(10(2.2^2)=48.4\) points squared. The control mean has no prior-discrepancy contribution. The treatment contribution is

$$ \frac{0.1(11)}{0.1+11}(8.5-10)^2 =\frac{1.1}{11.1}(2.25)=0.2230\text{ points}^2. $$

Thus the variance parameters are

$$ a_n=2+\frac{12+11}{2}=13.5,\qquad b_n=4+\frac{44.0+48.4+0.2230}{2} =50.3115\text{ points}^2. $$

The posterior degrees of freedom are \(2a_n=27\). The t scale for the contrast is

$$ \sqrt{\frac{50.3115}{13.5}\left(\frac{1}{12.1}+\frac{1}{11.1}\right)} =\sqrt{3.7268(0.172735)} =0.8023\text{ points}. $$

The posterior distribution is therefore a \(t_{27}\) distribution with location \(-1.4865\) points and scale \(0.8023\) points. Each update used the arm sample sizes, means, and standard deviations under the specified common-variance normal model; the sample standard deviations differ, but that alone does not establish that the population variances differ.

Worked Example: Calculating a 95% Credible Interval

Continue with the hypothetical trial above. The \(0.975\) quantile of a \(t_{27}\) distribution is approximately \(2.052\). The equal-tailed 95% posterior credible interval for the treatment-minus-control mean difference is

$$ -1.4865\pm 2.052(0.8023) =-1.4865\pm1.6463 =[-3.133,\ 0.160]\text{ points}. $$

Under the model and prior, the posterior probability that the treatment-minus-control mean difference lies between \(-3.133\) and \(0.160\) points is 95%. The interval includes zero, so it does not place the entire 95% posterior interval on one side of no mean difference. This interval is about uncertainty in the parameter \(\Delta\); it is not a statement that 95% of individual patients’ outcomes fall within those limits.

Prior Sensitivity and Model Checks

Worked Example: A More Concentrated Prior on the Arm Means

To see how the prior affects the same hypothetical trial, retain \(m_{00}=m_{10}=10\) points, \(a_0=2\), and \(b_0=4\) points squared, but set \(\kappa_{00}=\kappa_{10}=2\). This assigns more prior precision to both arm means than the \(\kappa_{j0}=0.1\) choice.

For treatment, the updated mean is \((2(10)+11(8.5))/(2+11)=113.5/13=8.7308\) points; the control posterior mean remains 10.000 points. The posterior location is consequently \(-1.2692\) points. The updated variance parameters are

$$ a_n=13.5,\qquad b_n=4+\frac{1}{2}\left[44.0+48.4+ \frac{2(11)}{13}(8.5-10)^2\right] =52.1038\text{ points}^2. $$

Here the treatment mean’s discrepancy contribution is \((22/13)(2.25)=3.8077\) points squared. The posterior scale is

$$ \sqrt{\frac{52.1038}{13.5}\left(\frac{1}{14}+\frac{1}{13}\right)} =0.7567\text{ points}. $$

The more concentrated prior pulls the treatment location closer to 10 points, changing the estimated contrast from \(-1.4865\) to \(-1.2692\) points. This is not a data error: it is a consequence of changing the prior. Reporting the prior and checking whether reasonable alternative prior choices materially alter the posterior are important parts of the analysis.

The assumptions should be considered before interpreting the interval. Participants’ outcomes are modeled as independent within and across arms, conditional on their arm means and variance. The normal model should be a reasonable description of the endpoint distribution, particularly when sample sizes are small or there are influential outliers. The model also assumes the same population variance in both arms. Differences between the observed \(s_0\) and \(s_1\) are possible even when population variances are equal, but substantial differences or strong subject-matter reasons to expect unequal variability call this assumption into question.

Useful checks include examining arm-specific distributions and outliers, comparing the observed spreads, and repeating the analysis under reasonable prior choices. If the outcome is strongly skewed or has extreme observations, a normal likelihood may be inadequate. If a common variance is implausible, the shared-variance posterior should not be treated as a harmless convenience; an alternative model is needed. These diagnostics assess assumptions and sensitivity, but no check can prove that a model is correct.

How This Approach Differs From Alternatives

ApproachVariance treatmentImplication for the mean difference
Known-variance normal modelArm variances are fixed as known.The contrast posterior is normal conditional on those values; uncertainty in variance is not propagated.
Shared unknown-variance model hereOne unknown variance is common to both arms.The conjugate marginal contrast posterior is Student’s t, with uncertainty in the shared variance included.
Separate-variance modelEach arm may have its own variance.The posterior calculation changes because the arms no longer share one variance parameter.

The known-variance approach can be appropriate when variances genuinely are known from external information, but treating estimates as known understates uncertainty when that is not justified. The shared-variance model is more parsimonious than a separate-variance model, but that parsimony is purchased by the equality-of-variances assumption. The choice should reflect the endpoint and trial design, not merely which calculation is simplest.

Common Pitfalls and Practical Limits

  • Reversing the contrast. This tutorial defines \(\Delta=\mu_1-\mu_0\). A negative value means a lower treatment-arm mean, which may or may not be favorable depending on the endpoint.
  • Calling the t scale a posterior standard deviation. The scale parameter in the location-scale t distribution is not its standard deviation. For \(2a_n>2\), the t standard deviation also includes the factor \(\sqrt{2a_n/(2a_n-2)}\).
  • Ignoring prior influence. The posterior location and scale depend on prior hyperparameters as well as the data. State the prior and assess sensitivity when the data are limited.
  • Assuming unequal sample standard deviations invalidate the model automatically. Sample standard deviations vary by chance; investigate whether the shared population variance is defensible rather than deciding from sample values alone.
  • Interpreting a credible interval as a frequentist confidence interval or as a probability statement about observed outcomes. Its probability interpretation is posterior and conditional on the model and prior, and it concerns \(\Delta\).

The method also does not correct a poor endpoint definition, informative missingness, or departures from the assumed sampling model. Those issues require modeling choices beyond the conjugate calculation. The earlier material on posterior inference for continuous outcome variance provides background on variance uncertainty; here that uncertainty is propagated specifically into a two-arm mean contrast.

Key takeaway: With independent normal outcomes sharing an unknown variance and the stated normal-inverse-gamma prior, update the two arm means and common variance, then obtain a Student’s t posterior for treatment minus control. The resulting interval is interpretable only alongside the common-variance, normality, independence, and prior assumptions.

Check Your Understanding

Answer each question, then compare with the solutions below.

  1. In this tutorial, what does a negative \(\Delta\) mean?
  2. Why does the marginal posterior for \(\Delta\) have heavier tails than a normal posterior with a fixed variance?
  3. For a trial with \(n_0=10\) and \(n_1=14\), what are the posterior degrees of freedom when \(a_0=1.5\)?
  4. What does a 95% posterior credible interval mean under this model?
  5. Name two assumptions that should be examined before using the shared-variance result.

Solutions. (1) Since \(\Delta=\mu_1-\mu_0\), a negative value means the treatment-arm population mean is below the control-arm population mean. Whether that is beneficial depends on the endpoint. (2) The variance is unknown, and integrating over its posterior uncertainty yields a Student’s t distribution rather than a normal distribution with variance treated as fixed. (3) \(a_n=1.5+(10+14)/2=13.5\), so the degrees of freedom are \(2a_n=27\). (4) Conditional on the model and prior, the posterior probability that \(\Delta\) lies between the interval endpoints is 95%. (5) Appropriate answers include conditional independence of observations, approximate normality within arms, and a common population variance across arms.

Clinical Biostats