Why Let the Treatment Effect Change Over Time?
A single treatment-effect coefficient can be inadequate when the effect of a treatment history changes over follow-up. An intervention might improve an outcome soon after treatment begins, have little effect later, or produce an effect that grows gradually. A marginal structural model (MSM) can represent this pattern by including treatment-by-time terms and then comparing predicted outcomes under specified treatment histories at each time.
The key is to distinguish the model’s coefficients from the time-specific contrasts of interest. With a treatment-by-time interaction, the treatment coefficient alone generally describes an effect only at the time used as the reference. To describe how the contrast evolves, calculate the predicted marginal outcome under each history at each time and compare those predictions on the chosen effect scale.
Models With Treatment-by-Time Terms
First consider a binary treatment-history contrast: \(\bar a=1\) denotes one prespecified history, such as sustained treatment, and \(\bar a=0\) denotes a reference history, such as sustained no treatment. These labels refer to histories, not necessarily to treatment received at a single visit. Let \(m(\bar a,t)=E(Y_t^{\bar a})\) be the marginal mean under that history at time \(t\). With an identity link and a linear time trend, one possible MSM is:
For the reference history, the predicted mean is \(\beta_0+\beta_t t\). For the treated history, it is \(\beta_0+\beta_t t+\beta_a+\beta_{at}t\). Subtracting the reference prediction from the treated prediction gives:
Thus, \(\beta_a\) is the mean difference at \(t=0\), and \(\beta_{at}\) is the change in that difference for each one-unit increase in time. Neither coefficient alone is the treatment contrast at every time. If \(t=0\) is not a meaningful or observed time, centering time at a meaningful visit makes the treatment coefficient refer to that visit instead.
A linear time trend is economical, but it imposes a straight-line pattern on the marginal means and on their difference. When the shape over follow-up is uncertain, time can be represented by visit indicators or by a nonlinear basis. For example, let \(I(t=j)\) indicate visit \(j\), with visit 1 as the reference. A model with a separate treatment term for each visit allows the treatment-history contrast to differ freely across those visits. A quadratic time function allows curvature, while spline functions can represent more flexible smooth patterns.
Worked Example: A Linear Change in a Mean Difference
Worked Example: A Linear Change in a Mean Difference
Suppose a fitted weighted MSM for a continuous symptom score, measured in points, is \(m(\bar a,t)=50+2t-4\bar a+3\bar a t\), where \(t\) is years since the start of follow-up. The histories are sustained treatment (\(\bar a=1\)) and sustained no treatment (\(\bar a=0\)). Assume the target is the marginal mean symptom score under each history at the listed times, and that this linear specification is being used over the follow-up range.
At year 0, the predictions are \(m(0,0)=50\) points and \(m(1,0)=50-4=46\) points. The treated-history minus reference-history contrast is \(46-50=-4\) points.
At year 1, the predictions are \(m(0,1)=50+2=52\) points and \(m(1,1)=50+2-4+3=51\) points. The contrast is \(51-52=-1\) point.
At year 2, the predictions are \(m(0,2)=50+4=54\) points and \(m(1,2)=50+4-4+6=56\) points. The contrast is \(56-54=2\) points.
The same result follows directly from the interaction formula: \(m(1,t)-m(0,t)=-4+3t\). It gives \(-4\), \(-1\), and \(2\) points at years 0, 1, and 2, respectively. Under this model, the estimated marginal mean difference changes by 3 points per year. Whether these differences are beneficial depends on the score’s direction; the arithmetic alone does not establish clinical importance.
Predictions When the Link Is Nonlinear
For a nonlinear link, an interaction coefficient describes change on the link scale, not automatically on the outcome scale. For a binary outcome, an MSM with a logit link can be written as \(\operatorname{logit}\{P(Y_t^{\bar a}=1)\}=\alpha_t+\delta_t\bar a\), where \(\alpha_t\) is the reference-history log odds at time \(t\), and \(\delta_t\) is the treatment-history contrast in log odds at that time. Here \(\operatorname{logit}(p)=\log\{p/(1-p)\}\). The odds ratio at time \(t\) is \(\exp(\delta_t)\). To report a risk difference, first convert each predicted logit to a probability, then subtract the probabilities.
If visit is represented by indicators, \(\alpha_t\) and \(\delta_t\) can vary across visits. This avoids forcing a linear change in log odds, but requires estimating more time-specific parameters. In either case, the fitted marginal predictions—not an interaction coefficient by itself—are the direct route to time-specific risk contrasts.
Worked Example: From Time-Specific Logits to Risk Differences
Consider a hypothetical fitted logistic MSM for an adverse binary outcome. At visits 1, 2, and 3, suppose the reference-history logits are \(-1.8\), \(-1.2\), and \(-0.7\), and the corresponding treatment-history log-odds contrasts are \(0.4\), \(0.1\), and \(-0.3\). These numbers define separate predictions at each visit; the treatment-history contrast is not constrained to be constant over time.
At visit 1, the reference-history risk is \(1/(1+e^{1.8})\), approximately \(0.1419\). The treated-history logit is \(-1.8+0.4=-1.4\), giving risk \(1/(1+e^{1.4})\), approximately \(0.1978\). Using the unrounded fitted risks, the treated-minus-reference risk difference is approximately \(0.055965\), which rounds to 0.0560, or 5.60 percentage points. The odds ratio is \(e^{0.4}\approx1.492\).
At visit 2, the reference-history risk is \(1/(1+e^{1.2})\approx0.2315\). The treated-history logit is \(-1.2+0.1=-1.1\), giving risk \(1/(1+e^{1.1})\approx0.2497\). The risk difference, calculated from the unrounded probabilities, is approximately \(0.0183\), or 1.83 percentage points; the odds ratio is \(e^{0.1}\approx1.105\).
At visit 3, the reference-history risk is \(1/(1+e^{0.7})\approx0.3318\). The treated-history logit is \(-0.7-0.3=-1.0\), giving risk \(1/(1+e^{1.0})\approx0.2689\). The risk difference is approximately \(0.2689-0.3318=-0.0629\), or \(-6.29\) percentage points, and the odds ratio is \(e^{-0.3}\approx0.7408\).
The fitted odds contrast moves from positive to negative across visits, and the predicted risk difference also changes direction. The risk differences are not equal to the log-odds coefficients: they are obtained by applying the inverse-logit transformation to both histories’ predictions and then subtracting. These are model-based marginal contrasts for the specified histories and visits, not claims that an individual’s outcome changes by the same amount.
Flexible Time Functions and Their Contrasts
Categorical time is useful when the number of follow-up visits is modest and there is little reason to impose a particular trajectory. A more compact alternative uses a basis of time functions. Suppose \(f_1(t),\ldots,f_K(t)\) are chosen functions, such as \(t\), \(t^2\), or spline basis functions. With an identity link, a model can be written:
The treatment-history contrast is then \(\beta_a+\sum_{k=1}^{K}\gamma_k f_k(t)\). Under a logit link, the same linear predictor structure gives the contrast on the log-odds scale; response-scale risks still require inverse-logit predictions. The choice of basis determines which patterns the model can represent. More flexibility can reduce the risk of imposing an unrealistic shape, but usually requires more parameters and can produce imprecise or unstable predictions when data are sparse at some times.
Worked Example: A Curved Time-Varying Mean Difference
Suppose a hypothetical identity-link MSM for a continuous functional score, in points, is \(m(\bar a,t)=40+2t-0.2t^2+\bar a(-2+1.5t-0.25t^2)\), where \(t\) is years since baseline. The squared term allows curvature in both the reference trajectory and the treatment-history contrast. Assume the model is intended for \(t=0,1,2\) years.
At baseline, \(m(0,0)=40\) points and \(m(1,0)=40-2=38\) points, so the contrast is \(-2\) points.
At year 1, the reference prediction is \(40+2-0.2=41.8\) points. The contrast is \(-2+1.5-0.25=-0.75\) point, so the treated-history prediction is \(41.8-0.75=41.05\) points.
At year 2, the reference prediction is \(40+4-0.2(4)=43.2\) points. The contrast is \(-2+1.5(2)-0.25(4)=0\) points, so the treated-history prediction is also \(43.2\) points.
This model implies a curved treatment-history contrast: it moves from \(-2\) points at baseline to \(-0.75\) point at year 1 and 0 points at year 2. The polynomial form is an assumption about the pattern, not a discovery guaranteed by including squared terms. Predictions should be interpreted only over the time range for which the model is being used, rather than extrapolated automatically beyond it.
How to Report an Evolving Contrast
A clear report states the histories being compared, the outcome scale, the follow-up times, and the time-specific predicted outcomes or contrasts. For example, report a mean difference in score points, a risk difference in percentage points, or an odds ratio. With a nonlinear link, be explicit about whether a number is on the link scale or the outcome scale. Reporting only the treatment main-effect coefficient can be misleading when the model contains treatment-by-time terms.
The causal interpretation also depends on the conditions that support the MSM, not just on its algebra. In the longitudinal setting, the treatment histories must be well defined, consistency must connect observed outcomes to the corresponding potential outcomes, sequential exchangeability must hold given the measured histories, and treatment positivity must hold for the histories being compared. If censoring can prevent outcome observation, censoring must also be handled appropriately. The model form must adequately represent the marginal outcomes or contrasts being reported. Weighting is used to estimate the MSM under the relevant assumptions; a time interaction does not itself establish those assumptions.
Specify the treatment histories, outcome, follow-up times, and effect scale to be compared.
Use visit indicators for visit-specific flexibility, or a stated time basis when a structured trajectory is appropriate.
Allow the history contrast to vary over time on the model’s link scale.
Predict under each history at each time, transform to the outcome scale if needed, and form the requested contrast.
Common Mistake: Reading the Main Effect as the Whole Story
A common error is to report the treatment coefficient as “the treatment effect” at every visit even though the model contains a treatment-by-time interaction. In the linear model \(m(\bar a,t)=\beta_0+\beta_t t+\beta_a\bar a+\beta_{at}\bar a t\), the contrast is \(\beta_a+\beta_{at}t\), so \(\beta_a\) is only the contrast at \(t=0\). In a logistic model, even the time-specific log-odds contrast must be transformed through both predicted logits before it becomes a risk difference. Calculate the history-specific predictions first, then report the contrast on the intended scale.
Check Your Understanding
Use the model scale and the specified treatment histories when answering.
- For an identity-link MSM \(m(\bar a,t)=30+t+2\bar a-0.5\bar a t\), what is the treated-minus-reference mean difference at times 0 and 4?
- Why does a treatment main-effect coefficient not generally represent the contrast at all times when the model includes a treatment-by-time interaction?
- In a logistic MSM with a treatment-by-time interaction, what additional calculation is needed to report a risk difference rather than a log-odds contrast?
- Give one advantage and one limitation of representing follow-up time with visit indicators rather than a linear time trend.
- What assumptions, beyond the presence of an interaction term, are needed for a fitted MSM contrast to have a causal interpretation?