Why Weight Timing Is Part of the Model
A weighted Cox analysis does not attach one permanent weight to each person when treatment and confounders evolve over time. A person’s cumulative treatment weight changes as treatment decisions are made. At each event time, the risk set must therefore use weights aligned with the treatment history that was in place by then. Using the weight from the wrong interval can alter both the weighted composition of the risk set and the event’s contribution to the score.
The central rule is temporal: at an event time, use the cumulative treatment weight based on treatment assignments made before that time. The exact interval index depends on how the study defines its intervals and when a treatment becomes effective. Making those conventions explicit prevents an apparent “off-by-one” rule from becoming a real off-by-one error.
This definition describes a common interval convention, not an instruction to use the index \(k\) mechanically. If the protocol instead assigns \(A_k\) at the end of interval \(k\), that assignment cannot contribute to a weight used earlier in that interval. The event time and the effective time of treatment—not the variable’s name in a data file—determine the correct weight.
Let \(N_i(t)\) count events for person \(i\), and let \(Y_i(t)\) indicate that the person is under observation and at risk just before \(t\). Let \(X_i(t)\) denote the Cox model covariate vector. For a time-varying treatment weight, write \(W_i(t-)\) for the cumulative weight based on treatment assignments made strictly before \(t\). At a boundary where a new assignment and an event could coincide, the study protocol must specify their order; the minus sign emphasizes that an event contribution uses the history available immediately before the event.
Risk-Set Contributions and Their Timing
For the weighted Cox score, define the weighted risk-set sums, for \(r=0,1\), by
where \(X^{\otimes 0}=1\) and \(X^{\otimes 1}=X\). Thus \(S_0^W\) is a weighted total over the risk set, and \(S_1^W/S_0^W\) is its weighted covariate mean under the fitted relative-risk factors. A standard weighted Cox score is
At an event time, every person still at risk enters the denominator with the weight current for that person at that time. The person who experiences the event also contributes an event weight in the outer factor. These two roles are related but distinct: assigning the event person’s later weight to the denominator, or assigning a risk-set member’s event-time weight to all earlier times, does not implement this score.
Justification. During interval \(k\), \(A_k\) has been assigned, while \(A_{k+1}\) has not. The product defining \(W_k\) contains exactly the factors for decisions \(1,\ldots,k\). The product defining \(W_{k-1}\) omits the decision governing the interval; \(W_{k+1}\) includes a factor for a future decision. Since an event contribution at time \(t\) is based on the treatment and weight history available before \(t\), the corresponding product is \(W_k\), subject to the stated boundary convention.
The weighted score formula also follows directly from a weighted partial-likelihood criterion. For fixed weights not depending on \(\beta\), write its log criterion as
Differentiating the finite risk-set sum gives
Substituting this derivative into the derivative of \(\ell_W\) yields \(U(\beta)\). This derivation assumes the weights are held fixed while differentiating the outcome criterion; it does not assert that the weighted criterion is an ordinary likelihood for the original data. The timing rule enters through each \(W_i(t-)\) in the risk-set sums and event contribution. \(\square\)
Worked Timelines
Worked Example: Computing the Weight for an Event in Interval 2
A person receives \(A_1=1\) at baseline and \(A_2=0\) at \(t_1\). The stabilized numerator probabilities for the observed decisions are \(0.50\) and \(0.40\). The corresponding denominator probabilities, conditional on the measured histories available before each decision, are \(0.40\) and \(0.20\). The person has an event at \(t=1.6\), where \(t_1=1\) and \(t_2=2\).
The first-interval weight is $$ W_1=\frac{0.50}{0.40}=1.25. $$
The second decision has already been made at \(t_1\), so the weight during interval 2 is $$ W_2=W_1\frac{0.40}{0.20} =1.25(2)=2.50. $$
The event at \(1.6\) uses \(2.50\). Using \(1.25\) would omit the treatment decision governing interval 2. A weight involving a decision at \(t_2=2\) would be future information and cannot be used for this event.
Worked Example: How a Wrong Weight Changes a Risk-Set Score
At an event time in interval 2, three people are at risk. Person 1 has the event, and their covariate is \(X_1=1\). Persons 2 and 3 have \(X_2=0\) and \(X_3=1\), respectively. At \(\beta=0\), the correct interval-2 weights are \(1.5\), \(2.0\), and \(0.5\).
The weighted mean covariate in the risk set is $$ \frac{1.5(1)+2.0(0)+0.5(1)} {1.5+2.0+0.5} =\frac{2.0}{4.0}=0.5. $$ The event contribution to the score is therefore $$ 1.5(1-0.5)=0.75. $$
Suppose an indexing error instead assigns the next-interval weights \(3.0\), \(0.5\), and \(2.0\). The resulting mean is $$ \frac{3.0(1)+0.5(0)+2.0(1)} {3.0+0.5+2.0} =\frac{5.0}{5.5}\approx0.9091, $$ and the event contribution becomes $$ 3.0(1-0.9091)\approx0.2727. $$
The change is not a harmless relabeling: both the risk-set mean and the event’s own weight changed. The same mistake can affect many event times and hence the fitted coefficient.
Worked Example: An Event at a Treatment-Update Boundary
A person receives \(A_1\) at time \(0\); a second treatment decision \(A_2\) is scheduled at time \(1\). The protocol specifies that an event recorded at exactly time \(1\) is ordered before the new assignment, which becomes effective immediately after the event time. Suppose \(W_1=1.2\), and the observed \(A_2\) would multiply the weight by \(1.5\), giving \(W_2=1.8\).
For an event recorded at \(t=1\), the pre-event history contains only the first decision. The correct event weight is \(1.2\), not \(1.8\). For an event at \(t=1.1\), the second decision has occurred and is effective, so the weight is \(1.8\), provided the person remains at risk.
If the protocol instead orders assignment before an event at time \(1\), the event at that boundary uses \(W_2=1.8\). The arithmetic is unchanged; the recorded ordering convention determines which history is available. A dataset with tied timestamps but no ordering rule does not, by itself, settle the weight assignment.
Assumptions, Data Layout, and Diagnostics
Correct timing is necessary but not sufficient for causal interpretation. The treatment-weight analysis still relies on consistency, sequential exchangeability given the measured treatment history, positivity for the treatment decisions represented by the weights, and adequate specification of the treatment models. If censoring weights are also used, their factors must follow the censoring history through the event time and the study’s censoring convention. These assumptions are distinct from the bookkeeping rule that aligns treatment weights with risk sets.
A useful data layout has one row per person per interval, with a start time, stop time, treatment history effective over that row, event indicator, and weight for that row. Under the convention in this tutorial, a row for interval \(k\) carries \(W_k\); splitting an interval at a treatment update creates a new row with the updated weight from that update onward. The risk-set weight at an event is then the weight on the row containing that event, for each person still at risk.
The following checks are especially useful before fitting the model:
- Inspect the update sequence. For each person, confirm that \(W_k/W_{k-1}\) corresponds to the treatment decision assigned at the start of interval \(k\), not to the next decision.
- Check event rows manually. Select a few events and verify that each person at risk has the weight associated with their history before that event.
- Check boundary ordering. Confirm how events, treatment changes, and censoring recorded at the same time are ordered in the protocol and represented in the data.
- Look for future information. An event row must not carry a weight factor calculated using a treatment decision that occurred after the event.
- Compare intervals around updates. A weight should change when its corresponding decision enters the cumulative product. A shift one row early or late is a warning, even if the values appear plausible.
Extreme or unstable weights can also signal sparse treatment histories or poor positivity, but they do not diagnose timing by themselves. Conversely, a smooth-looking weight sequence does not show that the event-time alignment is correct. Review the treatment-update times and weight construction separately from summaries of the weight distribution.
Common Pitfall and Alternatives
The counting-process notation makes the rule explicit through \(W_i(t-)\). An interval start-stop dataset makes it operational by storing the current weight on each row. A landmark analysis instead defines risk sets at selected times and uses weights available at those landmarks; it answers a differently indexed analysis and does not justify carrying a later weight backward. For a weighted Cox MSM, the time-varying risk-set formulation is the direct choice when treatment and weights update over follow-up.
A standard software interface may accept a weight column but treat it as fixed for a subject or use it as a case weight without updating it across start-stop rows. The analyst must verify the implementation against the intended weighted score and the data structure. A static weight computed at the end of follow-up can inadvertently use future treatment decisions for earlier events. Software output cannot repair a misaligned time-varying weight.
The timing rule also has limits. It does not establish that the treatment models are correct, that positivity holds, or that the chosen Cox MSM is an adequate outcome model. Nor does it resolve tied-event conventions; those must be handled consistently with the selected weighted Cox method. Correctly timed weights are a prerequisite for the intended analysis, not a guarantee of valid causal conclusions.
Check Your Understanding
Answer each question, then compare with the solutions below.
- Treatment \(A_3\) is assigned at \(t_2\) and applies during \((t_2,t_3]\). Which cumulative treatment weight belongs to an event at \(t_2+0.4\)?
- A treatment update is recorded at the same timestamp as an event. What information is needed to determine which weight applies?
- Why can an off-by-one error alter both the risk-set mean and the event contribution to a weighted Cox score?
- In the interval convention used here, a person’s event in interval 4 is assigned \(W_3\), although the fourth treatment decision occurred at the start of interval 4. What is the likely error?
Solutions. (1) Use \(W_3\), since \(A_3\) was assigned before the event and governs interval 3. (2) The protocol’s ordering rule must say whether treatment became effective before or after the event; the timestamp alone is insufficient. (3) The weights enter the weighted risk-set sums used to calculate \(S_1^W/S_0^W\), and the event person’s weight also multiplies their score residual. Changing weights can change both pieces. (4) The row likely carries the previous interval’s weight; under this convention, an event in interval 4 uses \(W_4\), which includes the fourth decision.