Tutorials › Causal Inference › Linear Regression Interaction Terms

Effect Modification and Subgroup Effects · Tutorial 858 of 972

Linear Regression Interaction Terms

Translate linear regression coefficients into treatment effects for each subgroup and into the additive contrast between those effects.

Advanced 12 min read

What You'll Learn

  • Write a linear model with treatment, subgroup, and treatment-by-subgroup terms.
  • Derive the modeled treatment effect in each subgroup from the regression coefficients.
  • Interpret the interaction coefficient as a difference between subgroup effects on the outcome scale.
  • Recover the coefficients of a saturated binary-treatment, binary-subgroup model from its four cell means.
  • Distinguish a causal subgroup effect from a regression association and identify assumptions needed for the causal interpretation.
  • Recognize why omitting the interaction imposes a common treatment effect in the model.

Why Put an Interaction in a Linear Model?

A treatment effect can differ across subgroups even when the same treatment is assigned in both. A linear regression represents one particular kind of difference: variation in the treatment effect on the additive outcome scale. The treatment-by-covariate term is the model component that allows the treatment contrast to change with the covariate.

The coefficient on that term is not usually the treatment effect in either subgroup by itself. To interpret it, first calculate the treatment contrast at each covariate value; then compare those contrasts. This distinction matters in clinical interpretation: the treatment coefficient refers to a specified reference value, while the interaction coefficient describes how the modeled treatment effect changes relative to that reference.

Definition: Let \(T\) indicate treatment, with \(T=1\) for treatment and \(T=0\) for control, and let \(S\) indicate a pre-treatment subgroup, with \(S=1\) for the subgroup of interest and \(S=0\) for the reference subgroup. The linear regression model with a treatment-by-subgroup interaction is $$ E[Y\mid T,S]=\beta_0+\beta_T T+\beta_S S+\beta_{TS}(T S). $$ Here \(Y\) is a quantitative outcome, \(\beta_0\) is the mean for the control group in the reference subgroup, \(\beta_T\) is the treatment-control difference in that reference subgroup, \(\beta_S\) is the subgroup difference among controls, and \(\beta_{TS}\) is the treatment-by-subgroup interaction coefficient.

The product \(T S\) is one only for treated individuals in subgroup \(S=1\); it is zero in the other three treatment-subgroup combinations. A linear regression without this product term sets \(\beta_{TS}=0\), which imposes a common treatment-control difference across the two subgroups. Including the product term relaxes that restriction.

From Coefficients to Subgroup Treatment Effects

The coefficient meanings follow by evaluating the model in each treatment-subgroup combination. The fitted conditional means are:

$$ \begin{aligned} E[Y\mid T=0,S=0]&=\beta_0,\\ E[Y\mid T=1,S=0]&=\beta_0+\beta_T,\\ E[Y\mid T=0,S=1]&=\beta_0+\beta_S,\\ E[Y\mid T=1,S=1]&=\beta_0+\beta_T+\beta_S+\beta_{TS}. \end{aligned} $$

Subtract the control mean from the treatment mean within each subgroup. In the reference subgroup, the treatment-control difference is \(\beta_T\). In subgroup \(S=1\), it is \(\beta_T+\beta_{TS}\). Subtracting the reference-subgroup difference from the \(S=1\) difference leaves \(\beta_{TS}\).

Result: Under this model, the treatment-control difference in the reference subgroup is \(\beta_T\), and the difference in subgroup \(S=1\) is \(\beta_T+\beta_{TS}\). The additive contrast between the subgroup effects, defined as the effect in \(S=1\) minus the effect in \(S=0\), is \(\beta_{TS}\). All three quantities are measured in the units of \(Y\).

This is a result about the model's mean contrasts. It is a causal result only when the model's observed-data contrasts identify the corresponding potential-outcome contrasts. In a randomized trial, that interpretation requires treatment to be randomized within each subgroup, each treatment to be possible in each subgroup, a well-defined treatment and outcome, and no interference between individuals. For an observational study, a causal interpretation additionally requires appropriate control of confounding, such as conditional exchangeability given measured covariates. Regression adjustment alone does not establish these conditions.

The subgroup variable must also be defined before treatment for the usual baseline subgroup interpretation. If subgroup membership is measured after treatment, comparing people by their observed post-treatment subgroup can select different kinds of individuals in each treatment arm and need not estimate treatment-effect modification in a baseline population.

A Short Derivation From the Four Cell Means

Let \(\mu_{ts}=E[Y\mid T=t,S=s]\) denote the mean in treatment group \(t\) and subgroup \(s\). The four model equations above imply \(\beta_0=\mu_{00}\), \(\beta_T=\mu_{10}-\mu_{00}\), and \(\beta_S=\mu_{01}-\mu_{00}\). The remaining equation gives the interaction coefficient:

$$ \begin{aligned} \beta_{TS} &=\mu_{11}-\beta_0-\beta_T-\beta_S\\ &=\mu_{11}-\mu_{00}-(\mu_{10}-\mu_{00})-(\mu_{01}-\mu_{00})\\ &=(\mu_{11}-\mu_{01})-(\mu_{10}-\mu_{00}). \end{aligned} $$

Thus the interaction is a difference in differences: the treatment-control difference in subgroup \(S=1\), minus the treatment-control difference in the reference subgroup. This identity is exact for the stated model with binary \(T\) and \(S\). In a sample, the same algebra applies to the four fitted cell means in a saturated model. It does not by itself show that the contrast is causal.

Worked Example: Recovering Effects From Four Subgroup Means

Consider a hypothetical randomized trial of a rehabilitation program. The outcome is a functional score at 12 weeks, with higher scores indicating better function. Suppose the subgroup-specific sample means are as follows:

Baseline subgroupControl meanTreatment meanSample sizes (control, treatment)
\(S=0\)50 points62 points80, 80
\(S=1\)55 points72 points60, 60

Code \(S=0\) as the reference subgroup and fit the model with \(T\), \(S\), and \(T S\). In a saturated model for two binary variables, the coefficients are recovered from the four means:

$$ \begin{aligned} \hat{\beta}_0&=\bar{Y}_{00}=50,\\ \hat{\beta}_T&=\bar{Y}_{10}-\bar{Y}_{00}=62-50=12,\\ \hat{\beta}_S&=\bar{Y}_{01}-\bar{Y}_{00}=55-50=5,\\ \hat{\beta}_{TS}&=(72-55)-(62-50)=17-12=5. \end{aligned} $$

The estimated treatment effect in \(S=0\) is \(\hat{\beta}_T=12\) points. In \(S=1\), it is \(\hat{\beta}_T+\hat{\beta}_{TS}=12+5=17\) points. The estimated additive contrast is \(17-12=5\) points, equal to \(\hat{\beta}_{TS}\). Equivalently, the model predicts means of 50, 62, 55, and \(50+12+5+5=72\) points for the four cells, matching the data.

For a causal interpretation, suppose treatment was randomized within both baseline subgroups, both arms were represented in each subgroup, and follow-up and outcome measurement were comparable across arms. Also suppose the program is well defined and one participant's assignment does not affect another participant's outcome. Under those conditions, the within-subgroup randomized contrasts estimate the subgroup-specific causal effects. The computed 5-point contrast then describes a larger average treatment benefit in \(S=1\) than in \(S=0\) on this score scale. Without those design conditions, these calculations describe differences in observed means, not necessarily causal effects.

What Changes When the Subgroup Coding Changes?

The reference subgroup determines which treatment effect is represented by \(\beta_T\). With \(S=0\) as the reference, \(\beta_T\) is the effect for \(S=0\), and \(\beta_{TS}\) is the difference between the \(S=1\) and \(S=0\) effects. The effect for \(S=1\) must therefore be calculated by adding the two coefficients.

The interaction's sign also depends on the direction of the contrast: here it is \(S=1\) minus \(S=0\). A positive coefficient means the modeled treatment effect is more positive in \(S=1\), in the units of \(Y\). Whether that corresponds to greater benefit depends on how the outcome is defined. If lower scores are preferable, for example, a more negative effect could represent greater benefit.

For a numeric covariate \(X\), the same algebra applies to the model \(E[Y\mid T,X]=\beta_0+\beta_T T+\beta_X X+\beta_{TX}TX\). At a specified value \(x\), the modeled treatment-control difference is \(\beta_T+\beta_{TX}x\). This expression shows why \(\beta_T\) is the treatment difference at \(X=0\), not a universal treatment effect. The detailed choice of functional form for continuous effect modifiers is a separate modeling question; the interpretation still begins by calculating the treatment contrast at the covariate value of interest.

Worked Example: Interpreting an Adjusted Interaction Model

In a hypothetical randomized study, \(Y\) is change in symptom score, measured in points, with a positive change indicating improvement. Let \(S=0\) denote participants with lower baseline severity and \(S=1\) those with higher baseline severity. An investigator fits a linear regression that also adjusts for baseline score \(Z\):

$$ E[Y\mid T,S,Z] =\beta_0+\beta_TT+\beta_SS+\beta_{TS}(TS)+\gamma(Z-z_0). $$

Here \(z_0\) is a chosen baseline-score reference value. Suppose the fitted coefficients are \(\hat{\beta}_T=4.2\) points and \(\hat{\beta}_{TS}=-2.7\) points. The model contains no treatment-by-\(Z\) term, so its treatment contrast at a fixed \(S\) does not vary with \(Z\). For \(S=0\):

$$ \widehat{\Delta}(0)=\hat{\beta}_T=4.2\text{ points}. $$

For \(S=1\):

$$ \widehat{\Delta}(1)=\hat{\beta}_T+\hat{\beta}_{TS} =4.2+(-2.7)=1.5\text{ points}. $$

The estimated contrast is \(1.5-4.2=-2.7\) points, the interaction coefficient. In this model, the estimated improvement is 2.7 points smaller in the higher-severity subgroup than in the lower-severity subgroup. It remains positive in both subgroups according to these point estimates.

The study is hypothetical, so these values illustrate coefficient interpretation rather than evidence about a real treatment. For a causal interpretation, randomization must hold within each subgroup, both treatment assignments must occur in both subgroups, and the usual consistency and no-interference conditions must hold. The adjustment model must also represent the conditional mean adequately; in particular, this specification assumes that the treatment contrast does not vary with \(Z\). If that assumption is not appropriate, the reported subgroup effects may not describe the intended averages over baseline scores. The coefficients alone do not establish that the interaction is statistically distinguishable from zero.

Worked Example: A Subgroup Difference Is Not Necessarily Effect Modification

Suppose a hypothetical randomized trial measures a quality-of-life score, with higher values preferred. The control mean is 40 and the treatment mean is 48 in \(S=0\); in \(S=1\), the control mean is 60 and the treatment mean is 68. Each of the four cells has 50 participants.

The treatment effects are \(48-40=8\) points in \(S=0\) and \(68-60=8\) points in \(S=1\). The interaction coefficient is:

$$ \hat{\beta}_{TS}=(68-60)-(48-40)=8-8=0\text{ points}. $$

The subgroup coefficient is \(\hat{\beta}_S=60-40=20\) points: among controls, the \(S=1\) mean is 20 points higher than the \(S=0\) mean. That baseline difference is not a treatment-effect contrast. Because the treatment-control difference is 8 points in both subgroups, this model has no additive effect modification, despite the substantial difference in subgroup outcome levels.

If treatment was randomized within each subgroup and the outcome was measured consistently, the two observed treatment contrasts estimate the causal effects in the subgroups. The example illustrates that subgroup outcome levels and subgroup treatment effects answer different questions.

Why the Interaction Term Matters

A model with treatment and subgroup main effects but no product term is:

$$ E[Y\mid T,S]=\beta_0+\beta_TT+\beta_SS. $$

Setting \(T=0\) gives the control mean as a function of subgroup. Setting \(T=1\) and subtracting the control mean gives \(\beta_T\) in either subgroup. The model therefore asserts equal additive treatment effects by construction. A fitted common effect from this model is not evidence that the subgroup effects are equal; equality was imposed by omitting the interaction.

Conversely, including an interaction permits different subgroup contrasts but does not guarantee that the estimates are precise or that the difference is important. The coefficient is a point estimate on the outcome scale. Questions about uncertainty, hypothesis tests, and the clinical importance of a subgroup contrast require additional considerations beyond the algebra of interpreting the coefficients.

Common Mistakes

  • Calling \(\beta_{TS}\) the treatment effect in subgroup \(S=1\). It is the difference between the \(S=1\) and reference-subgroup effects. The \(S=1\) effect is \(\beta_T+\beta_{TS}\).
  • Interpreting \(\beta_T\) as an overall treatment effect. With this coding, it is the treatment effect at \(S=0\). An overall effect averages across a target population and is not generally given by this coefficient.
  • Confusing a subgroup outcome difference with effect modification. The coefficient \(\beta_S\) compares subgroup means among controls. Effect modification on the additive scale is represented by \(\beta_{TS}\).
  • Assuming a regression interaction is automatically causal. A product term describes a feature of the fitted conditional mean. Causal interpretation also requires appropriate design or identification assumptions.
  • Ignoring the outcome scale and direction. The interaction is an additive contrast measured in outcome units. A positive value does not always mean greater clinical benefit; that depends on whether higher or lower outcomes are desirable.
  • Using a post-treatment subgroup as if it were a baseline characteristic. Conditioning on a variable affected by treatment can undermine a straightforward comparison of treatment effects between subgroups.
Key takeaway: In a linear regression with binary treatment and binary subgroup, first calculate the treatment-control contrast within each subgroup. With \(S=0\) as the reference, those contrasts are \(\beta_T\) and \(\beta_T+\beta_{TS}\); their difference, \(S=1\) minus \(S=0\), is \(\beta_{TS}\). The causal meaning of these contrasts depends on the study design and assumptions, not on the interaction term alone.

Check Your Understanding

Use the stated coding, with \(T=1\) for treatment and \(S=0\) as the reference subgroup.

  1. In \(E[Y\mid T,S]=\beta_0+\beta_TT+\beta_SS+\beta_{TS}TS\), which treatment effect does \(\beta_T\) represent?
  2. If \(\beta_T=3\) and \(\beta_{TS}=-1.5\), what are the modeled treatment effects in \(S=0\) and \(S=1\), and what is their contrast?
  3. Why does a model that omits \(TS\) impose a common treatment effect across the two subgroups?
  4. Suppose the \(S=1\) control mean exceeds the \(S=0\) control mean, but the treatment-control differences are equal. What does this imply about \(\beta_S\) and \(\beta_{TS}\)?
  5. Name two conditions needed to interpret observed randomized-trial subgroup contrasts as causal subgroup effects.
Clinical Biostats