Tutorials › Regression Analysis (Undergraduate) › Contrasts Between Predicted Profiles

Simple Slopes and Marginal Effects · Tutorial 374 of 991

Contrasts Between Predicted Profiles

Compare two predictor profiles by calculating their fitted-mean difference and tracing that contrast to the coefficients in the regression model.

Intermediate 10 min read

What You'll Learn

  • Define a contrast as the difference between fitted means for two specified predictor profiles.
  • Calculate a contrast from profile predictions or directly from model terms.
  • Identify when predictor terms cancel and when interaction terms contribute.
  • Interpret the sign, size, and units of a fitted-mean difference.
  • Distinguish a point contrast from a claim about statistical uncertainty or causation.

Why Compare Two Predictor Profiles?

A fitted value describes the model's predicted mean outcome at one specified combination of predictors. Often the useful question is comparative: how far apart are the fitted means for two profiles? For example, a model might predict outcomes for two treatment groups at different doses, or compare two people with different values of several predictors. The difference between those predictions is a contrast.

The key is to compare the profiles term by term. A predictor that has the same value in both profiles may cancel from the difference, while an interaction can contribute even when its component predictors appear separately in the model. Calculating the contrast directly makes those contributions explicit.

Definition and Model Setup

Suppose a regression model specifies the conditional mean of an outcome \(Y\) using predictors \(x\) and \(z\), including their interaction:

$$ E(Y\mid x,z)=\beta_0+\beta_1x+\beta_2z+\beta_3xz. $$

The model says how the mean outcome varies with the included predictor terms. In a fitted model, the estimated coefficients are written \(\hat{\beta}_0,\hat{\beta}_1,\hat{\beta}_2,\hat{\beta}_3\), and the fitted mean at profile \((x,z)\) is

$$ \hat{Y}(x,z)=\hat{\beta}_0+\hat{\beta}_1x+\hat{\beta}_2z+\hat{\beta}_3xz. $$
Definition: A contrast between two predictor profiles is the difference between their fitted means. For profiles \(A\) and \(B\), using the convention \(B-A\), it is \(\hat{Y}_B-\hat{Y}_A\). The contrast is measured in the units of the outcome.

For point predictions and their difference, the essential requirement is that the fitted mean model be specified and estimated. A standard regression interpretation treats the conditional mean as the modeled expression and assumes errors have mean zero conditional on the predictors. Independence and other assumptions can matter for estimation and uncertainty, but they are not extra arithmetic steps in subtracting two fitted values. The profiles should also be meaningful for the question; predictions far outside the observed predictor ranges may rely on unsupported extrapolation.

Deriving the Contrast Formula

Write the two profiles as \(A=(x_A,z_A)\) and \(B=(x_B,z_B)\). Subtract the fitted mean at \(A\) from the fitted mean at \(B\):

$$ \begin{aligned} \hat{Y}_B-\hat{Y}_A &=(\hat{\beta}_0+\hat{\beta}_1x_B+\hat{\beta}_2z_B+\hat{\beta}_3x_Bz_B)\\ &\quad-(\hat{\beta}_0+\hat{\beta}_1x_A+\hat{\beta}_2z_A+\hat{\beta}_3x_Az_A)\\ &=\hat{\beta}_1(x_B-x_A)+\hat{\beta}_2(z_B-z_A) +\hat{\beta}_3(x_Bz_B-x_Az_A). \end{aligned} $$

The intercept disappears because it is the same in both fitted means. Each remaining coefficient is multiplied by the change in its model term between profiles. In particular, the interaction term contributes according to the difference between the products \(x_Bz_B\) and \(x_Az_A\), not merely according to the change in \(x\) or in \(z\).

This expression also gives a reliable procedure for models with more terms: write the fitted mean at each profile, subtract, and collect the terms. The contrast can be calculated either by subtracting two fitted values or by calculating each coefficient's contribution directly. The two methods must agree.

Worked Example: Changing a Continuous Predictor at a Fixed Moderator Value

Suppose a hypothetical fitted model, with outcome measured in score points, is

$$ \hat{Y}(x,z)=20+1.5x+2z-0.4xz. $$

Compare profile \(A=(2,1)\) with profile \(B=(5,1)\). The value of \(z\) is held fixed at 1, while \(x\) increases by 3.

First calculate each fitted mean:

$$ \begin{aligned} \hat{Y}_A&=20+1.5(2)+2(1)-0.4(2)(1)=24.2,\\ \hat{Y}_B&=20+1.5(5)+2(1)-0.4(5)(1)=27.5. \end{aligned} $$

Thus, using \(B-A\), the contrast is \(27.5-24.2=3.3\) score points. Directly, the \(z\) contribution cancels, while the \(x\) and interaction contributions are

$$ 1.5(5-2)-0.4(5\cdot1-2\cdot1)=4.5-1.2=3.3. $$

For these two profiles, the model's fitted mean at \(x=5\) is 3.3 score points higher than at \(x=2\). This is a comparison of fitted means, not evidence by itself that changing \(x\) would cause an individual's score to change.

Categorical Predictors and Interaction Terms

A categorical predictor with two levels is commonly represented by an indicator: \(G=0\) for one reference group and \(G=1\) for the other. For a model with a continuous predictor \(x\) and a group-by-\(x\) interaction,

$$ \hat{Y}(x,G)=\hat{\beta}_0+\hat{\beta}_1x+\hat{\beta}_2G+\hat{\beta}_3xG, $$

a profile contrast includes changes in \(x\), \(G\), and the product \(xG\). The coefficient \(\hat{\beta}_2\) contributes through the group change; the interaction coefficient \(\hat{\beta}_3\) contributes through the change in the product. A group change at \(x=0\) and a group change at another \(x\) need not have the same fitted-mean difference.

Worked Example: Comparing Groups at Different Predictor Values

Consider the hypothetical fitted model

$$ \hat{Y}(x,G)=50+4x-6G+2xG, $$

where \(Y\) is measured in outcome units, \(x\) is a dose in dose units, and \(G=0\) denotes the reference group while \(G=1\) denotes the comparison group. Compare reference-group profile \(A=(x=3,G=0)\) with comparison-group profile \(B=(x=5,G=1)\).

The fitted means are

$$ \begin{aligned} \hat{Y}_A&=50+4(3)-6(0)+2(3)(0)=62,\\ \hat{Y}_B&=50+4(5)-6(1)+2(5)(1)=74. \end{aligned} $$

Therefore \(B-A=74-62=12\) outcome units. To see the coefficient contributions, the dose term changes by 2, the group indicator by 1, and the interaction product from \(3(0)=0\) to \(5(1)=5\):

$$ 4(5-3)-6(1-0)+2(5-0)=8-6+10=12. $$

All three non-intercept terms contribute. The result compares profiles that differ in both dose and group, so it should not be described as a group difference at a single common dose.

Terms Can Cancel or Combine

A contrast need not involve every coefficient in a model. If a predictor has the same value at both profiles, its main-effect contribution cancels. But an interaction involving that predictor may still change if another component changes. Conversely, a term can cancel because its full model value is identical at both profiles, even when the underlying profiles differ.

For example, with two indicator variables \(A\) and \(B\), the model may include \(A\), \(B\), and \(AB\). Comparing profiles \((A=0,B=1)\) and \((A=1,B=0)\), both have \(AB=0\). The interaction contribution is therefore zero in this particular contrast, although the two profiles have different categories.

Worked Example: Contrasting Two Levels of Different Factors

Suppose a hypothetical fitted model for an outcome in minutes is

$$ \hat{Y}(A,B)=30+5A-3B+4AB, $$

where \(A\) and \(B\) are indicators coded 0 or 1. Compare profile \(A_1=(A=0,B=1)\) with profile \(B_1=(A=1,B=0)\). The fitted means are

$$ \begin{aligned} \hat{Y}_{A_1}&=30+5(0)-3(1)+4(0)(1)=27,\\ \hat{Y}_{B_1}&=30+5(1)-3(0)+4(1)(0)=35. \end{aligned} $$

Using \(B_1-A_1\), the contrast is \(35-27=8\) minutes. The coefficient calculation confirms this:

$$ 5(1-0)-3(0-1)+4(1\cdot0-0\cdot1)=5+3+0=8. $$

The intercept cancels, and the interaction contributes zero because the product is zero at both profiles. The contrast comes from the two main effects, with the \(B\) term contributing positively to \(B_1-A_1\) because \(B\) decreases from 1 to 0.

Interpreting a Contrast Carefully

A complete interpretation names the direction of subtraction, the profiles being compared, and the outcome units. If \(B-A\) is positive, the fitted mean at \(B\) is higher than the fitted mean at \(A\); if negative, it is lower. Reversing the order changes only the sign: \(A-B=-(B-A)\). It does not change the size of the difference.

A contrast is a point estimate derived from the fitted coefficients. It does not communicate how uncertain that estimate is. A standard error or confidence interval is needed to describe sampling uncertainty, topics addressed separately. Nor does a contrast alone establish a causal effect: that interpretation requires an appropriate study design and assumptions beyond the fitted regression equation.

Key takeaway: To identify which coefficients contribute, calculate the change in every model term between the two profiles. Multiply each change by its estimated coefficient, sum the contributions, and state the result in outcome units with the subtraction direction made clear.

Common Mistakes

  • Comparing only the main-effect predictors. In an interaction model, the product term can change between profiles and contribute to the contrast. Calculate the change in the interaction term itself.
  • Assuming every listed coefficient contributes. A coefficient contributes zero when its associated model term has the same value at both profiles. Check the term values before interpreting the coefficient.
  • Using the wrong subtraction order. A positive \(B-A\) means the fitted mean at \(B\) exceeds that at \(A\). State the order explicitly.
  • Calling a fitted contrast a causal effect. The contrast compares model-based fitted means. Without a design and assumptions that support causal interpretation, describe it as an association or prediction.
  • Reporting a point contrast as if it expressed precision. The calculated difference has no uncertainty measure attached. Do not infer statistical significance from its size alone.

Check Your Understanding

For each question, identify the relevant profile changes and explain how they enter the contrast.

  1. In a model with terms \(x\), \(z\), and \(xz\), what part of the contrast cancels if \(z\) is identical at profiles \(A\) and \(B\)? Does the interaction necessarily cancel?
  2. For the fitted model \(\hat{Y}=10+2x-3G+xG\), calculate \(B-A\) for \(A=(x=1,G=0)\) and \(B=(x=4,G=1)\). Show both fitted means and the coefficient contributions.
  3. Why can a group contrast from a group-by-dose model depend on the dose value at which the profiles are compared?
  4. If a contrast is calculated as \(A-B=-5\) outcome units, what is \(B-A\), and how should its direction be interpreted?
  5. What additional information is needed before judging how precisely a fitted contrast has been estimated?