Why Treatment-History Encoding Matters
A weighted Cox marginal structural model (MSM) uses treatment weights to estimate a marginal hazard model, but the model still needs a precise description of how treatment history enters the hazard. A coefficient for “treatment” is not self-interpreting: it may describe treatment during the current interval, treatment one interval earlier, or a contrast in accumulated exposure. Those choices imply different comparisons, even when the same weighted risk sets and estimation method are used.
Let follow-up be divided into intervals \(k=1,\ldots,K\). Let \(A_k\in\{0,1\}\) denote treatment assigned before interval \(k\), and let \(T\) denote event time. A history through interval \(k\) is \(\bar A_k=(A_1,\ldots,A_k)\). We compare encodings in which the hazard during interval \(k\) depends on the current value, a lagged value, or the count of treated intervals up to and including \(k\). The treatment weights are assumed to have been constructed for the relevant histories; the focus here is how those histories are represented in the outcome model.
Three Encodings and Their Meanings
For clarity, suppose the baseline hazard is common across treatment histories and use a constant coefficient for each displayed term. These are alternative models, not a prescription to include all terms at once:
In the first model, \(\exp(\alpha)\) is the hazard ratio for treatment versus no treatment in the current interval, at a given interval time, under this current-treatment model. It does not represent a comparison of complete treatment regimes unless the regimes differ only in the current value and the model is adequate for the relevant histories. In the second, \(\exp(\gamma)\) compares histories that differ in the immediately preceding interval’s treatment, with the same current treatment. The lagged term is undefined at the first interval unless an initial value is specified; one common convention is to omit it from interval 1 and define the model for \(k\geq2\).
In the third model, \(\exp(\beta)\) is the hazard ratio associated with one additional treated interval in the history through \(k\), holding the rest of the model fixed. Because \(C_k\) includes \(A_k\), it is not a “past exposure only” term. A cumulative count treats every treated interval as contributing equally on the log-hazard scale; it does not distinguish whether exposure occurred early or recently.
Worked Example: Computing the Three Encodings
Consider histories through interval 4: \(H^{(1)}=(1,0,0,0)\), \(H^{(2)}=(0,0,0,1)\), and \(H^{(3)}=(1,1,1,1)\). At interval 4, the current values are respectively \(0,1,1\), the lagged values are \(0,0,1\), and the cumulative counts are \(1,1,4\).
For \(H^{(1)}\) versus \(H^{(2)}\), the current-treatment model gives linear predictors \(0\) and \(\alpha\), so its hazard ratio is \(\exp(\alpha)\). The lagged model gives \(0\) for both histories, so it predicts a ratio of \(1\). The cumulative model gives \(\beta\) for both, also predicting a ratio of \(1\). Thus the current model distinguishes these histories at interval 4, while the other two do not.
For \(H^{(2)}\) versus \(H^{(3)}\), the current model again predicts a ratio of \(1\), since both are treated in interval 4. The lagged model predicts \(\exp(\gamma)\), since the lagged values are 0 and 1. The cumulative model predicts \(\exp(4\beta-\beta)=\exp(3\beta)\). The same pair of histories therefore gives three different model-based contrasts.
Joint Terms and Identifiability
Sometimes a scientific question calls for separate current and lagged associations. A model can include both, for example \(\lambda(t\mid\bar A_k)=\lambda_0(t)\exp(\alpha A_k+\gamma A_{k-1})\) for \(k\geq2\). Here \(\exp(\alpha)\) compares current treatment values at fixed lagged treatment, while \(\exp(\gamma)\) compares lagged values at fixed current treatment. These conditional contrasts require adequate weighted support for the combinations being compared.
The following result makes an important identification problem explicit.
Proof. Under the stated condition, substitute \(A_{k-1}=A_k\) into the linear predictor:
Thus any pair \((\alpha,\gamma)\) with the same sum produces the same linear predictor for every observed interval and, consequently, the same model-based hazards and weighted Cox partial likelihood. For any real number \(c\), the pair \((\alpha+c,\gamma-c)\) has the same sum as \((\alpha,\gamma)\). The data therefore cannot distinguish the separate coefficients. This is a lack of identification, not a numerical optimization problem that can be fixed by changing the optimizer. \(\square\)
More generally, separate effects need variation in the relevant treatment-history patterns. In particular, a data set with almost no switches between treatment states may provide weak information even if exact equality \(A_k=A_{k-1}\) does not hold for every record.
Worked Example: Persistent Treatment and a Joint Model
Suppose the only histories represented in the weighted risk sets at intervals 2 and 3 are \((0,0)\) and \((1,1)\). For \((0,0)\), the joint predictor \(\alpha A_k+\gamma A_{k-1}\) is \(0\). For \((1,1)\), it is \(\alpha+\gamma\). A fitted hazard ratio comparing these patterns is \(\exp(\alpha+\gamma)\), not a separately identified estimate of either \(\exp(\alpha)\) or \(\exp(\gamma)\).
For example, \((\alpha,\gamma)=(\log 2,0)\) and \((0,\log 2)\) both yield a hazard ratio of 2 for \((1,1)\) versus \((0,0)\). So does \((\log 4,-\log 2)\), since \(\log 4-\log 2=\log 2\). The observed patterns cannot determine which coefficient allocation is correct.
Deriving a Cumulative-Exposure Contrast
The cumulative-count model has a simple history-level implication, provided its log-linear form is suitable. Consider two histories \(h\) and \(h'\) at the same interval \(k\), with counts \(C_k(h)\) and \(C_k(h')\). The model gives their hazards as \(\lambda_0(t)\exp\{\beta C_k(h)\}\) and \(\lambda_0(t)\exp\{\beta C_k(h')\}\). Dividing cancels the common baseline hazard:
This derivation shows precisely what the coefficient asserts: histories differing by \(d\) treated intervals have hazard ratio \(\exp(\beta d)\), at the same interval time, under the model. It also shows a substantive restriction. If two histories have the same count but different timing, this model assigns them the same hazard. For example, treating only in the first interval and treating only in the current interval are equivalent with respect to \(C_k\). If recency matters, a cumulative count alone cannot represent that feature.
Worked Example: Interpreting a Cumulative Coefficient
Suppose a fitted cumulative-count model has \(\hat\beta=\log(1.20)\). Compare histories through interval 4 with counts 1 and 3. The fitted hazard ratio is
Thus the model associates two additional treated intervals with a 44% higher hazard at the same interval time. It does not say that each particular placement of those two intervals has the same causal effect in nature; that conclusion depends on the cumulative-count model being an adequate representation of the relevant history contrasts and on the causal assumptions supporting the weighted analysis.
Assumptions, Diagnostics, and Limits
Causal interpretation of a weighted Cox MSM requires the usual conditions for the weighting strategy and outcome model. In particular, treatment histories must be well-defined and consistent with observed outcomes; sequential exchangeability must hold given the measured past; and positivity must provide support for the treatment choices being compared at relevant histories. The weights and the marginal structural hazard model must also be appropriately specified for the target contrast. If censoring is informative conditional on measured history, the analysis must account for it through an appropriate censoring strategy. These conditions do not follow merely from fitting a weighted Cox model.
Inspect the treatment sequences and weighted risk sets before choosing an encoding. Ask whether histories with different current values occur at comparable past histories, whether histories with different lagged values occur at comparable current values, and whether the cumulative counts overlap. Large or unstable weights can make nominally present patterns contribute very little reliable information. Sparse history patterns can also make joint terms unstable or unidentifiable. Weight truncation may reduce extreme influence, but it does not create treatment-history support that the data lack.
Compare candidate encodings by their implied contrasts, not by treating one as automatically correct. A current-only model is parsimonious but discards distinctions among past histories at the same current treatment. A lag-only model is appropriate only when the scientific target concerns the preceding interval and the model’s omission of current treatment is defensible. A cumulative count summarizes duration of exposure but imposes equal contribution by interval and ignores timing. A joint current-and-lagged model can distinguish immediate and one-interval-delayed terms, but it needs sufficient variation and does not represent all more distant history effects. These simple encodings are not interchangeable with a fully specified regime comparison.
A common mistake is to interpret \(\exp(\beta)\) in a cumulative model as the hazard ratio for “being treated now.” The correction is to calculate the change in \(C_k\) for the precise histories being compared: the model’s ratio is \(\exp\{\beta\Delta C_k\}\). Another mistake is to include current and lagged treatment and assume both coefficients are estimable because the software returns two numbers. If the weighted data contain only persistent histories, the likelihood depends on their sum; separate coefficient estimates then reflect numerical constraints or instability, not information in the data.
Check Your Understanding
Answer each question by identifying the treatment histories being compared. Short solutions follow.
- At interval 5, what is the cumulative count for history \((0,1,0,1,1)\)?
- In a cumulative-count model with \(\beta=\log(1.10)\), what is the model-based hazard ratio for histories whose cumulative counts differ by 3?
- Why can’t current and lagged coefficients be separated if \(A_k=A_{k-1}\) in every observed interval?
- At interval 4, compare histories \((0,0,0,1)\) and \((0,1,0,0)\). Which of the three single-term encodings distinguishes them?
- Name one limitation of a cumulative-count term and one diagnostic that can reveal weak support for a joint current-and-lagged model.
Solutions. (1) \(C_5=0+1+0+1+1=3\). (2) The ratio is \(\exp\{3\log(1.10)\}=1.10^3=1.331\). (3) The predictor is \((\alpha+\gamma)A_k\), so the likelihood depends only on the coefficient sum. (4) At interval 4, the first history has current 1, lagged 0, and count 1; the second has current 0, lagged 0, and count 1. Thus only the current-treatment encoding distinguishes them. (5) A cumulative count ignores timing, assigning equal counts equal hazards; weak support can be seen by tabulating weighted risk-set observations for each current/lagged treatment combination and finding empty or sparse cells.