Tutorials › Regression Analysis (Undergraduate) › Parallel Lines for Comparing Groups

Interactions Among Groups · Tutorial 345 of 991

Parallel Lines for Comparing Groups

Use group indicators to fit parallel regression lines, and interpret the shared slope and constant adjusted differences between groups.

Intermediate 9 min read

What You'll Learn

  • Write a regression model with one quantitative predictor and categorical group indicators
  • Identify the reference group and interpret its coefficients
  • Fit a common slope from grouped data using least squares
  • Explain why the fitted group lines are parallel
  • Distinguish adjusted group differences from raw mean differences
  • Recognize when the no-interaction model may be inappropriate

Comparing Groups With Parallel Lines

Suppose a researcher wants to compare an outcome across groups while accounting for a quantitative predictor. For example, students in different course formats might have different exam scores, and study time might also be related to score. A regression model can represent both relationships at once. If it assumes that the relationship with study time is the same in every format, the fitted lines are parallel: they share a slope but can have different heights.

This is an additive model: the group indicators add constant differences to the predicted outcome, while the quantitative predictor contributes the same amount per unit in each group. The model is useful when a common slope is scientifically reasonable and there is enough overlap in the predictor values to make group comparisons meaningful.

Definition: For an outcome \(Y\), quantitative predictor \(x\), and categorical group \(G\) with \(K\) levels, choose one level as the reference group. The parallel-lines regression model is $$ Y_i=\beta_0+\beta_1x_i+\beta_2I(G_i=2)+\cdots+\beta_KI(G_i=K)+\varepsilon_i, $$ where the reference group is level 1, and \(I(G_i=j)\) equals 1 when individual \(i\) is in group \(j\) and 0 otherwise. The conditional mean is linear in \(x\), with a common slope \(\beta_1\) and group-specific intercepts. The error \(\varepsilon_i\) is the difference between the observed outcome and its conditional mean.

There are \(K-1\) indicator variables because the reference group is represented by all indicators equal to zero. For group 1, the fitted conditional mean is \(\beta_0+\beta_1x\). For group \(j\), it is \((\beta_0+\beta_j)+\beta_1x\). Thus \(\beta_0\) is the reference-group intercept, and \(\beta_j\) is the difference in intercept between group \(j\) and the reference group. At any fixed value of \(x\), that same \(\beta_j\) is the modelled difference in conditional mean outcome.

What “Parallel” Means in the Model

A slope describes the change in the modelled mean outcome for a one-unit increase in \(x\), holding group fixed. Because the model contains no product terms between \(x\) and the group indicators, that change is \(\beta_1\) in every group. A group coefficient changes the intercept, not the slope.

For two groups, A as the reference and B as the comparison, the model is

$$ E(Y\mid x,G=\mathrm{A})=\beta_0+\beta_1x,\qquad E(Y\mid x,G=\mathrm{B})=(\beta_0+\beta_2)+\beta_1x. $$

Subtracting the first conditional mean from the second gives

$$ E(Y\mid x,G=\mathrm{B})-E(Y\mid x,G=\mathrm{A})=\beta_2. $$

The difference does not depend on \(x\). This is the defining feature of the model: it describes constant adjusted group differences over the predictor values under consideration. It does not assert that observed outcomes in the two groups differ by exactly the same amount for every individual; individual outcomes also include errors.

Worked Example: Interpreting Two Parallel Group Lines

Consider a hypothetical analysis of exam score, measured in points, by weekly study time, measured in hours, and course format. Suppose the fitted model uses lecture format as the reference group:

$$ \widehat{Y}=52+4.2x+6I(\text{seminar}). $$

For lecture format, the indicator is 0, so the fitted equation is \(\widehat{Y}=52+4.2x\). For seminar format, the indicator is 1, so the equation is \(\widehat{Y}=52+4.2x+6=58+4.2x\).

The common slope is \(4.2\) points per additional weekly study hour. Under this model, increasing study time by one hour is associated with a 4.2-point increase in fitted exam score in either format. The seminar coefficient is \(6\) points: at the same study time, the fitted mean exam score for seminar students is 6 points higher than for lecture students.

For instance, at \(x=5\) hours, the lecture prediction is \(52+4.2(5)=73\) points and the seminar prediction is \(58+4.2(5)=79\) points. Their difference is \(79-73=6\) points. The intercepts are model predictions at zero study hours; they should not be given a practical interpretation if zero hours is outside the relevant data range.

These coefficients describe adjusted associations, not necessarily causal effects. The model accounts for study time as specified, but other differences between students or formats could still be relevant.

Fitting the Common-Slope Model

The coefficients are usually estimated by ordinary least squares: choose the coefficients that minimize the sum of squared residuals, where each residual is observed \(Y_i\) minus fitted \(\widehat{Y}_i\). The model’s error assumptions should be considered before using the fit for interpretation or inference. In particular, the conditional mean should be adequately represented by straight lines with a shared slope; observations should be independent under the study design; and the errors should have mean zero and constant variance at each predictor and group combination. Normal errors are additionally used for exact small-sample \(t\)-based inference. A fit by least squares can be calculated without assuming normal errors, but a calculation alone does not establish that these assumptions are reasonable.

For the two-group model with both groups observed at the same predictor values, the common slope can be understood as a pooled within-group slope. Group intercepts absorb differences in group levels, so the slope is estimated from how outcomes vary with \(x\) within groups, not from the difference between group means alone. The following derivation makes that point precise for balanced data with the same \(x\) values in each group.

Justification: For a proposed common slope \(b\), least squares chooses each group’s intercept to make that group’s residuals sum to zero. For group \(g\), its intercept is therefore \(\bar{y}_g-b\bar{x}_g\). Substituting this intercept into the squared residuals gives residuals \((y_{ig}-\bar{y}_g)-b(x_{ig}-\bar{x}_g)\). Differentiating the sum of their squares with respect to \(b\), setting the derivative equal to zero, and solving yields $$ \widehat{\beta}_1= \frac{\sum_g\sum_i(x_{ig}-\bar{x}_g)(y_{ig}-\bar{y}_g)} {\sum_g\sum_i(x_{ig}-\bar{x}_g)^2}. $$ Thus each group contributes its within-group association between \(x\) and \(Y\). After finding the slope, the fitted intercept for each group is \(\bar{y}_g-\widehat{\beta}_1\bar{x}_g\). This formula is shown for data with the same predictor observations in each group; with unequal designs, least squares still estimates the coefficients by minimizing the full residual sum of squares.

Worked Example: Calculating a Common Slope From Two Groups

The following hypothetical data give an outcome \(Y\) and predictor \(x\) for three observations in each of two groups. Suppose \(x\) is within the range of interest and the observations are independent. The values provide no obvious reason to reject a straight-line mean pattern, but six observations cannot establish independence or constant error variance; these should be assessed using the study design and residuals. We fit the shared-slope model with group A as the reference.

Group\(x\)\(Y\)
A18
A211
A312
B111
B213
B316

Both groups have \(\bar{x}_g=2\), and the within-group sum of squared deviations in \(x\) is \(2\) for each group. For A, \(\bar{y}_{\mathrm{A}}=(8+11+12)/3=10.333\), and its within-group cross-product is \((-1)(8-10.333)+0(11-10.333)+1(12-10.333)=4\). For B, \(\bar{y}_{\mathrm{B}}=(11+13+16)/3=13.333\), and its cross-product is \((-1)(11-13.333)+0(13-13.333)+1(16-13.333)=5\).

Using the common-slope formula,

$$ \widehat{\beta}_1=\frac{4+5}{2+2}=\frac{9}{4}=2.25. $$

The fitted intercept for A is \(10.333-2.25(2)=5.833\), and for B it is \(13.333-2.25(2)=8.833\). The fitted model, with A as reference, is therefore

$$ \widehat{Y}=5.833+2.25x+3I(\mathrm{B}). $$

The fitted group difference is \(8.833-5.833=3\) outcome units at each shared value of \(x\). For example, at \(x=2\), the predictions are \(5.833+2.25(2)=10.333\) for A and \(5.833+2.25(2)+3=13.333\) for B. This calculation illustrates the model’s constant adjusted difference; it does not by itself show that the model assumptions hold.

More Than Two Groups

With \(K\) groups, select one reference category and include one indicator for each of the other \(K-1\) groups. Each indicator coefficient compares that group with the reference group, adjusting for \(x\). The comparisons are not automatically comparisons between every pair of non-reference groups; for example, the difference between groups 2 and 3 is \(\beta_3-\beta_2\) under the notation in the definition.

Worked Example: Comparing Three Clinic Groups

Suppose a hypothetical model predicts a follow-up measurement in millimetres from baseline measurement \(x\), also in millimetres, and clinic group. Clinic A is the reference group. The fitted model is

$$ \widehat{Y}=8+0.70x-2I(\mathrm{B})+3I(\mathrm{C}). $$

For clinic A, both indicators are zero, giving \(\widehat{Y}_{\mathrm{A}}=8+0.70x\). For clinic B, the B indicator is one and the C indicator is zero, giving \(\widehat{Y}_{\mathrm{B}}=6+0.70x\). For clinic C, the prediction is \(\widehat{Y}_{\mathrm{C}}=11+0.70x\).

The common slope is \(0.70\) millimetres of fitted follow-up measurement per millimetre of baseline measurement. Holding baseline measurement fixed, the fitted mean for B is \(2\) mm lower than for A, and the fitted mean for C is \(3\) mm higher than for A. The fitted C-minus-B difference is \(3-(-2)=5\) mm. At \(x=20\) mm, for example, the three predictions are \(8+0.70(20)=22\) mm, \(6+0.70(20)=20\) mm, and \(11+0.70(20)=25\) mm. These values preserve the same group differences at any other \(x\) for which the model is being used.

When the Parallel-Lines Model Is a Poor Choice

The model is a substantive assumption, not merely a convenient way to organize data. If the association between \(x\) and the outcome differs across groups, a single shared slope can conceal that pattern. A plot of outcomes against \(x\), separated by group, can help reveal whether the lines plausibly have similar slopes, but a plot is not conclusive proof. Residual patterns and the study context also matter. The appropriate model should not be chosen only because its fitted lines are simpler.

Predictor coverage matters as well. If one group has observations only at low values of \(x\) and another only at high values, their adjusted difference at the same \(x\) may rely on extrapolation rather than direct comparison. Even if a parallel-lines model is fitted, interpret comparisons where the groups have meaningful overlap and explain when an interpretation depends on the assumed linear model.

  • Common mistake: interpreting a group coefficient as a raw mean difference. The coefficient compares modelled group means at the same \(x\), not necessarily the groups’ overall observed means.
  • Common mistake: assuming “no interaction” means no group difference. Group coefficients can be nonzero; the no-interaction assumption is that those differences do not change with \(x\).
  • Common mistake: treating parallel fitted lines as proof of equal real-world slopes. Parallelism is imposed by the model. Whether it is reasonable must be assessed using the data and subject-matter context.
  • Common mistake: making an adjusted comparison where groups have no predictor overlap. A numerical prediction can still be calculated, but it may be an extrapolation and should be reported cautiously.
Key takeaway: A regression with quantitative \(x\), group indicators, and no \(x\)-by-group product terms assigns every group the same slope. Each group indicator coefficient is a constant adjusted difference from the reference group, measured at the same value of \(x\).

Check Your Understanding

Try these questions using the model definitions and interpretations above.

  1. In a two-group model with A as the reference group, what does the coefficient of \(I(\mathrm{B})\) represent?
  2. A fitted model is \(\widehat{Y}=10+2x-4I(\mathrm{B})\). Write the fitted equation for each group and state the predicted group difference at a fixed \(x\).
  3. Why does a regression with group indicators but no product terms give parallel fitted lines?
  4. In a three-group model with A as the reference, the coefficients for B and C are \(-1.5\) and \(2.0\). What is the fitted C-minus-B difference at the same \(x\)?
  5. Name one reason why an adjusted group comparison from a parallel-lines model might be unreliable, even if the model can be fitted.