Tutorials › Regression Analysis (Undergraduate) › Comparing Adjusted Group Means With Contrasts

Tests and Linear Contrasts · Tutorial 235 of 991

Comparing Adjusted Group Means With Contrasts

Use linear contrasts to compare regression-adjusted group means at a clearly specified covariate profile, with correct tests and contextual interpretations.

Intermediate 10 min read

What You'll Learn

  • Define an adjusted group mean at a specified covariate profile.
  • Express a comparison of adjusted means as a linear contrast of regression coefficients.
  • Calculate and interpret a contrast test statistic and two-sided p-value.
  • Account for covariance when finding the standard error of a comparison.
  • Explain what reference profile an adjusted-mean comparison applies to.
  • Check the model conditions that support regression-based inference.

Why Compare Adjusted Group Means?

Suppose two clinics serve patients with different age distributions. A comparison of their raw average recovery times combines differences between clinics with differences in the ages of the patients they serve. A regression model can compare the clinics at a common age, separating the modeled group difference from the modeled association between age and recovery time. That comparison is an adjusted group-mean comparison.

“Adjusted” does not mean that a group’s observed data have been changed. It means that the fitted model is used to predict the response for each group at the same specified values of the covariates. Those values define the reference profile for the comparison. The profile matters: a comparison at age 50 is not automatically a comparison averaged over every age in a population.

Model and Definition

For clarity, begin with two groups, A and B, and one quantitative covariate \(x\). Use the indicator \(I(B_i)\), which equals 1 for an observation in group B and 0 for an observation in group A. A common-slope regression model is

$$ Y_i=\beta_0+\beta_1 I(B_i)+\beta_2(x_i-x_0)+\varepsilon_i. $$

Here \(x_0\) is the chosen reference value of the covariate. Centering \(x\) at \(x_0\) makes the intercept the fitted mean for group A at that value. For multiple covariates, the same idea applies: specify a reference profile, and use the fitted model to predict each group’s mean response at that profile.

Definition: An adjusted group mean at a specified covariate profile is the model’s fitted mean response for that group when the covariates are set to the stated reference values. A contrast of adjusted means is a specified linear combination of those fitted means. For two groups, the usual difference is the adjusted mean for one group minus the adjusted mean for the other.

In the two-group model above, the adjusted mean for A at \(x=x_0\) is \(\beta_0\), and the adjusted mean for B at \(x=x_0\) is \(\beta_0+\beta_1\). Thus the B-minus-A contrast is

$$ (\beta_0+\beta_1)-\beta_0=\beta_1. $$

The intercept cancels, leaving the group coefficient. With three or more groups, treatment-indicator coefficients are differences from a reference group; comparing two nonreference groups generally requires subtracting their coefficients. Whatever the parameterization, the requested comparison should be stated in terms of the adjusted means and their subtraction order.

Conditions for Inference

A contrast test relies on the regression model being suitable for the data. In the common-slope model, the expected response is linear in the quantitative covariates, and the group differences are constant across covariate values. The errors have mean zero given the predictors, are independent, and have a common variance. For exact small-sample t inference, the errors are also normally distributed. The design matrix must have enough independent information to estimate the coefficients, and the covariate profile should be supported by the observed data rather than being an extreme extrapolation.

A group-by-covariate interaction would allow the group difference to vary with the covariate. If that pattern is needed, a single common adjusted difference is not an adequate summary; the comparison must be stated at a particular covariate value using a model that includes the interaction. In the examples below, the stated diagnostic summaries and study designs are hypothetical and are taken to support the common-slope model.

Testing a Difference Between Adjusted Means

Write the desired adjusted-mean difference as a contrast \(L\) of the regression coefficients. Its estimate is the same linear combination of the estimated coefficients. The standard error must reflect the uncertainty in all coefficients involved, including their covariances. Under the regression assumptions, a contrast can be tested by comparing its estimate with its null value using a t statistic and the model’s residual degrees of freedom.

Theorem: For a specified contrast \(L=c^\mathsf{T}\beta\), test \(H_0:L=L_0\) with
$$ t=\frac{\widehat{L}-L_0}{SE(\widehat{L})}. $$

Under \(H_0\) and the regression error assumptions, this statistic has a t distribution with the fitted model’s residual degrees of freedom. For a two-sided test of equal adjusted means, \(L_0=0\) and \(H_a:L\ne 0\). The p-value is the probability, assuming \(H_0\) and the model, of obtaining a t statistic at least as far from zero as the observed statistic. A confidence interval for the difference is the estimate plus or minus the appropriate t critical value times its standard error.

Worked Comparisons

Worked Example: Comparing Two Clinics at a Common Age

Imagine a hypothetical sample of patients from clinics A and B. Let \(Y\) be recovery time in days and \(x\) be age in years. The fitted model is

$$ \widehat{Y}=18.0+3.6I(B)-0.20(x-50). $$

The estimated difference in adjusted mean recovery time, B minus A, for patients aged 50 is \(\widehat{L}=3.6\) days. Suppose its standard error is 1.20 days and the regression has 42 residual degrees of freedom. The diagnostic summary indicates no substantial curvature or unequal residual spread, residuals are reasonably consistent with normality, and patients were sampled independently. Both clinics include patients near age 50, so the reference value is not an extrapolation.

We test \(H_0:L=0\) against \(H_a:L\ne0\). The statistic is

$$ t=\frac{3.6-0}{1.20}=3.00. $$

For a two-sided test with 42 degrees of freedom, the p-value is approximately 0.004526. Since this is below a 0.05 significance level, the data provide evidence that the clinics’ mean recovery times differ at age 50, under the fitted model. The estimated difference is positive: the model estimates B’s mean to be 3.6 days longer than A’s at age 50. This is an adjusted association, not evidence that receiving care at clinic B causes longer recovery.

Worked Example: Comparing a Third Group With the Reference Group

Consider a hypothetical study of an outcome measured in points for groups A, B, and C, with \(x\) representing a covariate. At the reference value \(x_0=40\), the fitted model has an adjusted mean of 70.0 points for A, a C-minus-A coefficient estimate of 2.2 points, and a common covariate slope. Thus the adjusted mean for C is \(70.0+2.2=72.2\) points. Suppose the standard error of the C-minus-A contrast is \(\sqrt{2.10}\) points, and the model has 42 residual degrees of freedom.

The contrast is \(L=\mu_C(40)-\mu_A(40)\), where each mean refers to the model’s expected outcome at \(x=40\). Test \(H_0:L=0\) against \(H_a:L\ne0\). The standard error and test statistic are

$$ SE(\widehat{L})=\sqrt{2.10}=1.449,\qquad t=\frac{2.2}{\sqrt{2.10}}=1.518. $$

With 42 degrees of freedom, the two-sided p-value is approximately 0.1365. At the 0.05 level, the result does not provide sufficient evidence of a difference between the adjusted means for groups C and A at \(x=40\). It does not establish that the means are equal: the estimate is 2.2 points, but its uncertainty is substantial. Suppose the hypothetical residual checks support the linear common-slope model and both groups have observations around \(x=40\); those conditions make this particular adjusted comparison interpretable.

Worked Example: Comparing Two Nonreference Groups

In a hypothetical three-group model, A is the reference group and \(x\) is centered at a specified value \(x_0\). The estimated adjusted means at \(x_0\) are 50.0 points for A, 54.0 for B, and 51.0 for C. Equivalently, the estimated B-minus-A coefficient is 4.0 points and the C-minus-A coefficient is 1.0 point. We want B minus C, not either group’s difference from A. The contrast estimate is

$$ \widehat{L}=(\widehat{\mu}_B-\widehat{\mu}_A)-(\widehat{\mu}_C-\widehat{\mu}_A) =4.0-1.0=3.0\text{ points}. $$

Suppose the estimated variances of these two coefficients are 2.25 and 1.44 points squared, and their estimated covariance is 0.60 points squared. For a difference, the variance is the first variance plus the second variance minus twice their covariance:

$$ \widehat{\operatorname{Var}}(\widehat{L}) =2.25+1.44-2(0.60)=2.49, \qquad SE(\widehat{L})=\sqrt{2.49}=1.578\text{ points}. $$

With 42 residual degrees of freedom, a 95% confidence interval uses \(t^*=2.018\). Its margin of error is \(2.018(1.578)=3.184\) points, giving

$$ 3.0\pm3.184=(-0.184,\ 6.184)\text{ points}. $$

At this specified reference profile, the interval ranges from B being 0.184 points lower than C to B being 6.184 points higher. Because zero is included, these data do not show a statistically significant B-versus-C difference at the two-sided 0.05 level. The hypothetical design and residual checks are assumed to support the stated regression conditions, and the reference profile is within the covariate range for all three groups.

Why the Reference Profile and Covariance Matter

An adjusted mean is not a raw group average, and it is not automatically an average over a particular population. It is a model-based prediction at the covariate values used to define it. For instance, an age-50 comparison describes expected outcomes at age 50; it does not by itself describe the average difference among all patients of every age. When several covariates are included, identify their reference values as well. A profile that is far outside the observed data can produce a precise-looking but poorly supported extrapolation.

Covariance matters because estimated regression coefficients are generally not independent. For two coefficient estimates \(\widehat{\beta}_1\) and \(\widehat{\beta}_2\), the variance of their difference is

$$ \operatorname{Var}(\widehat{\beta}_1-\widehat{\beta}_2) =\operatorname{Var}(\widehat{\beta}_1) +\operatorname{Var}(\widehat{\beta}_2) -2\operatorname{Cov}(\widehat{\beta}_1,\widehat{\beta}_2). $$

This follows from expanding the variance of a linear combination: the variance terms contribute positively, while the cross-product contributes twice the covariance with a negative sign. In practice, use the contrast standard error from the fitted model or compute it using the full estimated covariance matrix. Adding the two standard errors, or treating the coefficients as independent without justification, generally gives the wrong uncertainty.

Common Pitfall and a Short Workflow

A common mistake is to interpret a group indicator coefficient as an adjusted difference without checking what it compares. Under reference-group coding with a common slope, a group coefficient is that group’s adjusted difference from the reference group at the same covariate profile. It is not necessarily the comparison of interest when both groups are nonreference groups. State the target contrast first, then construct the coefficient combination that represents it.

1
Name the comparison and profile.
Specify the two groups, the subtraction order, the outcome units, and the covariate values defining the reference profile.
2
Write the contrast.
Express the desired adjusted-mean difference as a linear combination of the fitted regression coefficients.
3
Check the model and its support.
Confirm that the common-slope specification and regression error assumptions are reasonable, and that the profile is represented in the observed data.
4
Calculate and interpret.
Use the contrast estimate and its standard error for the test or interval, then report the conclusion in context without implying causation.
Key takeaway: A regression contrast compares model-predicted group means at a common, explicitly stated covariate profile. The contrast defines the question; its standard error must account for coefficient covariance; and the result applies to the specified profile and model.

Check Your Understanding

Answer each question by identifying the comparison and stating its interpretation in context.

  1. A model predicts mean blood pressure for two treatment groups at age 60. What additional information should be reported to make the adjusted-mean comparison clear?
  2. In a three-group model with A as the reference, how would you write the adjusted B-minus-C difference using the B-minus-A and C-minus-A coefficients?
  3. Why is the variance of the difference between two coefficient estimates not generally the sum of their variances alone?
  4. A 95% confidence interval for a B-minus-A adjusted difference includes zero. What does that say about a two-sided test at the 0.05 level, and what does it not establish?
  5. Why should a covariate profile used for adjusted predictions be checked against the range of observed covariate values?