Why a Group Difference Can Depend on a Predictor
Suppose a hypothetical study models the time needed to complete a service task using a measure of task complexity. The task time may increase with complexity, but it may also differ between two service channels. If the channels have different increases in time as complexity rises, a model that gives them only different starting values is insufficient. The model needs a way for the slope to vary by group.
A product of a group indicator and the continuous predictor provides that flexibility. The resulting model has a separate intercept and slope for each of two groups, while expressing both groups’ coefficients in a single regression equation.
The response mean is modeled as a linear function of the predictors. For interpreting the fitted mean, assume \(E[\varepsilon_i\mid x_i,G_i]=0\). For the usual exact small-sample \(t\)-tests and confidence intervals for regression coefficients, also assume independent errors with common variance and normally distributed errors. If these inferential assumptions are not suitable, the coefficient interpretation still follows from the model, but the usual standard errors and tests may not be reliable.
Reading the Two Group-Specific Lines
Substitute each possible indicator value into the model. When \(G=0\), the terms involving \(G\) vanish. When \(G=1\), both the group indicator and its product with \(x\) remain.
Thus, the reference group’s intercept is \(\beta_0\) and its slope is \(\beta_1\). The comparison group’s intercept is \(\beta_0+\beta_2\), and its slope is \(\beta_1+\beta_3\). In particular, \(\beta_2\) is the difference in fitted means between groups at \(x=0\), not necessarily the difference at every value of \(x\).
These interpretations are conditional on the model’s coding and units. Reversing which group is coded 0 changes the coefficient interpretations, although it does not change the fitted means. Changing the unit of \(x\) also changes the numerical slope and interaction coefficients. Therefore, name the reference group and state the predictor’s units before interpreting coefficients.
Worked Example: Comparing Two Service Channels
In a hypothetical study, task time \(Y\) is measured in minutes and complexity \(x\) is a score from 0 to 10. Channel A is the reference group (\(G=0\)); Channel B has \(G=1\). The fitted model is \(\widehat{Y}=12+2x+5G-0.5xG\). Find each channel’s intercept and slope, predict task time for each channel at \(x=8\), and state the fitted difference. Name the method and a mistake to avoid.
Method. Substitute \(G=0\) and \(G=1\) into the fitted equation, then calculate both fitted means at the requested \(x\).
For Channel A, \(G=0\), so the fitted line is \(\widehat{Y}=12+2x\). Its intercept is 12 minutes and its slope is 2 minutes per complexity-score point. At \(x=8\), its prediction is \(12+2(8)=12+16=28\) minutes.
For Channel B, \(G=1\), so \(\widehat{Y}=12+2x+5-0.5x=17+1.5x\). Its intercept is 17 minutes and its slope is 1.5 minutes per complexity-score point. At \(x=8\), its prediction is \(17+1.5(8)=17+12=29\) minutes.
The fitted difference, Channel B minus Channel A, is \(29-28=1\) minute. Directly from the coefficients, the difference at \(x=8\) is \(5-0.5(8)=5-4=1\) minute, which checks the predictions.
Mistake to avoid: Reporting \(\beta_2=5\) as the group difference at \(x=8\) ignores the interaction. The correction is to use \(\beta_2+\beta_3x=5-0.5(8)=1\) minute.
Why the Product Term Gives Different Slopes
The interaction arises directly from the algebra of the model. The group indicator by itself adds a group-specific constant. Multiplying that indicator by \(x\) makes the additional group contribution increase or decrease with \(x\).
Set \(G=1\) in \(\beta_0+\beta_1x+\beta_2G+\beta_3xG\), giving \(\beta_0+\beta_1x+\beta_2+\beta_3x\).
The expression becomes \((\beta_0+\beta_2)+(\beta_1+\beta_3)x\). Its slope is therefore \(\beta_1+\beta_3\).
Subtract \(\beta_0+\beta_1x\), leaving \(\beta_2+\beta_3x\). This proves that the group difference depends on \(x\) when the interaction coefficient is nonzero.
The calculation also shows why interpreting \(\beta_2\) in isolation can be misleading. It compares the fitted groups at the particular value \(x=0\). If zero is outside the observed predictor range or has no useful meaning, that coefficient may not describe a practically relevant comparison. The model’s group difference at a relevant value \(x=c\) is instead \(\beta_2+\beta_3c\).
Estimating and Testing a Group Difference at a Chosen Value
The same algebra applies to estimated coefficients. At \(x=c\), the estimated difference in fitted means is \(\widehat{\beta}_2+c\widehat{\beta}_3\). This is a linear combination of estimated coefficients. Its estimated variance is \(\operatorname{Var}(\widehat{\beta}_2)+c^2\operatorname{Var}(\widehat{\beta}_3)+2c\operatorname{Cov}(\widehat{\beta}_2,\widehat{\beta}_3)\). The covariance term matters because the coefficient estimates generally need not be independent.
To test whether the groups have equal fitted means specifically at \(x=c\), test \(H_0:\beta_2+c\beta_3=0\). The test statistic is the estimated contrast divided by its standard error. This is a different question from testing whether the slopes are equal, which corresponds to \(H_0:\beta_3=0\). Equal slopes do not imply equal group means; they imply parallel fitted lines.
Worked Example: Testing the Difference at a Specified Complexity
A hypothetical analysis compares two channels using complexity score \(x\). Channel A is coded \(G=0\), Channel B is coded \(G=1\), and task time is measured in minutes. The estimates are \(\widehat{\beta}_2=8\) and \(\widehat{\beta}_3=-1.5\). At \(x=6\), suppose \(\operatorname{Var}(\widehat{\beta}_2)=1\), \(\operatorname{Var}(\widehat{\beta}_3)=0.04\), and \(\operatorname{Cov}(\widehat{\beta}_2,\widehat{\beta}_3)=0.05\). With 24 residual degrees of freedom, estimate the group difference and test equality at the 5% two-sided level. Use \(t_{0.975,24}=2.064\).
Method. Form the contrast \(\widehat{\beta}_2+6\widehat{\beta}_3\), calculate its variance including the covariance term, and compare the resulting \(t\)-statistic with the stated critical value.
The estimated difference, Channel B minus Channel A, is \(8+6(-1.5)=8-9=-1\) minute. Thus, at complexity 6, Channel B’s fitted mean is 1 minute lower.
The contrast variance is \(1+6^2(0.04)+2(6)(0.05)=1+36(0.04)+0.6=1+1.44+0.6=3.04\). Its standard error is \(\sqrt{3.04}\approx1.744\) minutes. The test statistic is \(t=-1/1.744\approx-0.573\).
Since \(|-0.573|=0.573<2.064\), fail to reject equality of fitted means at \(x=6\) at the 5% level. This does not establish that the means are exactly equal; it means the estimated contrast is not statistically significant by this test. The calculation avoids the mistake of testing only \(\beta_2=0\), which would address the group difference at \(x=0\), not at \(x=6\).
Checking the Model’s Implications
An interaction model should be interpreted as two fitted lines, not as a single slope plus an unexplained adjustment. A useful check is to compute the predictions from each group-specific line and verify that their difference agrees with \(\widehat{\beta}_2+\widehat{\beta}_3x\). The check catches sign errors and mistakes in indicator coding.
| Quantity | Reference group (\(G=0\)) | Comparison group (\(G=1\)) |
|---|---|---|
| Intercept | \(\beta_0\) | \(\beta_0+\beta_2\) |
| Slope with respect to \(x\) | \(\beta_1\) | \(\beta_1+\beta_3\) |
| Difference, comparison minus reference, at \(x\) | — | \(\beta_2+\beta_3x\) |
If a categorical predictor has more than two groups, choose one group as the reference and use an indicator for each remaining group. Each group then has its own intercept adjustment and, when the relevant product terms are included, its own slope adjustment. The meaning of a coefficient depends on the reference category and on which interaction terms are in the model.
Worked Example: Finding Where the Fitted Group Difference Changes Sign
A hypothetical study models annual training cost \(Y\), in hundreds of dollars, against training hours \(x\). Program A is the reference group, and Program B has indicator \(G=1\). The fitted model is \(\widehat{Y}=18+2.4x+7G-0.6xG\). Find the two slopes, determine where the fitted group means are equal, and compare the predictions at \(x=10\) and \(x=15\), values within the study’s stated range of 0 to 20 hours.
Method. Substitute each group indicator to obtain its fitted line. Set the difference expression to zero to find the equality point, then verify with predictions on either side.
For Program A, \(G=0\), so \(\widehat{Y}=18+2.4x\), with slope 2.4 hundreds of dollars per hour. For Program B, \(G=1\), so \(\widehat{Y}=18+2.4x+7-0.6x=25+1.8x\), with slope 1.8 hundreds of dollars per hour.
The Program B minus Program A difference at \(x\) is \(7-0.6x\). Equality occurs when \(7-0.6x=0\), so \(0.6x=7\) and \(x=7/0.6\approx11.67\) hours.
At \(x=10\), Program A predicts \(18+2.4(10)=18+24=42\), or $4,200. Program B predicts \(25+1.8(10)=25+18=43\), or $4,300. The difference is \(43-42=1\) hundred dollars, consistent with \(7-0.6(10)=1\).
At \(x=15\), Program A predicts \(18+2.4(15)=18+36=54\), or $5,400. Program B predicts \(25+1.8(15)=25+27=52\), or $5,200. The difference is \(52-54=-2\) hundreds of dollars, consistent with \(7-0.6(15)=-2\). The fitted comparison changes sign after about 11.67 hours. The coefficients describe fitted means, not a guarantee about every individual observation.
Common Interpretation Traps
- Calling \(\beta_2\) the group difference everywhere. With an interaction, the difference at \(x\) is \(\beta_2+\beta_3x\); \(\beta_2\) alone is the difference at \(x=0\).
- Calling \(\beta_3\) the comparison group’s slope. The comparison group’s slope is \(\beta_1+\beta_3\). The interaction coefficient is the difference between the two slopes.
- Ignoring the coding. State which group is \(G=0\) and which is \(G=1\). The comparison direction in a difference must match that coding.
- Confusing equal slopes with equal fitted means. A zero interaction means parallel lines, not necessarily the same line; the group intercept adjustment may still be nonzero.
Check Your Understanding
For each problem, use the stated indicator coding and report the requested fitted quantities.
- A hypothetical model is \(\widehat{Y}=12+2x+5G-0.5xG\), with Group A coded 0 and Group B coded 1. Find both predictions at \(x=8\) and the Group B minus Group A difference. (Answer: A = 28, B = 29, difference = 1.)
- A hypothetical model is \(\widehat{Y}=20+4x-6G+2xG\), with \(G=0\) as the reference group. Give both slopes and the group difference at \(x=10\). (Answer: reference slope = 4, comparison slope = 6, comparison-minus-reference difference = 14.)
- For \(\widehat{Y}=15+3x+9G-1.2xG\), find the predictor value where the two fitted group means are equal. (Answer: \(x=7.5\).)
- At \(x=5\), estimates are \(\widehat{\beta}_2=9\) and \(\widehat{\beta}_3=-1.2\). Find the estimated comparison-minus-reference difference. (Answer: 3.)
- A hypothetical model is \(\widehat{Y}=30+1.5x+4G+0.5xG\), with \(G=0\) as the reference group. Find both predictions at \(x=12\), both slopes, and the group difference at that value. (Answer: reference prediction = 48, comparison prediction = 58, reference slope = 1.5, comparison slope = 2, difference = 10.)