Tutorials › Joint Modeling of Longitudinal and Time-to-Event Data › Treatment-by-Time Interactions

Mixed Models Review · Tutorial 66 of 697

Treatment-by-Time Interactions

Learn to specify and interpret treatment-by-time fixed effects, including how time coding changes the treatment coefficient but not the fitted trajectories.

Intermediate 10 min read

What You'll Learn

  • Write a linear mean model with treatment, time, and their interaction.
  • Interpret the treatment coefficient at the time origin and the interaction as a slope difference.
  • Calculate fitted group means, treatment contrasts, and differences in change.
  • Test a treatment-by-time interaction and interpret its uncertainty in context.
  • Recognize how recentering time changes coefficient meanings without changing fitted values.
  • Diagnose when a linear treatment-specific trajectory is inadequate.

Why Separate Baseline Differences From Change?

Suppose biomarker measurements are collected repeatedly from patients in two treatment groups. The groups may differ at the start of follow-up, and they may also change at different rates. These are distinct features of the data: a group difference at baseline is not, by itself, evidence that the groups have different trajectories. A treatment-by-time interaction gives the mean trajectories separate slopes, allowing those questions to be addressed separately.

This tutorial considers a linear time trend and a binary treatment indicator. The focus is the fixed-effects mean structure: what the coefficients say about group means over time. Repeated measurements from the same person are generally correlated, so standard errors and tests must come from an analysis that accounts for that dependence. The interaction in the mean model does not, by itself, specify the within-person covariance structure.

Model and Coefficient Meanings

Definition: Let \(Y_{ij}\) be the biomarker measurement for subject \(i\) at visit \(j\), let \(t_{ij}\) be time since baseline in stated units, and let \(A_i=0\) for the control group and \(A_i=1\) for the treatment group. The linear treatment-by-time mean model is $$ E(Y_{ij}\mid A_i,t_{ij})=\beta_0+\beta_1t_{ij}+\beta_2A_i+\beta_3A_it_{ij}. $$ Here \(\beta_0\) and \(\beta_1\) are the control-group intercept and slope; \(\beta_2\) is the treatment-minus-control mean difference at \(t=0\); and \(\beta_3\) is the treatment-minus-control difference in slope.

The corresponding fitted mean trajectories are

$$ \begin{aligned} \text{Control: }&\beta_0+\beta_1t,\\ \text{Treatment: }&(\beta_0+\beta_2)+(\beta_1+\beta_3)t. \end{aligned} $$

Thus, the treatment group’s fitted baseline mean is \(\beta_0+\beta_2\), and its fitted change per time unit is \(\beta_1+\beta_3\). The control group’s fitted change per time unit is \(\beta_1\). At time \(t\), the treatment-minus-control contrast is \(\beta_2+\beta_3t\). Over the interval from baseline to time \(t\), the difference between the groups’ fitted changes is \(\beta_3t\).

The units matter. If the biomarker is measured in mg/L and time in months, \(\beta_1\) and \(\beta_3\) are in mg/L per month; \(\beta_2\) is in mg/L. The coefficient \(\beta_3\) is a difference in slopes, not the treatment difference at every visit. If \(t=0\) is baseline, \(\beta_2\) describes the fitted group difference at baseline. When baseline is measured before treatment begins, that coefficient is not a treatment effect on the pre-treatment measurement.

Worked Example: Reading Two Fitted Trajectories

Suppose a hypothetical fitted model for a biomarker measured in mg/L, with time in months since baseline, has \(\beta_0=12\), \(\beta_1=-0.30\), \(\beta_2=1.5\), and \(\beta_3=0.20\). Write and interpret both trajectories, then compare the groups at six months.

For control, the fitted mean at time \(t\) is \(12-0.30t\). Its fitted baseline mean is 12 mg/L, and its fitted slope is \(-0.30\) mg/L per month. For treatment, the fitted mean is \[ (12+1.5)+(-0.30+0.20)t=13.5-0.10t. \] Its fitted baseline mean is 13.5 mg/L and its fitted slope is \(-0.10\) mg/L per month.

At six months, the control fitted mean is \(12-0.30(6)=10.2\) mg/L. The treatment fitted mean is \(13.5-0.10(6)=12.9\) mg/L. Their difference is \(12.9-10.2=2.7\) mg/L. Equivalently, the contrast formula gives \(\beta_2+\beta_3t=1.5+0.20(6)=2.7\) mg/L.

The baseline difference is 1.5 mg/L, while the difference in change over six months is \(0.20(6)=1.2\) mg/L. Those two components sum to the six-month contrast. The positive interaction means the treatment group’s fitted slope is 0.20 mg/L per month higher than the control slope; it does not mean that the biomarker increases in the treatment group, whose fitted slope here is still negative.

Testing and Interpreting the Interaction

The usual test of whether the fitted linear slopes differ is \(H_0:\beta_3=0\) against \(H_a:\beta_3\ne0\). A test statistic is the estimated interaction coefficient divided by its standard error, with a reference distribution and degrees of freedom determined by the fitted model and its inferential method. Because measurements within a subject can be correlated, the standard error must account for the repeated-measures structure; treating every visit as independent can give misleading uncertainty.

The interaction test addresses slope difference under the specified linear mean model. It is not a test of whether the groups differ at every follow-up time, nor does a non-significant result establish that their trajectories are identical. A confidence interval for \(\beta_3\) is useful for judging the range of plausible slope differences in the biomarker’s units per time unit.

Worked Example: Testing a Difference in Slopes

In a hypothetical analysis, the estimated treatment-by-time coefficient is 1.20 mg/L per month, with \(SE=0.50\) mg/L per month and \(df=58\). Test \(H_0:\beta_3=0\) against a two-sided alternative at \(\alpha=0.05\).

The test statistic is \[ t=\frac{1.20-0}{0.50}=2.40. \] For a two-sided \(t\) test with 58 degrees of freedom, the p-value is \(2P(T_{58}\ge 2.40)\approx0.01963\). Since \(0.01963<0.05\), reject \(H_0\) at the 5% significance level. Under the fitted linear model, the data provide evidence that the treatment and control mean slopes differ.

For context, an approximate 95% confidence interval uses \(t_{0.975,58}\approx2.002\): \[ 1.20\pm2.002(0.50)=1.20\pm1.001, \] or approximately \(0.199\) to \(2.201\) mg/L per month. The interval’s endpoints are plausible values for the treatment-minus-control slope difference under the model and method used. It does not give a 95% probability that the fixed parameter lies in this particular interval.

Why Time Coding Changes Coefficients but Not Trajectories

With baseline coded as \(t=0\), the treatment main-effect coefficient directly represents the baseline contrast. Sometimes it is useful to choose a different time origin, such as the midpoint of follow-up. This changes the interpretation of the intercept and treatment main effect, but does not change the fitted values or the difference in slopes.

To see why, let \(s=t-c\), so \(t=s+c\), where \(c\) is a chosen time point. Substituting into the mean model gives

$$ \begin{aligned} \beta_0+\beta_1(s+c)+\beta_2A+\beta_3A(s+c) &=(\beta_0+c\beta_1)+\beta_1s\\ &\quad+(\beta_2+c\beta_3)A+\beta_3As. \end{aligned} $$

The new intercept is the control fitted mean at time \(c\), and the new treatment main-effect coefficient is the treatment-minus-control contrast at time \(c\). The interaction remains \(\beta_3\): shifting the time origin cannot alter the difference between the two slopes.

Worked Example: Recenter Time at Three Months

Use the fitted trajectories from the first example, and define \(s=t-3\), so \(s=0\) represents month 3. Find the coefficients under this time coding and verify the group contrast at month 3.

The control intercept becomes \(\beta_0+3\beta_1=12+3(-0.30)=11.1\) mg/L. Its slope remains \(-0.30\) mg/L per month. The treatment main effect becomes \(\beta_2+3\beta_3=1.5+3(0.20)=2.1\) mg/L, the treatment-minus-control contrast at month 3. The interaction remains \(0.20\) mg/L per month.

The recentered model is therefore \(11.1-0.30s+2.1A+0.20As\). At \(s=0\), the control mean is 11.1 mg/L and the treatment mean is \(11.1+2.1=13.2\) mg/L. Using the original model at \(t=3\) gives control \(12-0.30(3)=11.1\) mg/L and treatment \(13.5-0.10(3)=13.2\) mg/L. The fitted means agree, while the treatment main effect now refers to month 3 rather than baseline.

Assumptions, Diagnostics, and Alternatives

Interpretation and inference depend on the model and data collection. In particular, time must be defined consistently, the treatment coding must match the comparison of interest, and a straight-line mean trajectory within each group must be a reasonable approximation over the analyzed follow-up. The interaction permits different linear slopes; it does not accommodate arbitrary curvature. For tests and intervals, the fitted analysis must also use a defensible covariance and standard-error method for repeated measurements, along with its stated distributional or large-sample conditions. A causal interpretation requires suitable study design and assumptions; an interaction in observational data alone establishes an adjusted association, not a treatment-caused difference in change.

Useful checks include plotting observed biomarker values against time separately by group and overlaying the fitted lines. Systematic curvature, such as residuals that tend to be positive in the middle of follow-up and negative at both ends, suggests that a straight-line trend may be inadequate. Inspect residual patterns by time and treatment group, influential observations, the distribution of visit times, and whether both groups have enough observations across the time range to support a comparison. Sparse or non-overlapping follow-up can make the fitted slope contrast depend heavily on extrapolation.

An additive model without the interaction imposes a common slope: the treatment-control contrast is constant over time. It may be appropriate when that restriction is scientifically defensible, but it cannot represent different linear rates of change. If the trajectory is curved, alternatives include categorical time with treatment-by-visit terms or a nonlinear time function with treatment interactions. These approaches allow more flexible patterns but require more parameters and enough data to estimate them. The appropriate choice depends on the scientific question, visit schedule, and observed trajectory—not simply on which model produces a smaller p-value.

Common pitfall: “The treatment coefficient is 1.5, so the treatment group is 1.5 mg/L higher at every follow-up.” This is incorrect when an interaction is in the model. With baseline as \(t=0\), the treatment coefficient is the contrast at baseline only; at time \(t\), the fitted contrast is \(\beta_2+\beta_3t\). Always combine the main effect and interaction at the time point of interest.

Check Your Understanding

Use the model and hypothetical values in each question. Solutions follow each question so that the calculations can be checked directly.

  1. A fitted model has \(\beta_1=-0.4\) and \(\beta_3=0.1\), with time in months. What are the control and treatment slopes?
    Solution: The control slope is \(\beta_1=-0.4\) units per month. The treatment slope is \(\beta_1+\beta_3=-0.4+0.1=-0.3\) units per month. Both fitted means decline, but the treatment slope is 0.1 units per month higher.
  2. Suppose \(\beta_2=2\) and \(\beta_3=-0.25\), with baseline coded \(t=0\). What is the fitted treatment-minus-control contrast at month 4?
    Solution: The contrast is \(\beta_2+4\beta_3=2+4(-0.25)=1\) biomarker unit.
  3. A time origin is shifted by \(c=2\) months. If the original coefficients are \(\beta_2=1.4\) and \(\beta_3=0.3\), what is the treatment main effect under the shifted coding?
    Solution: It is \(\beta_2+c\beta_3=1.4+2(0.3)=2.0\) units. This is the treatment-minus-control contrast at month 2; the interaction remains 0.3 units per month.
  4. A fitted interaction estimate is \(-0.8\) units per month. State its meaning without claiming a treatment effect at every time.
    Solution: Under the fitted linear mean model, the treatment group’s mean slope is 0.8 units per month lower than the control group’s mean slope. Whether this difference is statistically distinguishable from zero depends on its standard error and the inferential method.
Clinical Biostats