Tutorials › Marginal Structural Models › Modeling Treatment Initiation and Duration

Fitting MSMs for Survival Outcomes · Tutorial 175 of 501

Modeling Treatment Initiation and Duration

Represent treatment initiation and duration in a weighted Cox model, then translate its coefficients into hazard contrasts for newly initiated and sustained treatment.

Advanced 12 min read

What You'll Learn

  • Define treatment initiation and elapsed duration on survival follow-up time
  • Encode initiation and duration jointly in a weighted Cox model
  • Derive hazard contrasts for newly initiated and sustained treatment
  • Compare duration coding with an ever-treated indicator
  • Diagnose timing, coding, and positivity problems in fitted models
  • State the assumptions needed for a causal interpretation

Why Initiation and Duration Need Separate Terms

A Cox model with a single indicator for whether treatment has ever begun makes a strong assumption: at any given follow-up time, the hazard ratio for treated versus untreated is the same whether treatment began just now or long ago. That may be implausible when treatment effects take time to develop, accumulate, or wane. A treatment-history model can distinguish the effect associated with starting treatment from the additional contrast associated with time since initiation.

The distinction is about the treatment history represented in the outcome model, not about changing the weighting procedure. In a weighted marginal structural Cox model, the treatment and censoring weights address measured time-varying confounding and censoring under their usual assumptions. The model terms then specify how the hazard is allowed to differ across the weighted treatment histories.

Define Initiation and Duration on the Risk-Time Scale

Consider a setting in which each person is untreated until treatment starts and, once started, remains on treatment. Let \(S_i\) be person \(i\)'s treatment initiation time, with \(S_i=\infty\) for someone who never initiates during follow-up. At survival time \(t\), define \(Z_i(t)=I(S_i\leq t)\), the indicator that treatment has begun. For a treated person, define elapsed time since initiation as \(D_i(t)=t-S_i\). The duration term will always be multiplied by \(Z_i(t)\), so its value for someone untreated is immaterial.

Definition: In the initiation-and-sustained-treatment setting, \(Z_i(t)\) indicates whether treatment has started by time \(t\), and \(D_i(t)\) is time elapsed since the start for a treated person. An initiation term represents the contrast at treatment start; a duration term represents how that contrast changes as time on treatment increases.

For person-period data, the same definitions must follow the interval convention used to construct the survival records. If an interval is \([t_k,t_{k+1})\), treatment initiated at \(t_k\) applies during that interval, and elapsed duration is measured from \(t_k\). A treatment start recorded after an event interval must not be used to describe treatment during that interval. The event-time and treatment-time alignment established in the earlier material on survival person-periods is essential here.

A Weighted Cox Model With an Initiation and Duration Term

One simple specification uses elapsed duration itself. Let \(g\) be a chosen duration function satisfying \(g(0)=0\); the simplest choice is \(g(d)=d\). The weighted marginal structural Cox model is

$$ \lambda_i(t)=\lambda_0(t)\exp\left\{\beta_I Z_i(t)+\beta_D Z_i(t)g\bigl(D_i(t)\bigr)\right\}. $$

Here \(\lambda_0(t)\) is the baseline hazard, \(\beta_I\) is the initiation coefficient, and \(\beta_D\) describes the change in log hazard associated with duration according to \(g\). The model is fitted with the treatment and, where appropriate, censoring weights for the relevant risk sets. In this specification, \(g(0)=0\) makes the initiation coefficient directly interpretable as the log hazard contrast at duration zero. If duration is measured in years, for example, the linear choice \(g(d)=d\) makes \(\beta_D\) a log-hazard change per year since initiation.

A causal interpretation requires the usual conditions for the weighted survival MSM: consistency; no interference; sequential exchangeability for treatment and censoring given the measured history used to construct the weights; positivity of the treatment and censoring probabilities for the histories being compared; and correctly specified weight models. The outcome model must also be correctly specified for the intended contrasts. These conditions do not turn a conditional hazard ratio into a risk ratio, nor do they remove the need to state which treatment histories are being contrasted.

Worked Example: Assigning Initiation and Duration to Intervals

Suppose a person is untreated through time 4 and initiates treatment at time 4. The event records use intervals \([0,2)\), \([2,4)\), and \([4,6)\). Take \(g(d)=d\). Determine the treatment and duration covariates used in each interval.

In \([0,2)\), treatment has not begun, so \(Z_i(t)=0\). The duration contribution is zero because it is multiplied by \(Z_i(t)\).

In \([2,4)\), the person is still untreated: \(Z_i(t)=0\), and again the duration contribution is zero.

In \([4,6)\), treatment has begun at the left endpoint. At the start of this interval, duration is \(D_i(4)=4-4=0\). Thus \(Z_i(4)=1\), while \(Z_i(4)g(D_i(4))=1\cdot 0=0\). At time 5, the corresponding duration contribution is \(1\cdot g(1)=1\). The covariates therefore describe newly initiated treatment at time 4 and one unit of treatment duration at time 5, rather than assigning treatment retrospectively to either untreated interval.

Deriving the Treatment-History Contrasts

The model's interpretation follows directly from comparing its linear predictors at the same follow-up time. For someone who has not initiated treatment by \(t\), both treatment terms are zero, so the hazard is \(\lambda_0(t)\). For someone who initiates at \(t\), duration is zero and \(g(0)=0\), giving hazard \(\lambda_0(t)\exp(\beta_I)\). For someone treated for duration \(d\), the hazard is \(\lambda_0(t)\exp\{\beta_I+\beta_Dg(d)\}\).

Result: Under the stated model, the hazard ratio for newly initiated treatment versus no treatment at the same time is \(\exp(\beta_I)\). For treatment duration \(d\) versus no treatment, it is \(\exp\{\beta_I+\beta_Dg(d)\}\). For duration \(d\) versus newly initiated treatment, it is \(\exp\{\beta_Dg(d)\}\).

To verify these contrasts, write the model hazard for no initiation as \(\lambda_0(t)\). At initiation, substitute \(Z=1\) and \(D=0\): the hazard is \(\lambda_0(t)\exp\{\beta_I+\beta_Dg(0)\}=\lambda_0(t)\exp(\beta_I)\). Dividing by the untreated hazard gives \(\exp(\beta_I)\). At duration \(d\), dividing \(\lambda_0(t)\exp\{\beta_I+\beta_Dg(d)\}\) by the untreated hazard gives \(\exp\{\beta_I+\beta_Dg(d)\}\); dividing it instead by the newly initiated hazard cancels \(\lambda_0(t)\exp(\beta_I)\), leaving \(\exp\{\beta_Dg(d)\}\). These are model-implied hazard contrasts for the specified histories, at the same follow-up time.

The contrast is not necessarily a comparison of people with the same observed covariates in an ordinary outcome regression. In the MSM, the weights construct a pseudo-population in which the measured confounding addressed by the weights is controlled, subject to the assumptions above. The hazard is still defined among those alive and at risk under the histories being contrasted.

Worked Example: Interpreting Initiation and Sustained Treatment

Suppose a weighted Cox fit uses \(g(d)=d\), with duration measured in years, and estimates \(\hat{\beta}_I=-0.20\) and \(\hat{\beta}_D=-0.10\). Calculate the three hazard contrasts at duration 0, 2, and 5 years.

At initiation, the hazard ratio versus no treatment is \(\exp(-0.20)\approx 0.819\). This is an estimated 18.1% lower hazard at the moment of initiation under the model.

After 2 years, the log hazard ratio versus no treatment is \(-0.20+(-0.10)(2)=-0.40\), so the hazard ratio is \(\exp(-0.40)\approx 0.670\). The duration-2 versus newly initiated contrast is \(\exp\{(-0.10)(2)\}=\exp(-0.20)\approx 0.819\).

After 5 years, the log hazard ratio versus no treatment is \(-0.20+(-0.10)(5)=-0.70\), giving \(\exp(-0.70)\approx 0.497\). The duration-5 versus newly initiated contrast is \(\exp(-0.50)\approx 0.607\). Thus, under this fitted linear-duration model, the hazard contrast becomes more protective as duration increases. That is a model-based association for specified treatment histories; it is not proof that treatment has a progressively stronger biological effect.

What a Single Ever-Treated Term Assumes

A model with only \(\beta_I Z_i(t)\) is nested within the initiation-and-duration model by setting \(\beta_D=0\). This restriction can be stated and checked algebraically: the hazard for a treated person is \(\lambda_0(t)\exp(\beta_I)\), regardless of duration, while the untreated hazard is \(\lambda_0(t)\). Therefore every treated-versus-untreated hazard ratio equals \(\exp(\beta_I)\), whether treatment began just now or years earlier. Conversely, if \(\beta_D\ne 0\) and \(g(d)\) varies over treated durations, the model allows those contrasts to differ. The ever-treated model is not merely a shorter description; it imposes duration invariance.

A direct alternative is to represent duration with categories. For example, one could distinguish untreated, newly initiated, and sustained treatment. If their log hazard contributions relative to untreated are \(\gamma_N\) and \(\gamma_S\), the newly initiated versus untreated hazard ratio is \(\exp(\gamma_N)\), the sustained versus untreated ratio is \(\exp(\gamma_S)\), and sustained versus newly initiated is \(\exp(\gamma_S-\gamma_N)\). This coding avoids a linear change per unit duration but depends on the chosen categories and may use data less efficiently. The linear-duration model instead imposes a constant change in log hazard per unit duration. Neither coding is universally correct; each encodes a different outcome-model assumption.

Worked Example: Contrasts From Duration Categories

Suppose a model uses untreated treatment history as the reference, with log hazard contributions \(\hat{\gamma}_N=-0.15\) for newly initiated treatment and \(\hat{\gamma}_S=-0.45\) for sustained treatment. Calculate each contrast.

Newly initiated versus untreated has log hazard contrast \(-0.15\), so the hazard ratio is \(\exp(-0.15)\approx 0.861\). Sustained versus untreated has log contrast \(-0.45\), so the ratio is \(\exp(-0.45)\approx 0.638\).

For sustained versus newly initiated treatment, subtract the two log contributions: \(-0.45-(-0.15)=-0.30\). The hazard ratio is \(\exp(-0.30)\approx 0.741\). Equivalently, \(0.638/0.861\approx 0.741\), up to rounding. This contrast is not \(\exp(\hat{\gamma}_S)\), because that coefficient compares sustained treatment with the untreated reference, not with newly initiated treatment.

Diagnostics, Failure Modes, and Limits

Before interpreting coefficients, check that the time origin, treatment start, and interval boundaries use one consistent convention. Tabulate treatment status and duration over intervals, and verify that durations begin at zero at initiation and increase only after it. A start recorded in the wrong interval can create an apparent initiation effect even when the underlying data are otherwise correct.

Check the distribution of weighted person-time and events across duration values. If few people remain at risk at long durations, the sustained-treatment contrast may be driven by a small, highly weighted subset. Inspect the weight distribution and effective support within treatment histories; positivity problems can make estimated long-duration contrasts unstable. Large changes in estimates across reasonable weight truncation choices are a warning that the data offer limited information, not a reason to select the most favorable estimate.

The linear-duration form assumes a constant change in log hazard per unit of duration. A sharply changing or non-monotone relationship would violate that restriction; residual patterns and comparisons with defensible alternatives can reveal lack of fit. Choosing more elaborate duration functions is a separate modeling decision. Also, this tutorial's coding assumes treatment is sustained after initiation. If people discontinue or restart, “time since first initiation” does not equal time currently treated; the treatment history must be encoded to match the intervention and question.

  • Common mistake: interpreting \(\beta_D\) as the treated-versus-untreated effect. It is the duration-related change on the log-hazard scale. The treated-versus-untreated contrast at duration \(d\) is \(\exp\{\beta_I+\beta_Dg(d)\}\).
  • Common mistake: using duration without an initiation term. A duration-only term with value zero at initiation would assign no treatment contrast to a newly initiated person. Include the initiation term when a distinct initiation contrast is intended.
  • Common mistake: counting untreated time as duration zero without keeping treatment status. Untreated people and newly treated people can both have a zero duration contribution, but \(Z_i(t)\) distinguishes them in the model.
  • Common mistake: treating a duration association as a randomized comparison. Its causal interpretation still depends on identification assumptions, correct weights, and the specified marginal structural model.

Compared with a single ever-treated indicator, an initiation-and-duration model allows the treatment-history contrast to change after treatment starts. Compared with separate regime-specific survival curves, it summarizes contrasts through a parametric hazard model. Its limitations follow from that compression: incorrect duration form, inadequate weighted support, or misspecified treatment timing can distort the summary, and a hazard ratio is not itself a survival-probability contrast.

Check Your Understanding

Work each problem before reading its solution.

  1. For the model with \(g(d)=d\), what is the hazard ratio for duration 3 versus untreated?
  2. Suppose the initiation and duration coefficients are \(0.1\) and \(-0.2\), respectively, with \(g(d)=d\). What is the duration-2 versus newly initiated hazard ratio?
  3. Why can an untreated person and a newly initiated person both have a zero duration contribution without being coded identically?
  4. Name one data diagnostic and one modeling assumption relevant to sustained-treatment contrasts.

Solutions. (1) The log contrast is \(\beta_I+3\beta_D\), so the hazard ratio is \(\exp(\beta_I+3\beta_D)\). (2) Divide the duration-2 hazard by the newly initiated hazard: \(\exp\{\beta_D(2)\}=\exp(-0.4)\approx0.670\). (3) The duration term is multiplied by \(Z_i(t)\); the initiation indicator is zero for the untreated person and one for the newly initiated person, whose initiation contrast is \(\exp(\beta_I)\). (4) A diagnostic is checking weighted event support across durations or verifying that duration resets to zero at initiation. One modeling assumption is that the chosen duration form correctly represents how log hazard contrasts vary with time since initiation.

Clinical Biostats