Tutorials › Regression Analysis (Undergraduate) › Comparing Two Profiles With Predicted Mean Differences

Predictions for Conditional Means · Tutorial 703 of 991

Comparing Two Profiles With Predicted Mean Differences

Calculate and interpret the difference between fitted means for two specified profiles, while keeping track of which predictors change and the units of the outcome.

Beginner 9 min read

What You'll Learn

  • Define an ordered contrast between two fitted conditional means
  • Subtract fitted means to compare two specified predictor profiles
  • Identify which predictors change and which are held fixed
  • Interpret a fitted-mean difference in the outcome’s units
  • Evaluate the full model when curvature or interactions are present
  • Distinguish a difference in fitted means from an individual outcome difference

Why Compare Two Predictor Profiles?

A regression model can provide a fitted mean outcome for any specified set of predictor values within the model’s scope. Often the useful question is not just what each fitted mean is, but how far apart the two are. For example, one might compare the fitted mean test score for students with different study times while holding their other listed characteristics fixed.

A comparison is meaningful only when the two profiles are clearly stated and the subtraction order is fixed. The result is a difference between two fitted conditional means, expressed in the outcome’s units. It is not the difference between two particular individuals’ observed outcomes, and by itself it does not establish that changing a predictor causes an outcome to change.

Definition: For two specified predictor profiles \(A\) and \(B\), the fitted-mean contrast in the order \(B-A\) is the fitted conditional mean at profile \(B\) minus the fitted conditional mean at profile \(A\): $$ \widehat{\Delta}_{B-A}=\hat{m}(B)-\hat{m}(A). $$ A positive contrast means the fitted mean at \(B\) is higher; a negative contrast means it is lower. The contrast has the same units as the outcome.

Model and Conditions for a Meaningful Comparison

Suppose a regression model relates a quantitative outcome \(Y\) to predictors \(X_1,\ldots,X_k\). Its conditional mean at predictor values \(x_1,\ldots,x_k\) is \(E(Y\mid X_1=x_1,\ldots,X_k=x_k)\). The fitted conditional mean, written \(\hat{m}(x_1,\ldots,x_k)\), is the value calculated from the estimated regression equation at those predictor values.

For the examples below, the equations describe fitted means on the original outcome scale. The underlying mean model assumes that the conditional mean is represented by the stated regression equation (or is an adequate approximation to it). To interpret a contrast as relevant to a population, the model must be appropriate for the setting, and the profiles should be meaningful combinations of predictor values supported by the data. If a profile is far outside the observed range, its fitted mean may be an extrapolation and should be treated cautiously.

Calculating the difference between two fitted means is a point calculation. It does not require a normal error distribution or a constant error variance. Those assumptions may matter for other regression procedures, but they are not needed for the subtraction itself. The comparison also does not provide a confidence interval or a test of whether the means differ; uncertainty for differences is a separate question.

How the Contrast Simplifies

In an additive linear model, the fitted mean is a sum of an intercept and predictor contributions. For two quantitative predictors, for example, write

$$ \hat{m}(x_1,x_2)=\hat{\beta}_0+\hat{\beta}_1x_1+\hat{\beta}_2x_2. $$

Let profile \(A\) have predictor values \((x_{1A},x_{2A})\) and profile \(B\) have \((x_{1B},x_{2B})\). Subtracting the first fitted mean from the second gives

$$ \begin{aligned} \widehat{\Delta}_{B-A} &=\left(\hat{\beta}_0+\hat{\beta}_1x_{1B}+\hat{\beta}_2x_{2B}\right) -\left(\hat{\beta}_0+\hat{\beta}_1x_{1A}+\hat{\beta}_2x_{2A}\right)\\ &=\hat{\beta}_1(x_{1B}-x_{1A})+\hat{\beta}_2(x_{2B}-x_{2A}). \end{aligned} $$

The intercept cancels because it appears in both fitted means. A predictor’s contribution also cancels when its value is the same in both profiles. If only \(X_1\) changes, the contrast reduces to \(\hat{\beta}_1(x_{1B}-x_{1A})\). If several predictors change, each contributes according to its coefficient and its change in value. This shortcut relies on an additive model; with curvature or interactions, the full fitted-mean equation must be evaluated at both profiles.

Worked Example: Comparing Two Study-Time Profiles

Assume a hypothetical fitted model for mean quiz score, measured in points, is \(\hat{m}(x)=42+3.6x\), where \(x\) is study time in hours. Compare profiles \(A\), with 2 hours of study, and \(B\), with 5 hours. Assume both values lie within the range of study times represented when fitting this hypothetical model.

Check the comparison. The model specifies a fitted mean score from study time, and both profiles give valid values of that predictor. The outcome is measured in points, so the difference will also be in points.

At profile \(A\): $$ \hat{m}(2)=42+3.6(2)=42+7.2=49.2\text{ points}. $$ At profile \(B\): $$ \hat{m}(5)=42+3.6(5)=42+18=60.0\text{ points}. $$ Thus, in the stated order \(B-A\), $$ \widehat{\Delta}_{B-A}=60.0-49.2=10.8\text{ points}. $$

The model’s fitted mean score at 5 study hours is 10.8 points higher than at 2 study hours. This is a comparison of fitted means, not a claim that every student who studies 5 hours will score 10.8 points more than a particular student who studies 2 hours.

Recognize What Changes Between Profiles

The profile comparison determines what a contrast represents. If the profiles differ in only one predictor, the fitted-mean difference isolates the model’s comparison for that change, with the other specified predictors held fixed. If several predictors differ, the result combines their contributions; it should not be described as the effect of just one of them.

A categorical predictor can be compared in the same way. Its values identify categories rather than numerical distances. In a model coded with an indicator variable, changing the category changes the indicator value. Subtracting fitted means then gives the category comparison at the other predictor values specified in the two profiles. The indicator’s coefficient alone is the comparison only when the model’s other terms do not make that comparison depend on the profile.

Worked Example: Changing a Group While Holding Other Predictors Fixed

Assume a hypothetical fitted model for mean daily output, in units per shift, is \(\hat{m}(a,t,g)=18+1.5a+2.2t-4g\). Here \(a\) is age of equipment in years, \(t\) is operator training in hours, and \(g=1\) denotes Group B while \(g=0\) denotes Group A. Compare two profiles with equipment age 40 years and training of 6 hours: profile \(A\) is in Group A, and profile \(B\) is in Group B. Assume the model and these profiles are appropriate for the hypothetical data.

At profile \(A\), \(g=0\): $$ \hat{m}(40,6,0)=18+1.5(40)+2.2(6)-4(0) =18+60+13.2=91.2\text{ units per shift}. $$ At profile \(B\), \(g=1\): $$ \hat{m}(40,6,1)=18+1.5(40)+2.2(6)-4(1) =18+60+13.2-4=87.2\text{ units per shift}. $$ The ordered contrast is $$ \widehat{\Delta}_{B-A}=87.2-91.2=-4.0\text{ units per shift}. $$

Only group membership changes; equipment age and training are held fixed. The negative sign indicates that the fitted mean for Group B is 4.0 units per shift lower than the fitted mean for Group A at these specified values. In this additive model, the group coefficient is \(-4\), so it gives this same group comparison at every age and training value for which the model is used.

Curvature and Interactions Require Both Evaluations

When a model contains a squared predictor, the fitted-mean change depends on where the comparison starts as well as on how far the predictor changes. When it contains an interaction, the contribution of one predictor can depend on another predictor’s value. In either case, a coefficient by itself may not equal the contrast of interest. The reliable procedure is to substitute each complete profile into every term, calculate both fitted means, and subtract in the chosen order.

Worked Example: Comparing Profiles in a Model With Curvature and Interaction

Assume a hypothetical model for mean response time, in milliseconds, is \(\hat{m}(x,g)=30+4x-0.08x^2+5g+1.2xg\), where \(x\) is a practice measure and \(g=1\) identifies a specified group (with \(g=0\) for the other group). Compare \(A=(x=2,g=1)\) with \(B=(x=6,g=1)\). Thus, only \(x\) changes. Assume both profiles are within the range represented in the hypothetical data.

At profile \(A\): $$ \begin{aligned} \hat{m}(2,1) &=30+4(2)-0.08(2^2)+5(1)+1.2(2)(1)\\ &=30+8-0.32+5+2.4=45.08\text{ milliseconds}. \end{aligned} $$ At profile \(B\): $$ \begin{aligned} \hat{m}(6,1) &=30+4(6)-0.08(6^2)+5(1)+1.2(6)(1)\\ &=30+24-2.88+5+7.2=63.32\text{ milliseconds}. \end{aligned} $$ Therefore, $$ \widehat{\Delta}_{B-A}=63.32-45.08=18.24\text{ milliseconds}. $$

The fitted mean response time at \(x=6\) is 18.24 milliseconds higher than at \(x=2\) for the specified group. Using only the coefficient \(4\) would give \(4(6-2)=16\), which misses the changes in both the squared term and the interaction. The two fitted means incorporate all model terms and give the appropriate contrast.

A Reliable Calculation and Interpretation

For any model, the basic operation is the same. First state the two profiles, including the values of every predictor in the model. Then substitute each profile into the fitted-mean equation and keep enough precision during the calculation. Finally subtract in the declared order and give the result with outcome units and context.

1
Specify profiles \(A\) and \(B\).
List the predictor values at each profile and make explicit which values differ. Define the contrast order as \(B-A\) or \(A-B\).
2
Evaluate the complete fitted-mean model.
Substitute each profile into all applicable terms, including indicator variables, squared terms, and interactions.
3
Subtract and interpret.
Subtract the fitted mean at the second profile in the declared order, report the outcome units, and say which profile has the higher fitted mean.

The difference can be useful because it expresses the model’s comparison on the outcome scale people care about. A contrast of 10 points, 4 units per shift, or 18 milliseconds can be easier to interpret than a set of coefficients considered separately. But the number depends on the model and the profiles chosen. A different starting profile can produce a different contrast in a curved or interactive model.

For models whose equation is written on a transformed outcome scale, a difference on that scale is not automatically an absolute difference in the original outcome units. To report an original-scale difference, compare fitted means after obtaining them on that scale. The distinction is especially important when the outcome has been transformed.

Common Mistakes

  • Reversing the subtraction without changing the interpretation. If the contrast is \(B-A\), calculate the fitted mean at \(B\) minus the fitted mean at \(A\). Reversing the order reverses the sign and the direction described.
  • Attributing a multi-predictor contrast to one predictor. If several values differ, the fitted-mean difference reflects all of those changes under the model. Say which profiles were compared rather than claiming the difference is due to one variable alone.
  • Using a single coefficient when terms interact or curve. A coefficient need not equal the difference between the specified profiles. Evaluate the full equation at each profile.
  • Calling the contrast an individual outcome difference or a causal effect. The calculation compares fitted conditional means. It does not predict the exact difference between two individuals, and a model-based association alone does not show that changing a predictor causes an outcome change.
Key takeaway: A fitted-mean contrast is the difference between two model-based conditional means at explicitly stated profiles. Identify what changes, evaluate the full fitted-mean equation at both profiles, subtract in a clear order, and report the result in outcome units.

Check Your Understanding

Use the stated contrast order in each question.

  1. A fitted mean model is \(\hat{m}(x)=20+2.5x\). Find the contrast \(B-A\) for \(x_A=4\) and \(x_B=7\), and interpret it in outcome units.
  2. In an additive model with predictors \(x\) and \(z\), profiles \(A\) and \(B\) have the same \(z\) value. Which part of the fitted-mean difference involving \(z\) cancels?
  3. In a model containing \(x^2\), why might the fitted-mean difference for increasing \(x\) by 2 depend on the starting value of \(x\)?
  4. Two profiles differ in both training hours and group membership. Is their fitted-mean contrast necessarily a comparison attributable only to group? Explain.
  5. What does a contrast of \(-3.5\) outcome units for \(B-A\) say about the fitted means at profiles \(A\) and \(B\)?