Tutorials › Causal Inference › Confidence Intervals for Subgroup Contrasts

Effect Modification and Subgroup Effects · Tutorial 865 of 972

Confidence Intervals for Subgroup Contrasts

Construct and interpret subgroup-effect intervals and a confidence interval for their contrast, accounting for dependence between estimates.

Advanced 10 min read

What You'll Learn

  • Define subgroup-specific treatment effects and the contrast that measures their difference
  • Derive the variance of a difference between two correlated estimates
  • Construct Wald confidence intervals using an estimated covariance
  • Recognize when shared data or fitted models induce dependence between subgroup estimates
  • Explain why overlap or non-overlap of separate confidence intervals does not test heterogeneity

Why a Contrast Needs Its Own Interval

A subgroup analysis may report a treatment effect for each subgroup, but the scientific question is often whether those effects differ. That is a question about a contrast between estimates, not about whether one subgroup-specific confidence interval excludes zero while another includes it. The uncertainty in the contrast depends on how the estimates vary together.

Let \(G\) denote a pretreatment subgroup, with two categories labelled 0 and 1, and let \(Y(1)\) and \(Y(0)\) denote the potential outcomes under treatment and control. For a specified target population within subgroup \(g\), define the average treatment effect as \(\tau_g=E[Y(1)-Y(0)\mid G=g]\). The contrast considered here is \(\Delta=\tau_1-\tau_0\). It measures the difference in treatment effects on the chosen outcome scale and in the chosen target populations.

A confidence interval for \(\Delta\) concerns sampling uncertainty in an estimate of this contrast. Its causal interpretation also depends on identifying the subgroup effects: for example, a randomized study with consistent treatment assignment and adequate treatment representation in both subgroups can identify them under the trial’s target-population definition. In an observational study, identification additionally requires suitable control of confounding. An interval cannot correct bias from a failure of causal identification.

Definition: Let \(\hat{\tau}_1\) and \(\hat{\tau}_0\) estimate the subgroup-specific effects \(\tau_1\) and \(\tau_0\). The estimated contrast is \(\hat{\Delta}=\hat{\tau}_1-\hat{\tau}_0\). A confidence interval for the contrast uses the sampling variance of this difference, including the covariance between the two estimates.

Variance and Confidence Interval for a Difference

Suppose the two estimates are approximately jointly normally distributed around their target values, with estimated standard errors \(SE_1\) and \(SE_0\), and estimated covariance \(\widehat{\operatorname{Cov}}(\hat{\tau}_1,\hat{\tau}_0)\). The variance of a difference is the sum of the two variances minus twice their covariance:

$$ \widehat{\operatorname{Var}}(\hat{\Delta}) = SE_1^2+SE_0^2 -2\widehat{\operatorname{Cov}}(\hat{\tau}_1,\hat{\tau}_0). $$

The minus sign matters. If estimates tend to move together across repeated samples, their positive covariance reduces the variability of their difference. If they tend to move in opposite directions, negative covariance increases the variability of the difference. Treating the estimates as independent when they are not can therefore make the interval too narrow or too wide.

For a large-sample Wald interval with approximately normal sampling distribution, a two-sided 95% confidence interval is:

$$ \hat{\Delta} \ \pm\ 1.96 \sqrt{ SE_1^2+SE_0^2 -2\widehat{\operatorname{Cov}}(\hat{\tau}_1,\hat{\tau}_0) }. $$

The multiplier 1.96 is the 97.5th percentile of the standard normal distribution. Under the approximation, intervals constructed this way cover the target contrast in about 95% of repeated samples. The interval is about \(\Delta\), not about either subgroup effect alone.

Why the Covariance Term Appears

The variance formula follows directly from the variance of a linear combination. Write the centered estimates as \(\hat{\tau}_1-\tau_1\) and \(\hat{\tau}_0-\tau_0\). Since \(\hat{\Delta}-\Delta=(\hat{\tau}_1-\tau_1)-(\hat{\tau}_0-\tau_0)\), expanding the squared centered difference gives:

$$ \begin{aligned} \operatorname{Var}(\hat{\Delta}) &=\operatorname{Var}\big((\hat{\tau}_1-\tau_1)-(\hat{\tau}_0-\tau_0)\big)\\ &=\operatorname{Var}(\hat{\tau}_1)+\operatorname{Var}(\hat{\tau}_0) -2\operatorname{Cov}(\hat{\tau}_1,\hat{\tau}_0). \end{aligned} $$

The final term comes from the two cross-products in the square; omitting it assumes the covariance is zero. That assumption is justified only when the estimates are uncorrelated under the sampling procedure, not merely because they refer to different subgroups.

Estimates can be correlated when they use shared observations, common fitted model parameters, or the same estimated standardization weights. A covariance estimate can be obtained from a joint sandwich variance calculation or from paired resampling: in each bootstrap replicate, resample the data according to the study design, re-estimate both subgroup effects, and retain the pair. The covariance across these paired estimates estimates their joint sampling covariance. Resampling the two effects independently would discard the dependence being estimated.

Worked Example: A Positive Covariance Narrows the Contrast Interval

In a hypothetical randomized study, the estimated treatment effect on a symptom score is 0.12 points in subgroup 1 and 0.04 points in subgroup 0. Both estimates come from a joint standardization procedure. Suppose their standard errors are 0.045 and 0.035 points, and their estimated covariance is 0.000700 points squared. Construct a 95% confidence interval for the difference in effects.

The estimated contrast, in symptom-score points, is:

$$ \hat{\Delta}=0.12-0.04=0.0800. $$

Using the covariance in the variance formula:

$$ \widehat{\operatorname{Var}}(\hat{\Delta}) =(0.045)^2+(0.035)^2-2(0.000700) =0.002025+0.001225-0.001400 =0.001850. $$

Thus \(SE(\hat{\Delta})=\sqrt{0.001850}=0.04301\) points. The 95% interval is:

$$ 0.0800\pm1.96(0.04301) =0.0800\pm0.08430 =(-0.00430,\ 0.1643). $$

The estimated effect is 0.0800 points larger in subgroup 1, but this interval includes zero. Under the large-sample approximation, the data are compatible with a contrast ranging from subgroup 1’s effect being 0.00430 points smaller to being 0.1643 points larger. This interval does not establish that the subgroup effects differ.

For comparison, the separate subgroup intervals are \(0.12\pm1.96(0.045)=(0.0318,0.2082)\) and \(0.04\pm1.96(0.035)=(-0.0286,0.1086)\), in points. Those intervals describe uncertainty in each effect; neither their overlap nor their endpoints substitute for the interval calculated directly for the contrast.

Covariance Depends on the Estimation Procedure

There is no universal rule that subgroup estimates are independent. If they are estimated from disjoint observations using separate procedures, independence may be reasonable under an appropriate sampling model. But that is a property to establish from the design and estimation procedure. A shared control group, common regression coefficients, or weights estimated from the full sample can link the estimates even when subgroup membership itself is disjoint.

For a fitted model, covariance can also be obtained by writing the contrast as a linear combination of model coefficients. If the estimated coefficient vector is \(\hat{\boldsymbol{\beta}}\), its estimated covariance matrix is \(\widehat{\mathbf V}\), and the contrast is \(\mathbf c^\mathsf{T}\hat{\boldsymbol{\beta}}\), then its estimated variance is \(\mathbf c^\mathsf{T}\widehat{\mathbf V}\mathbf c\). This is the same variance rule, expressed for multiple coefficients. It is particularly useful when subgroup effects are standardized predictions rather than single model coefficients.

Worked Example: Negative Covariance Widens the Contrast Interval

In a second hypothetical study, the estimated treatment effects are 0.24 and 0.09 units in subgroups 1 and 0. Their standard errors are 0.040 and 0.030 units, and their estimated covariance is \(-0.000400\) units squared. Calculate the interval for the difference.

The estimated contrast is \(0.24-0.09=0.150\) units. Its estimated variance and standard error are:

$$ \begin{aligned} \widehat{\operatorname{Var}}(\hat{\Delta}) &=(0.040)^2+(0.030)^2-2(-0.000400)\\ &=0.001600+0.000900+0.000800\\ &=0.003300,\\ SE(\hat{\Delta})&=\sqrt{0.003300}=0.05745\text{ units}. \end{aligned} $$

The 95% interval is:

$$ 0.150\pm1.96(0.05745) =0.150\pm0.1126 =(0.0374,\ 0.2626)\text{ units}. $$

Because the covariance is negative, subtracting twice the covariance adds 0.000800 to the variance. Ignoring that dependence would instead give a standard error of \(\sqrt{0.001600+0.000900}=0.05000\) units and a narrower interval. The covariance-adjusted interval is the one supported by the stated joint sampling distribution. It excludes zero under the Wald approximation, indicating evidence of a positive difference on this outcome scale; it does not by itself show that the difference is clinically important.

Reading a Regression Interaction as a Contrast

With a binary subgroup and an additive linear model, a treatment-by-subgroup coefficient can equal the difference between subgroup treatment effects. Consider a model for a continuous outcome:

$$ E(Y\mid A,G)=\beta_0+\beta_A A+\beta_G G+\beta_{AG}AG, $$

where \(A\) is coded 0 for control and 1 for treatment, and \(G\) is coded 0 or 1. Under this model, the fitted treatment effect for subgroup 0 is \(\beta_A\). For subgroup 1 it is \(\beta_A+\beta_{AG}\). Therefore their difference is \(\beta_{AG}\). The identity concerns the model’s additive outcome scale; interpreting it causally requires the relevant design or confounding-control assumptions, as well as a model appropriate for the target effect.

Worked Example: A Model-Based Interaction Interval

In a hypothetical randomized trial, a linear model for pain score (points) gives \(\hat{\beta}_A=0.050\) with standard error 0.040, and \(\hat{\beta}_{AG}=0.110\) with standard error 0.060. Suppose the estimated covariance between these coefficients is \(-0.00120\) points squared. Find the subgroup effects and a 95% interval for their difference.

For subgroup 0, the estimated treatment effect is \(\hat{\tau}_0=\hat{\beta}_A=0.050\) points. For subgroup 1, it is \(\hat{\tau}_1=\hat{\beta}_A+\hat{\beta}_{AG}=0.050+0.110=0.160\) points. The estimated difference is \(0.160-0.050=0.110\) points, equal to the interaction coefficient.

The variance of the subgroup 1 estimate includes the covariance between its two coefficients:

$$ \widehat{\operatorname{Var}}(\hat{\tau}_1) =(0.040)^2+(0.060)^2+2(-0.00120) =0.00160+0.00360-0.00240 =0.00280. $$

Thus \(SE(\hat{\tau}_1)=\sqrt{0.00280}=0.05292\) points, and its 95% interval is \(0.160\pm1.96(0.05292)=(0.0563,0.2637)\) points. The subgroup 0 interval is \(0.050\pm1.96(0.040)=(-0.0284,0.1284)\) points.

For the difference, the fitted-model identity makes the calculation direct: \(\hat{\Delta}=\hat{\beta}_{AG}=0.110\), with standard error 0.060 points. The 95% interval is:

$$ 0.110\pm1.96(0.060) =0.110\pm0.1176 =(-0.00760,\ 0.2276)\text{ points}. $$

Although the subgroup 1 estimate is larger, the contrast interval includes zero. The model-based result therefore does not provide clear evidence of a nonzero additive difference at the two-sided 5% level. The separate subgroup intervals answer different questions and cannot replace this contrast interval.

Common Mistakes and Interpretation

A frequent error is to reason that a difference must be present because one subgroup’s interval excludes zero while the other subgroup’s interval includes zero. That compares two decisions about zero, not the subgroup effects with each other. Conversely, overlapping subgroup intervals do not demonstrate that the effects are equal. The appropriate uncertainty calculation is a confidence interval, or a test, for \(\Delta\) itself, using the joint covariance.

Another error is to set the covariance to zero just because the effects refer to different subgroups. Before doing so, check whether the estimates share observations, fitted parameters, standardization weights, or other estimated quantities. If the covariance is unavailable, the contrast interval cannot be fully justified by pretending it is zero; obtain a joint variance estimate appropriate to the estimator and study design.

Finally, a confidence interval describes uncertainty under the stated sampling and estimation assumptions. A narrow interval does not rule out bias from confounding, selection, or a mismatched target population, and a wide interval does not establish that effects are equal. Keep the scale and units explicit: a contrast of risk differences is measured in risk-difference units, while a contrast of mean differences is measured in outcome units.

Key takeaway: To quantify subgroup heterogeneity, estimate the contrast between subgroup effects and calculate its uncertainty from the joint covariance of those estimates. Separate confidence intervals are not a substitute for a confidence interval for the contrast.

Check Your Understanding

Answer each question using the variance formula and the interpretation of a contrast interval.

  1. Why does the variance of \(\hat{\tau}_1-\hat{\tau}_0\) contain minus twice the covariance?
  2. If two subgroup estimates have positive covariance, what happens to the variance of their difference compared with the calculation that sets covariance to zero?
  3. Two subgroup-specific confidence intervals overlap. What, if anything, does that establish about the confidence interval for the difference between effects?
  4. What features of an analysis could make estimates for distinct subgroups correlated?
  5. In the stated linear model, which coefficient represents the difference between the two subgroup treatment effects, and on what outcome scale?
Clinical Biostats