Why an End-to-End Analysis Needs More Than a Regression
With longitudinal treatment, a covariate measured after one treatment can predict the next treatment and the outcome, while also being affected by earlier treatment. Ordinary adjustment for that covariate can therefore change the causal contrast being estimated. Marginal structural models (MSMs) address this setting by weighting observations to account for measured treatment-confounder histories, then fitting a model for outcomes across treatment histories. If people can leave follow-up before the outcome is observed, censoring must be addressed as well.
This tutorial follows a hypothetical cohort with two treatment times and a continuous outcome measured at the end of follow-up. The goal is an end-to-end analysis for the mean outcome under each treatment history. The weights and model below are one coherent strategy, not a substitute for defining the target population, timing, and causal assumptions in the study protocol.
For a treatment-history-only MSM, the stabilized-weight numerators below depend on prior treatment, but not on \(V\). This detail matters: numerator probabilities that depend on baseline covariates can retain or induce baseline-covariate differences across treatment histories. Alternatively, an analysis could include \(V\) in the MSM and standardize fitted means to a specified population distribution of \(V\); that is not the model used here.
Assumptions and Weight Models
Before estimating weights, the analysis needs a clear time order: measure \(V\), then at each time measure \(L_t\), assign \(A_t\), and determine whether the participant remains observed. The following assumptions support a causal interpretation of the weighted estimates.
- Consistency: if a participant follows history \(\bar a\), their observed outcome equals \(Y^{\bar a}\).
- Sequential exchangeability for treatment: among participants still observed at time \(t\), treatment \(A_t\) is independent of future potential outcomes conditional on the measured history \(V,\bar L_t,\bar A_{t-1}\). Unmeasured confounding would violate this condition.
- Conditional independent censoring: given the measured covariate and treatment history, remaining uncensored is independent of the relevant future potential outcomes.
- Positivity: each treatment and remaining-observed probability required by the target histories is positive for the histories occurring in the target population.
- Correct probability models: the fitted treatment and censoring models adequately estimate the conditional probabilities used in the weights.
These are substantive and statistical conditions, not properties established simply by fitting logistic regressions. Diagnostics can reveal some problems, such as near-zero estimated probabilities or poor measured-covariate balance, but cannot verify exchangeability or rule out unmeasured confounding.
For binary treatment, one can estimate the treatment denominators with pooled logistic regressions, using the time-specific measured history to predict \(A_t\). The stabilized numerator model predicts \(A_t\) from \(\bar A_{t-1}\) only. For censoring, model the probability of remaining uncensored at each time among those uncensored at the start of that interval. The denominator includes measured covariates and treatment history; the numerator includes treatment history but not \(V\) or \(L_t\).
The numerator terms retain dependence on treatment history. Thus weighting aims to remove dependence of treatment on the time-varying covariates in the denominator, conditional on the history retained in the numerator; it does not make treatment independent of every measured predictor. Likewise, censoring weighting adjusts for measured predictors of remaining observed that appear in its denominator. The numerator choice is aligned with the treatment-history-only target model.
Worked Example: Constructing One Participant’s Cumulative Weight
Worked Example: Constructing One Participant’s Cumulative Weight
Suppose the fitted treatment and censoring models in a hypothetical cohort give the probabilities below for one participant who has \(A_1=1\), \(A_2=0\), and remains uncensored at both times. These values are illustrative model predictions, not observed study results.
At time 1, the numerator probability of \(A_1=1\) is \(0.50\), and the denominator probability given this participant’s measured history is \(0.40\). At time 2, conditional on \(A_1=1\), the numerator probability of \(A_2=0\) is \(0.60\), and the denominator probability is \(0.70\). Therefore,
For remaining uncensored, suppose the time-1 numerator and denominator probabilities are \(0.95\) and \(0.90\), respectively. At time 2, conditional on the treatment history, they are \(0.90\) and \(0.80\). Then
The combined weight is \(1.071\times1.188=1.272\), to three significant figures. This participant contributes about 1.27 times the influence of a weight-1 participant to the weighted estimating equation, subject to the chosen outcome model. The calculation assumes the fitted probabilities are valid and nonzero; a single finite weight does not establish that positivity or model specification is satisfactory.
From Probability Models to a Weighted Analysis
A useful justification for the product form is to consider one treatment time. Within a measured history, the observed treatment probability in the denominator is multiplied by the ratio of the numerator probability to that denominator. The resulting treatment probability is proportional to
The same cancellation applies successively across times, conditional on the history reached at each time. Censoring ratios analogously replace the measured-history-dependent probability of remaining observed with the numerator probability, conditional on treatment history. This explains the weighting construction: measured histories in the denominators are reweighted out, while the numerator histories remain. The argument depends on valid conditional probabilities and support; it does not by itself prove that the measured histories suffice for causal exchangeability.
After calculating weights for every eligible outcome record, fit the prespecified MSM by weighted estimating equations. For a continuous outcome and two binary treatments, a saturated treatment-history model is
“Saturated” here means that this model assigns a separate mean to each of the four treatment histories. For a binary outcome, a link appropriate to the target effect scale can be used instead; the link and interpretation must be stated before estimation. The weights alone do not determine the effect scale.
Worked Example: Checking the Weights and Balance
Worked Example: Checking the Weights and Balance
Suppose five hypothetical participants have final combined weights \(0.5, 0.8, 1.0, 1.2,\) and \(6.5\). Their sum is \(10.0\), and their squared weights sum to
The weight-based effective sample size is
Although there are five records, this weight concentration corresponds to an effective sample size of about 2.19. The value is a diagnostic summary, not a literal count of independent participants or a replacement for robust uncertainty estimation. The largest weight, \(6.5\), should prompt examination of the fitted probability models, the relevant covariate histories, and empirical support for the histories represented by that record.
Balance should also be examined after weighting. For illustration, suppose a time-varying confounder has weighted means \(4.8\) and \(4.7\) in two treatment groups being compared, with pooled standard deviation \(2.0\). The standardized mean difference is
This small difference suggests good balance for that measured covariate in this particular comparison. In a longitudinal analysis, balance checks should reflect the relevant time and prior-treatment strata, and should cover important measured denominator covariates rather than only one variable. A small standardized difference is reassuring for measured balance, but it cannot establish exchangeability or correct model specification.
Inspect the distribution of treatment, censoring, and combined weights, including upper quantiles and maxima, and calculate effective sample size. Review estimated probabilities near zero, histories with little or no support, and weighted covariate balance. If weights are truncated, report the truncation rule and assess how conclusions change; truncation trades reduced instability for potential bias. It does not repair a structural positivity violation.
Worked Example: Fitting the MSM and Reporting a Contrast
Worked Example: Fitting the MSM and Reporting a Contrast
Suppose a hypothetical weighted analysis of a continuous outcome measured in points produces the following sums of weights and weighted outcome sums among participants observed at the final time. These are summaries of a larger cohort; they are not raw sample sizes.
| Treatment history \((A_1,A_2)\) | Sum of weights | Weighted outcome sum | Weighted mean |
|---|---|---|---|
| (0, 0) | 100 | 1,200 | 12 |
| (1, 0) | 80 | 800 | 10 |
| (0, 1) | 75 | 675 | 9 |
| (1, 1) | 60 | 360 | 6 |
For history \((1,1)\), for example, the weighted mean is \(360/60=6\) points. The other cell means are \(12,10,\) and \(9\) points. In the saturated model, the estimated intercept is the \((0,0)\) mean, \(\hat\beta_0=12\). The two single-treatment coefficients are
The interaction coefficient makes the fitted mean for \((1,1)\) equal 6:
Thus the estimated mean difference for sustained treatment \((1,1)\) versus no treatment \((0,0)\) is \(\hat\beta_1+\hat\beta_2+\hat\beta_{12}=-6\) points. Under the assumptions stated above and the specified target population, the estimate says the mean outcome under \((1,1)\) is 6 points lower than under \((0,0)\). It is not a claim that every participant’s outcome would be 6 points lower.
Use a robust sandwich covariance estimator for the weighted estimating equations, with clustering at the participant level when the analysis data contain repeated rows per participant. Suppose the robust covariance submatrix for \((\hat\beta_1,\hat\beta_2,\hat\beta_{12})\) has diagonal entries \(0.64,0.81,0.49\), and off-diagonal entries \(0.05,0.02,0.01\). For contrast vector \(c=(1,1,1)\), the estimated variance is
The robust standard error is \(\sqrt{2.10}=1.449\) points. Using a normal approximation, the 95% confidence interval is
This interval is a range of values compatible with the data and the fitted analysis under repeated-sampling assumptions; it is not a 95% probability statement about this fixed contrast. The interval excludes zero, indicating evidence against a zero mean contrast at the conventional two-sided 5% level, conditional on the model and causal assumptions. Robust standard errors address specified forms of variance misspecification and within-participant dependence; they do not correct confounding, positivity violations, or incorrect weights.
Common Pitfall: Treating Stabilization as a Causal Guarantee
A common mistake is to assume that any stabilized weights make treatment independent of all measured covariates, then fit a treatment-only outcome model. That conclusion does not follow when numerator probabilities retain baseline covariates. In the analysis here, the treatment and censoring numerators depend on prior treatment history but not on \(V\); the denominators include \(V\) and time-varying covariates needed for adjustment. This numerator choice is paired with a treatment-history-only MSM. A different numerator specification may require including baseline covariates in the MSM and standardizing its predictions over the target distribution.
A second mistake is to interpret a weighted regression coefficient as causal merely because its standard error is robust. The causal interpretation requires consistency, sequential exchangeability, positivity, adequate probability models, and a correctly specified or sufficiently flexible MSM for the target contrast. Report the numerator and denominator histories, the weight diagnostics, the outcome-model scale, the robust variance method, and the target treatment histories so that the analysis can be evaluated as a whole.
Check Your Understanding
Use these questions to check both the calculations and the reasoning behind the analysis.
- Why do the numerator probabilities for the treatment-history-only MSM described here omit baseline \(V\), even though \(V\) appears in the treatment denominators?
- A participant’s treatment weight factors are \(0.8/0.5\) and \(0.7/0.9\). Calculate the cumulative treatment weight to three significant figures.
- What does an effective sample size much smaller than the observed cohort size suggest, and what does it not establish?
- For the saturated MSM, how would you calculate the mean contrast for history \((1,0)\) versus \((0,0)\)?
- Name two causal assumptions that cannot be confirmed merely by observing acceptable weight distributions and post-weighting balance.