Tutorials › Marginal Structural Models › Specifying a Marginal Structural Cox Model

Fitting MSMs for Survival Outcomes · Tutorial 166 of 501

Specifying a Marginal Structural Cox Model

You will learn to express causal survival contrasts with treatment-history terms in a weighted Cox model, while identifying what the unspecified baseline hazard does—and does not—represent.

Advanced 10 min read

What You'll Learn

  • Define a marginal structural Cox model for counterfactual hazards under treatment regimes
  • Choose treatment-history features and a clear reference regime
  • Derive hazard ratios between histories from model coefficients
  • Distinguish treatment effects from the unspecified baseline hazard
  • Recognize assumptions, diagnostics, and common specification failures

What the Model Specifies

A Cox model for survival outcomes has two distinct parts: a baseline hazard that may vary freely over time, and a relative-hazard component described by treatment terms. In a marginal structural Cox model, the modeled hazards concern counterfactual survival under treatment regimes, rather than hazards conditional on a selected set of measured covariates. The weighted risk sets introduced in the earlier material on Risk Sets for Weighted Cox Estimation provide the estimation framework; this tutorial specifies the model those risk sets are intended to fit.

Let \(T^g\) be the counterfactual event time under treatment regime \(g\). A regime specifies treatment over follow-up; write its treatment history through time \(t\) as \(\bar a_g(t)\). The hazard under that regime is the instantaneous event rate among those who would still be event-free under it. A marginal structural Cox model relates that hazard to a chosen feature vector \(x_g(t)\) of the treatment history.

Definition: A marginal structural Cox model specifies, for each regime \(g\), $$ \lambda^g(t)=\lambda_0(t)\exp\{\beta^\mathsf{T}x_g(t)\}, \qquad t>0. $$ Here \(\lambda^g(t)\) is the counterfactual hazard under regime \(g\), \(\lambda_0(t)\) is an unspecified, nonnegative baseline hazard, \(x_g(t)\) is a specified vector of treatment-history features, and \(\beta\) is a vector of regression parameters. The baseline is the hazard at the feature value \(x_g(t)=0\), or a reference hazard induced by the chosen parameterization.

The model is “marginal” because it describes regime-specific hazards at the population level, not hazards conditional on the time-varying confounders used to construct treatment weights. A weighted Cox fit uses treatment and, where appropriate, censoring weights to estimate the specified treatment coefficients. The weights do not decide which causal contrasts the model represents: that is determined by \(x_g(t)\).

The causal interpretation requires the relevant identification conditions: consistency between observed outcomes and counterfactual outcomes under the received regime; sequential exchangeability of treatment, conditional on the measured past; positivity for the regimes being compared; and appropriate handling of censoring. In addition, the structural hazard model must be an adequate representation of the regime-specific hazards over the times and histories of interest. These conditions are not guaranteed by fitting a Cox model or by applying weights.

Choosing Treatment Terms and a Reference

The treatment terms should encode the histories or regimes whose hazards are to be compared. For a single binary treatment assigned at baseline, let \(a\in\{0,1\}\), choose \(x_a=a\), and write

$$ \lambda^a(t)=\lambda_0(t)\exp(\beta a). $$

The untreated regime is the reference because its feature equals zero. The coefficient \(\beta\) is the log hazard ratio for treatment versus no treatment. For longitudinal treatment, the feature vector can include selected components of the history, such as treatment at specified occasions. Each coefficient then describes a contrast holding the other included features fixed. This interpretation follows from the model’s algebra; it does not establish that the model is correctly specified.

A feature set must distinguish the histories of scientific interest. If two regimes have identical feature vectors at every time, the model assigns them the same hazard and cannot estimate a contrast between them. Conversely, a feature set that is needlessly large may demand more support from the weighted data than is available. State the history coding and reference explicitly before interpreting coefficients.

Worked Example: A Baseline Binary Treatment

Suppose \(A=1\) denotes a baseline treatment and \(A=0\) denotes no treatment. Specify \(x_A=A\), and suppose the fitted treatment coefficient is \(\hat\beta=-0.40\). The model is

$$ \lambda^A(t)=\lambda_0(t)\exp(-0.40A). $$

For the untreated regime, \(A=0\), so \(\lambda^0(t)=\lambda_0(t)\). For the treated regime, \(A=1\), so \(\lambda^1(t)=\lambda_0(t)\exp(-0.40)\). Therefore,

$$ \frac{\lambda^1(t)}{\lambda^0(t)} =\exp(-0.40) \approx 0.6703. $$

The model’s hazard ratio is about \(0.67\) at each time \(t\), provided the proportional-hazards specification is correct. For illustration, if \(\lambda_0(t)=0.08\) at a particular time, the model gives \(\lambda^0(t)=0.08\) and \(\lambda^1(t)=0.08(0.6703)=0.053624\), approximately \(0.0536\). The value \(0.08\) is not a treatment coefficient; it is the baseline hazard at that time.

Contrasts Between Treatment Histories

For any two regimes \(g\) and \(h\) with the same baseline hazard, division of their model hazards gives

$$ \frac{\lambda^g(t)}{\lambda^h(t)} =\exp\{\beta^\mathsf{T}[x_g(t)-x_h(t)]\}. $$

This relation is useful because it makes the contrast depend on the difference in feature vectors, not on the numerical value of the baseline hazard. If the feature difference changes with time while \(\beta\) is constant, the model can imply a time-varying contrast. If the difference is constant, the hazard ratio is constant over time.

Result: Under the stated marginal structural Cox model, the log hazard ratio comparing regimes \(g\) and \(h\) at time \(t\) is \(\beta^\mathsf{T}[x_g(t)-x_h(t)]\). Thus the model’s treatment contrast is determined by the feature difference between the two histories.

Proof. By definition, \(\lambda^g(t)=\lambda_0(t)\exp\{\beta^\mathsf{T}x_g(t)\}\) and \(\lambda^h(t)=\lambda_0(t)\exp\{\beta^\mathsf{T}x_h(t)\}\). At times where the baseline hazard is positive, division cancels the common baseline:

$$ \frac{\lambda^g(t)}{\lambda^h(t)} =\frac{\lambda_0(t)\exp\{\beta^\mathsf{T}x_g(t)\}} {\lambda_0(t)\exp\{\beta^\mathsf{T}x_h(t)\}} =\exp\{\beta^\mathsf{T}[x_g(t)-x_h(t)]\}. $$

Taking logarithms yields the stated log hazard ratio. If the baseline hazard is zero at a time, both modeled hazards are zero there, so their ratio is not defined at that instant; the log-contrast formula describes the relative-hazard parameterization wherever a hazard ratio is defined. \(\square\)

Worked Example: Two Treatment Decisions

Suppose treatment is recorded at two occasions, with history features \(x_g=(A_1,A_2)^\mathsf{T}\), where each \(A_j\) is zero or one. Consider the model

$$ \lambda^g(t)=\lambda_0(t)\exp(-0.30A_1-0.20A_2). $$

The four histories have these model-based hazard ratios relative to history \((0,0)\): \((0,0)\) has ratio \(1\); \((1,0)\) has ratio \(\exp(-0.30)\approx0.7408\); \((0,1)\) has ratio \(\exp(-0.20)\approx0.8187\); and \((1,1)\) has ratio \(\exp(-0.50)\approx0.6065\). Each calculation uses the coefficient-weighted feature vector, for example \(\exp[-0.30(1)-0.20(1)]=\exp(-0.50)\) for \((1,1)\).

To compare \((1,1)\) directly with \((1,0)\), the feature difference is \((0,1)^\mathsf{T}\). Hence the log hazard ratio is \(-0.30(0)-0.20(1)=-0.20\), and the hazard ratio is \(\exp(-0.20)\approx0.8187\). The first treatment feature cancels because both histories have \(A_1=1\).

Why the Baseline Is Unspecified

The baseline hazard is a time-varying nuisance function, not an additional treatment effect. It accommodates the event-rate pattern shared by all histories at the reference feature value. The model leaves that pattern unrestricted rather than assuming, for example, a constant hazard or a particular parametric survival distribution.

A common time-varying term cannot be separately identified as a treatment effect if it applies equally to every regime. To see why, suppose a proposed linear predictor contains a term \(c(t)\) that is identical for all regimes:

$$ \lambda^g(t)=\lambda_0(t)\exp\{c(t)+\beta^\mathsf{T}x_g(t)\} =\widetilde{\lambda}_0(t)\exp\{\beta^\mathsf{T}x_g(t)\}, \qquad \widetilde{\lambda}_0(t)=\lambda_0(t)\exp\{c(t)\}. $$

The same hazards result after absorbing \(c(t)\) into the baseline. Therefore, adding a common time-only term does not create an estimable treatment contrast. This is the structural reason that an intercept, or any other term shared by all histories at each time, is not separately interpreted in an ordinary Cox model with an unspecified baseline.

Worked Example: Categorical Treatment Regimes

Suppose the scientific question compares usual care, an intermittent-treatment policy, and a sustained-treatment policy. Let usual care be the reference and define two indicators \(I\) and \(S\) for the latter policies. Specify

$$ \lambda^g(t)=\lambda_0(t)\exp(\beta_I I_g+\beta_S S_g). $$

Take \(\hat\beta_I=-0.15\) and \(\hat\beta_S=-0.50\). The hazard ratios relative to usual care are \(1\), \(\exp(-0.15)\approx0.8607\), and \(\exp(-0.50)\approx0.6065\), respectively. The sustained-versus-intermittent contrast is \(\exp(\hat\beta_S-\hat\beta_I)=\exp(-0.35)\approx0.7047\). If \(\lambda_0(t)=0.06\) at a particular time, the three modeled hazards are \(0.06\), \(0.06(0.8607)\approx0.0516\), and \(0.06(0.6065)\approx0.0364\). The baseline sets the common reference scale; the indicator coefficients encode comparisons to the reference policy.

Specification Checks and Common Pitfalls

Before fitting, check that each intended contrast corresponds to a difference in the specified treatment features, that the reference is clear, and that the same baseline hazard is appropriate for the regimes being compared. After fitting, examine whether the weighted data provide meaningful representation of the histories and event times used by the model. Extremely large weights, sparse weighted risk sets, or histories represented by only a few individuals can make estimates unstable. These are warnings about the support and information in the analysis, not evidence that a different coefficient coding will repair the problem.

A key modeling assumption is proportionality of the specified contrasts: when \(x_g(t)-x_h(t)\) is constant, the hazard ratio between \(g\) and \(h\) is constant over time. If that is substantively implausible, the constant-coefficient model may not answer the intended question. More elaborate treatment terms can be considered, but a specification should not be expanded without a clear target contrast and adequate data support.

  • Mistake: treating the baseline as the untreated hazard automatically. It is the hazard at the reference feature value. That value is untreated only when the chosen coding makes untreated history the reference.
  • Mistake: interpreting a coefficient without its coding. A coefficient is a log hazard contrast for a one-unit change in its feature, holding other features fixed. State the histories represented by that change.
  • Mistake: adding a treatment-independent time term and calling it a treatment effect. A term common to all regimes is absorbed into the unspecified baseline and does not distinguish them.
  • Mistake: assuming weights guarantee a correct causal model. Weighting addresses measured treatment and censoring processes under its assumptions; it does not fix a misspecified treatment-history contrast or a misspecified proportional-hazards structure.

A conventional covariate-adjusted Cox model generally describes hazards conditional on its included covariates. A marginal structural Cox model instead targets regime-specific marginal hazards and uses weighting to address time-varying confounding under the identification assumptions. Separate unweighted Cox fits by treatment group do not, by themselves, create the weighted pseudo-population or identify the same causal contrasts. These approaches can answer different questions, so the estimand and conditioning set should be stated rather than inferred from the phrase “Cox model.”

The specification also has limitations. A hazard ratio is a comparison among individuals still event-free under the regimes at time \(t\); it is not a risk ratio or a direct comparison of survival probabilities. The model’s common-baseline structure and treatment terms can be wrong even when the weighting procedure is implemented correctly. In particular, failure of positivity or poor weighted support can leave a requested regime contrast weakly identified in the observed data.

Check Your Understanding

Answer each question, then compare with the solutions.

  1. For \(\lambda^a(t)=\lambda_0(t)\exp(\beta a)\), what is the hazard ratio for \(a=1\) versus \(a=0\)?
  2. A two-feature model has coefficient vector \((0.2,-0.4)^\mathsf{T}\). What is the modeled hazard ratio for feature vector \((1,1)^\mathsf{T}\) versus \((1,0)^\mathsf{T}\)?
  3. Why is a treatment-independent time function not separately interpreted as a treatment effect in this model?
  4. If two regimes have identical feature vectors at every time, what does the model imply about their hazards?
  5. Name one assumption needed for a causal interpretation that is not guaranteed merely by fitting a weighted Cox model.

Solutions. (1) The ratio is \(\exp(\beta)\), by cancellation of \(\lambda_0(t)\). (2) The feature difference is \((0,1)^\mathsf{T}\), so the log ratio is \(0.2(0)-0.4(1)=-0.4\), and the ratio is \(\exp(-0.4)\approx0.6703\). (3) It is common to every regime and can be absorbed into \(\lambda_0(t)\). (4) Their hazards are equal under the model because they have the same linear predictor and baseline. (5) Examples include consistency, sequential exchangeability, positivity, appropriate censoring handling, or correct specification of the structural hazard model.

Clinical Biostats