Tutorials › Marginal Structural Models › Deriving the Weighted Cox Partial Likelihood

Fitting MSMs for Survival Outcomes · Tutorial 167 of 501

Deriving the Weighted Cox Partial Likelihood

Learn how to construct and interpret each weighted Cox partial-likelihood contribution, including the treatment weights used for the event subject and everyone in the risk set.

Advanced 12 min read

What You'll Learn

  • Define the weighted Cox partial-likelihood contribution at an untied event time.
  • Distinguish the event subject’s multiplicity weight from risk-set weights.
  • Derive the denominator from weighted event intensity under a proportional hazards model.
  • Calculate contributions when risk sets and treatment weights change over time.
  • Identify weight and risk-set diagnostics that reveal unstable or unsupported estimation.
  • Compare the weighted criterion with the ordinary Cox partial likelihood.

Why the Risk-Set Denominator Must Be Weighted

A Cox partial likelihood compares the subject who experiences an event with the subjects still at risk at that time. In a marginal structural Cox model, treatment weights create a pseudo-population in which treatment history is rebalanced. The comparison must therefore use the weighted risk set: a subject with a larger treatment weight contributes more to the denominator than an otherwise identical subject with a smaller weight.

This tutorial derives the event-time contribution for untied events. It focuses on how the treatment weights enter that contribution, not on solving the resulting estimating equations. Let \(X_i(t)\) denote the covariate vector in the specified marginal structural Cox model, and let \(\beta\) be its coefficient vector. The model’s hazard among subjects at risk is proportional to \(\exp\{\beta^\top X_i(t)\}\), with a common baseline hazard.

Definition: At time \(t\), let \(Y_i(t)=1\) if subject \(i\) is under observation and at risk immediately before \(t\), and let \(Y_i(t)=0\) otherwise. The risk set is \(R(t)=\{j:Y_j(t)=1\}\). Write \(W_i(t)\) for subject \(i\)’s positive, finite treatment weight evaluated immediately before \(t\). For an event at \(t\) in subject \(i\), the weighted Cox partial-likelihood contribution is $$ \left\{ \frac{\exp\{\beta^\top X_i(t)\}} {\displaystyle\sum_{j\in R(t)} W_j(t)\exp\{\beta^\top X_j(t)\}} \right\}^{W_i(t)}. $$

The event subject’s weight appears as the power of its contribution; the weights of all at-risk subjects appear inside the denominator. Equivalently, the event subject’s contribution to the weighted log partial likelihood is its weight times the log of the ordinary model numerator divided by the weighted risk-set sum. For event times \(t_1,\ldots,t_D\), with event subject \(i_k\) at time \(t_k\), multiply these contributions over \(k\).

$$ L_w(\beta) = \prod_{k=1}^{D} \left\{ \frac{\exp\{\beta^\top X_{i_k}(t_k)\}} {\displaystyle\sum_{j\in R(t_k)}W_j(t_k) \exp\{\beta^\top X_j(t_k)\}} \right\}^{W_{i_k}(t_k)} . $$

The weights here are treatment weights, which may be stabilized or truncated according to the analysis plan. If weights vary over follow-up, use each person’s weight at the event time in question. A subject who has already had the event or is no longer under observation is not in that time’s risk set and does not enter its denominator.

Deriving the Contribution

Assume independent subjects, a correctly specified marginal structural Cox hazard, and no tied event times. In particular, conditional on the observed history immediately before \(t\), suppose subject \(j\)’s event intensity is \(\lambda_0(t)Y_j(t)\exp\{\beta^\top X_j(t)\}\). The treatment weights are predictable: their values just before \(t\) are determined by information available before the event at \(t\). For a causal interpretation, the treatment weights must also be valid for the target analysis, including the relevant exchangeability and positivity conditions. This derivation concerns the weighted partial-likelihood criterion; it does not turn estimated weights into known constants for uncertainty calculations.

First consider the event process in the weighted pseudo-population. Over a short interval \([t,t+dt)\), the expected weighted event contribution from subject \(j\), conditional on the information just before \(t\), is \(W_j(t)Y_j(t)\lambda_0(t)\exp\{\beta^\top X_j(t)\}dt+o(dt)\). Summing across subjects gives the total weighted event intensity. The relative share for subject \(j\) is therefore proportional to its weight times its risk indicator times its model hazard factor.

$$ \frac{W_j(t)Y_j(t)\lambda_0(t)\exp\{\beta^\top X_j(t)\}} {\displaystyle\sum_{\ell=1}^{n}W_\ell(t)Y_\ell(t) \lambda_0(t)\exp\{\beta^\top X_\ell(t)\}} = \frac{W_j(t)\exp\{\beta^\top X_j(t)\}} {\displaystyle\sum_{\ell\in R(t)}W_\ell(t) \exp\{\beta^\top X_\ell(t)\}}, \qquad j\in R(t). $$

The common baseline hazard cancels, as does the common infinitesimal interval factor. Thus the weighted risk-set denominator is the sum of \(W_j(t)\exp\{\beta^\top X_j(t)\}\) over those at risk. This is the same risk-set weighting that arises by viewing weights as replication in a pseudo-population: a subject represented more heavily contributes more copies to the competing risk set.

For the weighted partial likelihood, an observed event in subject \(i\) contributes \(W_i(t)\) copies of the event-time comparison. Each copy has model numerator \(\exp\{\beta^\top X_i(t)\}\) and the same weighted risk-set denominator. Taking the product over copies gives the contribution raised to \(W_i(t)\). For noninteger weights, the power defines a weighted or pseudo-likelihood criterion rather than a literal probability for a fractional number of replicated people.

Result: Under the no-ties and predictable-weight conditions above, the weighted event-time comparison uses the weighted risk-set sum \(\sum_{j\in R(t)}W_j(t)\exp\{\beta^\top X_j(t)\}\). In the replicated-event weighted partial likelihood, the observed event subject’s weight is the power on that comparison.

This distinction matters. A single-event selection probability proportional to \(W_i(t)\exp\{\beta^\top X_i(t)\}\) is a valid way to describe which weighted risk-set member supplies an event. But multiplying such probabilities once per observed event is a different criterion: its event numerator contains an additional \(\log W_i(t)\), and it does not represent the replicated-event weighted partial likelihood defined here. The treatment weights in the risk-set denominator and the event multiplicity power have related origins, but they are not interchangeable placements of the weight.

Worked Event-Time Calculations

Worked Example: One Event With Three People at Risk

At an event time, subjects A, B, and C are at risk. A has the event, with \(X_A=1\) and \(W_A=2\). B and C have \(X_B=X_C=0\), with weights \(W_B=1\) and \(W_C=3\). The model has a single coefficient \(\beta\).

The weighted denominator is \(2e^\beta+1e^0+3e^0=2e^\beta+4\). The event subject’s model numerator is \(e^\beta\), and its event weight is 2. Therefore the contribution is

$$ \left(\frac{e^\beta}{2e^\beta+4}\right)^2. $$

At \(\beta=\log 2\), \(e^\beta=2\). The denominator is \(2(2)+4=8\), so the unpowered ratio is \(2/8=1/4\), and the contribution is \((1/4)^2=1/16\). If the denominator were incorrectly left unweighted, it would be \(e^\beta+1+1=4\), producing the different ratio \(2/4=1/2\). The difference arises because B and C represent unequal amounts of the weighted risk set.

Worked Example: Two Event Times and Changing Risk Sets

At \(t_1\), A has an event and A, B, and C are at risk. Their covariates are \(X_A=1\), \(X_B=0\), \(X_C=1\); their weights are \(2\), \(1\), and \(0.5\). At \(t_2>t_1\), A has left the risk set, B has an event, and B and C are at risk. At that time \(W_B(t_2)=1.5\), \(W_C(t_2)=0.5\), and their covariates remain 0 and 1, respectively.

At \(t_1\), the denominator is \(2e^\beta+1+0.5e^\beta=2.5e^\beta+1\). A’s event weight is 2, giving contribution \(\{e^\beta/(2.5e^\beta+1)\}^2\). At \(t_2\), B’s contribution has denominator \(1.5+0.5e^\beta\), numerator \(1\), and power \(1.5\), so it is \(\{1/(1.5+0.5e^\beta)\}^{1.5}\).

At \(\beta=0\), the first denominator is \(2.5+1=3.5\), so the first contribution is \((1/3.5)^2=4/49\). The second denominator is \(1.5+0.5=2\), so its contribution is \((1/2)^{1.5}=1/(2\sqrt{2})\). The product is \(2/(49\sqrt{2})\), approximately \(0.0289\). A is excluded at \(t_2\), and the changed weights at \(t_2\) are used there rather than carrying forward the \(t_1\) values.

Worked Example: A Stabilized Weight Changes the Risk-Set Share

Suppose an event subject A and a non-event subject B are both at risk. Both have \(X=0\), but their treatment weights at this time are \(W_A=4\) and \(W_B=1\). The model numerator for A is \(e^{0}=1\), and the denominator is \(4+1=5\). A’s weighted contribution is therefore \((1/5)^4=1/625\).

The weighted share of the risk-set total associated with A is \(4/5\), although the partial-likelihood contribution for the observed event is not \((4/5)^4\). The latter would put A’s weight into the numerator as well as using it as an event power, which is not the criterion defined above. If both weights were instead 1, the contribution would be \((1/2)^1=1/2\). This calculation shows that changing treatment weights alters both the risk-set comparison and the event’s multiplicity.

A Useful Invariance and Its Proof

A common diagnostic or implementation check is whether multiplying every weight by the same positive constant changes the fitted coefficient. It changes the numerical value of the weighted log partial likelihood, but not its maximizer. This statement requires the same constant for every person and event time; it does not apply to arbitrary subject-specific changes.

Result: Let \(c>0\) and replace every \(W_i(t)\) by \(cW_i(t)\). If \(\ell_w(\beta)=\log L_w(\beta)\), then the transformed criterion is \(c\ell_w(\beta)-c\log(c)\sum_{k=1}^D W_{i_k}(t_k)\). Hence its maximizers in \(\beta\) are exactly those of \(\ell_w(\beta)\).

Proof. The original log criterion is

$$ \ell_w(\beta)= \sum_{k=1}^{D}W_{i_k}(t_k) \left[ \beta^\top X_{i_k}(t_k) -\log\left\{\sum_{j\in R(t_k)}W_j(t_k) e^{\beta^\top X_j(t_k)}\right\} \right]. $$

After rescaling, each denominator becomes \(c\sum_{j\in R(t_k)}W_j(t_k)e^{\beta^\top X_j(t_k)}\), whose logarithm is \(\log(c)+\log\{\sum_j W_j(t_k)e^{\beta^\top X_j(t_k)}\}\). Each event power becomes \(cW_{i_k}(t_k)\). Substitution gives

$$ \ell_{cw}(\beta) = c\ell_w(\beta) -c\log(c)\sum_{k=1}^{D}W_{i_k}(t_k). $$

The second term does not depend on \(\beta\), and multiplication by \(c>0\) preserves the ordering of criterion values. Therefore the maximizers are unchanged. This is a criterion-level invariance, not a claim that the weights’ scale is irrelevant to every variance calculation. \(\square\)

Diagnostics, Alternatives, and Limitations

The denominator makes the risk-set implications of treatment weighting visible. At each event time, inspect whether a few large weights dominate the weighted risk-set sum, and whether relevant treatment histories remain represented among those at risk. For a numerical summary, the risk-set effective sample size can be calculated as

$$ \operatorname{ESS}(t)= \frac{\left\{\sum_{j\in R(t)}W_j(t)\right\}^2} {\sum_{j\in R(t)}W_j(t)^2}. $$

If one weight dominates, this quantity can be much smaller than the number at risk. A tiny effective sample size, sparse support for a treatment history, or an extremely large denominator contribution from one individual signals that the weighted comparison may be unstable. These checks do not establish that the treatment model or causal assumptions are correct; they help identify where the fitted criterion is relying heavily on a small part of the observed data.

The ordinary Cox partial likelihood is the main alternative when no treatment weighting is required. It uses \(\sum_{j\in R(t)}\exp\{\beta^\top X_j(t)\}\), so it does not represent the weighted pseudo-population risk set. Conversely, inserting treatment weights only in the event numerator while leaving the denominator unweighted does not implement the weighted risk-set comparison derived here. Other survival approaches, such as a discrete-time weighted model, use a different likelihood construction and should not be treated as algebraically identical to this continuous-time partial likelihood.

This derivation assumes untied events. When multiple events share a recorded time, the ordering or approximation used for the tied risk-set contribution must be specified; the untied formula should not simply be applied as if the events occurred one at a time in a known order. The criterion also relies on valid risk sets and meaningful positive weights. Extreme or poorly supported weights can make a formally computable denominator a poor representation of the intended target population.

Common pitfall: Using an unweighted risk-set denominator because the event subject is already weighted. The event weight alone changes the event’s contribution count; it does not give the other at-risk subjects their correct pseudo-population representation. Put \(W_j(t)\) inside the denominator for every \(j\in R(t)\), then raise the event-time contribution to \(W_i(t)\).

Check Your Understanding

Answer each question, then compare with the solutions.

  1. At an event time, the event subject has \(X=1\), weight 3; two other subjects at risk have \(X=0\), with weights 2 and 1. Write the event-time contribution.
  2. Why is a subject who had an earlier event absent from the current event-time denominator?
  3. Suppose every treatment weight is multiplied by the same positive constant. Does the maximizing value of \(\beta\) change? Explain.
  4. What is wrong with using the weighted risk-set selection share as the numerator and then also raising the resulting ratio to the event subject’s weight?

Solutions. (1) The denominator is \(3e^\beta+2+1=3e^\beta+3\), so the contribution is \(\{e^\beta/(3e^\beta+3)\}^3\). (2) The risk set contains only subjects under observation and event-free immediately before the current time; the earlier event removes that subject. (3) No. The transformed log criterion is the original criterion multiplied by the positive constant, plus a term independent of \(\beta\), so its maximizers are unchanged. (4) That puts the event subject’s weight in the numerator and again in the power. It is a different criterion; the weighted partial likelihood here uses the model numerator \(\exp\{\beta^\top X_i(t)\}\), the weighted sum over the full risk set in the denominator, and the event subject’s weight as the power.

Clinical Biostats