Tutorials › Introduction to Statistics › Group-Specific Slopes With Indicator Interactions

Introduction to Multiple Regression · Tutorial 932 of 996

Group-Specific Slopes With Indicator Interactions

Learn to build and interpret a regression model that allows both the slope and intercept to differ between two groups.

Intermediate 10 min read

What You'll Learn

  • Write a two-group regression model with an indicator and an indicator-by-predictor interaction.
  • Derive the regression line for each group from the model.
  • Interpret the reference-group slope and intercept, and the interaction coefficients.
  • Calculate fitted values and group differences at specified predictor values.
  • Explain how reversing the reference group changes coefficients but not fitted values.

Why Allow Group-Specific Slopes?

A regression model with a quantitative predictor and a group indicator can allow the groups to have different average outcomes. If the model includes only those two terms, it assumes the groups’ regression lines are parallel: the expected outcome changes at the same rate with the predictor in both groups. That assumption may not fit a situation in which the rate of change itself differs by group.

An indicator interaction allows that rate to differ. The interaction is the product of a group indicator and the quantitative predictor. With this term, the model can represent one line for the reference group and another line for the comparison group, with both different slopes and different intercepts.

The Model and Its Group-Specific Lines

Let \(X\) be a quantitative predictor, and let \(G\) indicate group membership, with \(G=0\) for the reference group and \(G=1\) for the comparison group. For an individual \(i\), fit the model

$$ Y_i=\beta_0+\beta_1X_i+\beta_2G_i+\beta_3(X_iG_i)+\varepsilon_i. $$

Here, \(\varepsilon_i\) is the error for individual \(i\). The model describes the conditional mean of \(Y\) given the predictor and group. Substituting each possible indicator value gives the two lines:

$$ \begin{aligned} E(Y\mid X=x,G=0)&=\beta_0+\beta_1x,\\ E(Y\mid X=x,G=1)&=(\beta_0+\beta_2)+(\beta_1+\beta_3)x. \end{aligned} $$

Thus, \(\beta_0\) and \(\beta_1\) are the reference group’s intercept and slope. The comparison group’s intercept is \(\beta_0+\beta_2\), and its slope is \(\beta_1+\beta_3\). The coefficient \(\beta_2\) is the difference in intercepts, while \(\beta_3\) is the difference in slopes, comparison group minus reference group.

Definition: In a two-group regression with an indicator interaction, the group-specific slope is the coefficient of \(X\) after substituting that group’s indicator value. The indicator interaction coefficient is the difference between the groups’ slopes. The group-specific intercept is the model’s expected response at \(X=0\), so its practical interpretation depends on whether \(X=0\) is meaningful and supported by the data.

At a particular predictor value \(x\), the comparison group’s expected response minus the reference group’s expected response is

$$ \big[(\beta_0+\beta_2)+(\beta_1+\beta_3)x\big] -\big[\beta_0+\beta_1x\big] =\beta_2+\beta_3x. $$

Therefore, \(\beta_2\) alone is not generally the difference between the groups at every predictor value. It is the difference at \(X=0\). When slopes differ, the expected group difference changes with \(X\).

Assumptions and What the Model Says

The interaction changes the form of the conditional mean model; it does not remove the assumptions needed to use a regression model. The model assumes that, within each group, the expected response is linear in \(X\). In the usual regression setup, the errors have conditional mean zero, \(E(\varepsilon_i\mid X_i,G_i)=0\), and observations are independent. Standard pooled regression inference also commonly assumes a common error variance across predictor values and groups; exact small-sample inference additionally uses a normal-error assumption. Those inference assumptions should be assessed before drawing inferential conclusions.

The groups need observations at predictor values that make their lines estimable. If a group has no variation in \(X\), its slope cannot be estimated from its own observations. Comparisons between groups at predictor values far outside the observed data range are extrapolations and should be treated cautiously. The model describes conditional means; by itself, it does not establish that group membership or \(X\) causes a change in the response.

The coefficients are commonly estimated by least squares: choose the coefficient values that minimize the sum of squared residuals, where each residual is observed \(Y_i\) minus its fitted value. With the interaction in the model, the fitted values can follow different slopes in the two groups.

Worked Example: Recovering Both Lines From the Interaction Model

Suppose a hypothetical data set records a quantitative predictor \(X\) and response \(Y\) for two groups. The observations are:

Group\(X\)\(Y\)
Reference (\(G=0\))112
Reference (\(G=0\))214
Reference (\(G=0\))316
Comparison (\(G=1\))117
Comparison (\(G=1\))220
Comparison (\(G=1\))323

For each group, the least-squares slope is \(b=\sum (x_i-\bar{x})(y_i-\bar{y})/\sum (x_i-\bar{x})^2\). In the reference group, \(\bar{x}=2\) and \(\bar{y}=14\), so

$$ b_0=\frac{(-1)(-2)+(0)(0)+(1)(2)}{(-1)^2+0^2+1^2} =\frac{4}{2}=2. $$

Its intercept is \(14-(2)(2)=10\), giving the line \(10+2x\). For the comparison group, \(\bar{x}=2\) and \(\bar{y}=20\), and

$$ b_1=\frac{(-1)(-3)+(0)(0)+(1)(3)}{(-1)^2+0^2+1^2} =\frac{6}{2}=3. $$

Its intercept is \(20-(3)(2)=14\), giving the line \(14+3x\). Matching these two lines to the interaction model gives \(\beta_0=10\), \(\beta_1=2\), \(\beta_2=14-10=4\), and \(\beta_3=3-2=1\). The comparison group’s slope is one response unit per \(X\)-unit greater than the reference group’s slope.

Why the Substitution Works

The interaction’s role follows directly from multiplying the indicator by \(X\). When \(G=0\), both terms involving \(G\) are zero, leaving only the reference group’s line. When \(G=1\), the indicator term adds \(\beta_2\) to the intercept, and the product term adds \(\beta_3X\) to the predictor part of the line:

$$ \begin{aligned} G=0:\quad &\beta_0+\beta_1X+\beta_2(0)+\beta_3(X)(0) =\beta_0+\beta_1X,\\ G=1:\quad &\beta_0+\beta_1X+\beta_2(1)+\beta_3(X)(1) =(\beta_0+\beta_2)+(\beta_1+\beta_3)X. \end{aligned} $$

This also explains why omitting the interaction imposes equal slopes: without the \(XG\) term, the coefficient of \(X\) remains \(\beta_1\) for both groups. The indicator alone can shift one line up or down, but cannot change its slope.

Worked Example: Predicting Outcomes and a Group Difference

In a hypothetical analysis of systolic blood pressure, \(Y\) is measured in millimeters of mercury (mmHg), and \(X\) is age centered at 50 years, so \(X=\text{age}-50\). Let \(G=0\) denote Group A and \(G=1\) denote Group B. Suppose the fitted model is

$$ \hat{Y}=128+0.35X-4G+0.12(XG). $$

For Group A, \(G=0\), so its fitted line is \(\hat{Y}=128+0.35X\). For Group B, \(G=1\), so its line is \(\hat{Y}=124+0.47X\). The estimated slope is 0.35 mmHg per year for Group A and 0.47 mmHg per year for Group B. The interaction estimate, \(0.12\), is the difference in slopes: Group B’s fitted slope is 0.12 mmHg per year greater.

At age 60, \(X=60-50=10\). The fitted value for Group A is

$$ \hat{Y}_A=128+0.35(10)=128+3.5=131.5\text{ mmHg}. $$

For Group B, the fitted value is \(124+0.47(10)=124+4.7=128.7\) mmHg. The fitted difference, Group B minus Group A, is \(128.7-131.5=-2.8\) mmHg. The coefficient formula gives the same result: \(\beta_2+\beta_3X=-4+0.12(10)=-2.8\) mmHg. These are model-based associations, not evidence that group membership causes blood pressure to change.

Changing the Reference Group

The choice of reference group determines which line is represented directly by \(\beta_0+\beta_1X\). Reversing the indicator changes the coefficient values and their interpretations, but does not change the two fitted lines or predictions, provided the model is otherwise equivalent.

Worked Example: Reversing the Indicator Coding

Return to the two fitted lines from the first example: Group A has line \(10+2x\), and Group B has line \(14+3x\). With Group A as the reference, the model coefficients are \(\beta_0=10\), \(\beta_1=2\), \(\beta_2=4\), and \(\beta_3=1\).

Now define a new indicator \(G^*=1\) for Group A and \(G^*=0\) for Group B. Group B is now the reference group, so the intercept and slope coefficients become its intercept and slope: \(\beta_0^*=14\) and \(\beta_1^*=3\). Group A’s intercept is four units lower, giving \(\beta_2^*=10-14=-4\), and its slope is one unit lower, giving \(\beta_3^*=2-3=-1\). The recoded model is

$$ \hat{Y}=14+3x-4G^*-1(xG^*). $$

At \(x=2\), Group B’s fitted value is \(14+3(2)=20\). Group A’s is \(14+3(2)-4-1(2)=14\). These match the original lines: \(10+2(2)=14\) for Group A and \(14+3(2)=20\) for Group B. The coding changed which group’s line is represented by the baseline coefficients, not the predictions.

Centering the Predictor and Avoiding Misinterpretation

If \(X=0\) is not a meaningful value, the intercept difference \(\beta_2\) may have little direct practical meaning. Centering \(X\) at a useful value can make that coefficient more interpretable. For example, in the blood pressure example, \(X=0\) represents age 50, so \(\beta_2=-4\) describes the fitted Group B minus Group A difference at age 50. Centering changes the intercept-related coefficients, but not the two group-specific slopes or their difference.

A frequent mistake is to interpret \(\beta_2\) as the group difference at all values of \(X\), or to interpret \(\beta_3\) as the outcome difference between groups. The correction is to calculate the group difference at the specified predictor value using \(\beta_2+\beta_3x\); \(\beta_3\) is a difference in slopes, measured in response units per predictor unit. Another mistake is to say the comparison group’s slope is \(\beta_3\). Its slope is \(\beta_1+\beta_3\); \(\beta_3\) alone is the amount by which that slope differs from the reference group’s slope.

This model is useful whenever a quantitative predictor may relate to the response differently across two groups. Reporting both fitted lines, with units for slopes and a clear reference-group definition, makes the interaction interpretable. A coefficient table alone can obscure the fact that its terms combine to form group-specific intercepts, slopes, and fitted differences.

Check Your Understanding

Use the model structure and interpretations in this tutorial to answer the following questions.

  1. For \(Y=\beta_0+\beta_1X+\beta_2G+\beta_3XG+\varepsilon\), write the conditional mean line for each group.
  2. If \(\beta_1=2.4\) and \(\beta_3=-0.6\), what is the comparison group’s slope, and how does it differ from the reference group’s slope?
  3. At \(X=5\), what expression gives the comparison group’s expected response minus the reference group’s expected response?
  4. Why does a model with a group indicator but no indicator interaction require the groups’ fitted lines to be parallel?
  5. What changes, and what stays the same, when the reference group is switched?