Why Expand an Interaction Model?
A regression model with a categorical group variable and a quantitative predictor can be written compactly using indicator variables and product terms. That compact form may be convenient for fitting the model, but it can obscure what the fitted line looks like within each group. Expanding the model shows the fitted intercept and slope for each group directly.
The task here is algebraic: read the coefficient table, identify which group is the reference group, and combine the appropriate terms to write one fitted equation per group. The equations describe fitted mean outcomes, not necessarily the outcome of any particular individual.
The Two-Group Model
Suppose \(Y\) is an outcome, \(x\) is a quantitative predictor, and there are two groups: a reference group and a comparison group. Let \(D=0\) for the reference group and \(D=1\) for the comparison group. A model with a group-specific intercept and slope can be written as
Here \(b_0,b_1,b_2,\) and \(b_3\) are the estimated regression coefficients. Before interpreting the fitted equations, the model's form should be appropriate for the question: the outcome is represented by a fitted mean, the predictor is quantitative, group membership is encoded as specified, and a straight-line mean relationship is being used within each group over the predictor range of interest. The equations do not by themselves establish a causal relationship.
To find the reference-group equation, substitute \(D=0\). The group-indicator term and the product term both become zero. For the comparison group, substitute \(D=1\); both the indicator and its product with \(x\) remain in the equation.
Thus the reference group's fitted intercept and slope are \(b_0\) and \(b_1\). The comparison group's fitted intercept and slope are \(b_0+b_2\) and \(b_1+b_3\). An intercept is the fitted outcome at \(x=0\), provided that value is meaningful in context; if 0 is far outside the observed predictor range, the intercept may be an algebraic feature of the line without a useful practical interpretation.
Worked Example: Study Hours in Two Course Groups
Suppose a hypothetical analysis models quiz score \(Y\), in points, using weekly study hours \(x\). The reference group is students in the standard course, and \(D_E=1\) for students in an enriched course and 0 otherwise. The estimated model is
For the standard-course group, \(D_E=0\), so the group and product terms are both zero:
The standard-course fitted intercept is 18 points and its fitted slope is 1.6 points per additional weekly study hour.
For the enriched-course group, \(D_E=1\):
The enriched-course fitted intercept is 22 points and its fitted slope is 1.3 points per additional weekly study hour. For example, at \(x=5\) hours, the fitted scores are \(18+1.6(5)=26.0\) points in the standard group and \(22+1.3(5)=28.5\) points in the enriched group. These are fitted mean scores from the model, not guaranteed scores for individual students.
Reading the Coefficient Table
A coefficient table typically lists a constant, the quantitative predictor, the group indicator, and the interaction between the predictor and the indicator. The labels matter: the coefficient for the indicator contributes to the intercept when the indicator is 1, while the coefficient for the product contributes to the coefficient of \(x\) when that indicator is 1. Neither term should be omitted when writing the non-reference group's equation.
A reliable method is to write the full fitted model first, then substitute the indicator value for one group at a time. Only after substitution should you collect the constant terms and the terms multiplying \(x\). This helps prevent a common error: copying the reference intercept into every group equation without adding the appropriate group-indicator coefficient.
Worked Example: Reconstructing Lines from a Coefficient Table
For a hypothetical dataset on daily output \(Y\), measured in units, let \(x\) be years of experience. Group A is the reference group; \(D_B=1\) identifies Group B, and \(D_C=1\) identifies Group C. The fitted coefficient table is:
| Term | Estimate |
|---|---|
| Intercept | 12 |
| Experience \(x\) | 2.0 |
| Group B indicator \(D_B\) | 3 |
| Group C indicator \(D_C\) | -2 |
| Experience by Group B \(xD_B\) | 0.5 |
| Experience by Group C \(xD_C\) | -0.8 |
Write the full model from the table before deriving the group equations:
For Group A, \(D_B=0\) and \(D_C=0\). All group-specific terms vanish, giving \(\widehat{Y}=12+2.0x\). Its fitted intercept is 12 units, and its fitted slope is 2.0 units per year of experience.
For Group B, \(D_B=1\) and \(D_C=0\). Substitution gives
Group B's fitted intercept is 15 units, and its fitted slope is 2.5 units per year.
For Group C, \(D_B=0\) and \(D_C=1\):
Group C's fitted intercept is 10 units, and its fitted slope is 1.2 units per year. As a check, at \(x=4\), the three equations give fitted values \(12+2.0(4)=20\), \(15+2.5(4)=25\), and \(10+1.2(4)=14.8\) units. Substituting the same group indicators into the full model gives those same values.
Extending the Method to Several Groups
With \(G\) groups, reference coding uses one indicator for each of the \(G-1\) non-reference groups. If the reference group is numbered 0 and the other groups are numbered \(1,\ldots,G-1\), the fitted model can be written
For the reference group, every \(D_j=0\), so its fitted equation is \(b_0+b_1x\). For non-reference group \(j\), its own indicator is 1 and all other group indicators are 0. Its equation is \((b_0+b_j)+(b_1+c_j)x\). This is simply repeated substitution; it does not require a separate fitting procedure for each group.
A Short Justification and a Practical Check
The rule follows directly from the indicator values. For the reference group, each indicator is 0, so \(b_jD_j=0\) and \(c_j(xD_j)=0\) for every non-reference group \(j\). Only \(b_0+b_1x\) remains. For a particular non-reference group \(k\), \(D_k=1\) while \(D_j=0\) for every \(j\ne k\). Therefore the terms that remain are \(b_0+b_1x+b_k+c_kx\), which can be collected as \((b_0+b_k)+(b_1+c_k)x\). This proves the group-equation rule.
As a practical check, every observation must belong to exactly one of the modeled groups. In reference coding, a reference-group observation has every indicator equal to 0; an observation in group \(k\) has \(D_k=1\) and the other indicators equal to 0. If two group indicators are mistakenly set to 1 for one observation, the substitution no longer represents any of the specified groups.
Common Mistakes and Why the Equations Matter
The fitted equations make the model easier to communicate. A coefficient table is compact, but group-specific equations let a reader see the fitted intercept and slope for each category and calculate predictions within a group. They also provide a direct check that the fitted model has been transcribed correctly.
- Leaving out the indicator on the group term. In the first example, the correct model contains \(4D_E\), not a bare \(+4\). If the term were written as \(+4\), the value 4 would be added to every group's intercept, including the reference group. Substituting \(D_E=0\) into \(4D_E\) correctly removes it from the reference equation.
- Adding only the group-indicator coefficient. The comparison group's equation also includes its product-term coefficient on \(x\). In the first example, both \(4D_E\) and \(-0.3(xD_E)\) must be included when \(D_E=1\).
- Assigning the comparison equation to the reference group. The reference group is the one with all indicators set to 0. Check the coding rather than guessing which group the constant describes.
- Calling a fitted value an individual outcome. A fitted equation gives the model's predicted mean outcome at a predictor value. It does not guarantee that every person or unit in that group has that outcome.
- Over-interpreting an intercept. The intercept is the fitted value at \(x=0\). If zero is not scientifically meaningful or is outside the relevant data range, its numerical value may have limited practical meaning.
Finally, equations describe fitted relationships in the model's units. In a line \(\widehat{Y}=a+mx\), \(a\) is measured in the units of \(Y\), while \(m\) is measured in units of \(Y\) per unit of \(x\). Stating those units helps distinguish the intercept from the slope and makes the group equations interpretable in context.
Check Your Understanding
For each question, write or inspect the group equations before interpreting their coefficients.
- A model is \(\widehat{Y}=7+0.9x-2D+0.4(xD)\), where \(D=0\) identifies the reference group and \(D=1\) the other group. Write both fitted equations and identify each intercept and slope.
- A three-group model has terms \(b_0+b_1x+b_AD_A+b_BD_B+c_AxD_A+c_BxD_B\). Which indicator values represent the reference group?
- In a two-group model, why must the interaction term be substituted along with the group indicator when deriving the non-reference group's equation?
- A coefficient table reports an intercept of 20, a predictor coefficient of 3, a group-indicator coefficient of 5, and an interaction coefficient of \(-1\). Write the reference and non-reference group equations.
- Explain why a fitted intercept may have limited practical meaning when \(x=0\) lies far outside the observed predictor values.