Tutorials › Marginal Structural Models › Treatment Weights in Pooled Logistic Score Equations

Fitting MSMs for Survival Outcomes · Tutorial 189 of 501

Treatment Weights in Pooled Logistic Score Equations

Learn to form and interpret weighted pooled logistic score equations, check their interval timing, and calculate how supplied treatment weights affect estimates.

Advanced 11 min read

What You'll Learn

  • Write the weighted pooled logistic objective for person-interval data.
  • Derive the score for a general logistic marginal structural model.
  • Interpret a treatment weight as scaling an interval’s score contribution.
  • Calculate weighted intercept and treatment-effect estimates from interval records.
  • Identify the conditions and diagnostics relevant to weighted score fitting.

Why weights enter the score equation

In discrete-time survival analysis, each person contributes one record for every interval in which they remain at risk. The pooled logistic model represents the event probability in an interval as a function of the treatment history and other terms in a marginal structural model (MSM). When treatment weights are supplied, they change how strongly each at-risk interval contributes to fitting that model.

The central calculation is direct: multiply an interval’s ordinary logistic score contribution by its weight. This tutorial derives that calculation and works through its implications. It treats the weights as supplied values; it does not derive treatment-weight models. A weighted objective is generally a pseudo-likelihood, not a probability likelihood for a new sample.

Definition: For person \(i\) and interval \(t\), let \(R_{it}=1\) if the person is at risk at the start of the interval, and let \(D_{it}=1\) if the event occurs in that interval. Only records with \(R_{it}=1\) contribute to the event model. Let \(x_{it}\) be the design vector for the MSM, \(\beta\) its parameter vector, and \(W_{it}\geq 0\) the supplied treatment weight for that interval. The pooled logistic model specifies \(p_{it}(\beta)=P(D_{it}=1\mid R_{it}=1,x_{it})=\operatorname{expit}(x_{it}^{\mathsf T}\beta)\), where \(\operatorname{expit}(u)=1/(1+\exp(-u))\).

The design vector summarizes whatever treatment-history terms and other prespecified MSM terms are being fitted. The exact representation of the interval baseline component is a separate modeling choice. For correct timing, \(W_{it}\) must correspond to the treatment history relevant to interval \(t\): a treatment assigned before the interval may be used for it, but a treatment assigned after the interval cannot be used to weight its contribution.

Deriving the weighted score

For an at-risk record, the ordinary Bernoulli log-likelihood contribution is \(D_{it}\log(p_{it})+(1-D_{it})\log(1-p_{it})\). In the weighted fit, multiply this contribution by \(W_{it}\). Summing over all at-risk records gives the weighted objective:

$$ \ell_W(\beta)= \sum_i\sum_t R_{it}W_{it} \left[D_{it}\log(p_{it}(\beta))+ (1-D_{it})\log\{1-p_{it}(\beta)\}\right]. $$

This sum is an objective for estimation, not generally the log-likelihood of independent observations drawn from a literal weighted sample. Within-person records can be dependent, and the treatment weights need not be integers.

Theorem: If \(x_{it}\) is fixed with respect to \(\beta\), \(W_{it}\) is supplied and does not depend on \(\beta\), and the logistic probabilities satisfy \(0<p_{it}(\beta)<1\), then the gradient of \(\ell_W(\beta)\) is
$$ U_W(\beta)= \frac{\partial\ell_W(\beta)}{\partial\beta} =\sum_i\sum_t R_{it}W_{it}x_{it}\{D_{it}-p_{it}(\beta)\}. $$

To verify the result, write \(\eta_{it}=x_{it}^{\mathsf T}\beta\), so that \(p_{it}=\exp(\eta_{it})/\{1+\exp(\eta_{it})\}\). The unweighted record contribution can be rewritten as \(D_{it}\eta_{it}-\log(1+\exp(\eta_{it}))\). Its derivative with respect to \(\beta\) is

$$ \frac{\partial}{\partial\beta} \left[D_{it}\eta_{it}-\log(1+\exp(\eta_{it}))\right] =x_{it}\left[D_{it}-\frac{\exp(\eta_{it})}{1+\exp(\eta_{it})}\right] =x_{it}(D_{it}-p_{it}). $$

Multiplication by the constant \(R_{it}W_{it}\), followed by summation, gives the stated score. A fitted coefficient vector solves \(U_W(\hat\beta)=0\), if a finite solution exists. The derivation establishes the score equation; existence and uniqueness of a finite solution are not guaranteed. \(\square\)

The equation makes the scaling explicit: without a weight, an interval contributes \(R_{it}x_{it}(D_{it}-p_{it})\); with a weight, the contribution is \(R_{it}W_{it}x_{it}(D_{it}-p_{it})\). A weight of two doubles that record’s contribution at the current parameter value. It does not change the record’s observed event indicator or fitted probability by itself.

Worked Example: Scaling Three Interval Contributions

Consider three at-risk records with an intercept-only model, so each design vector is \(x=1\). At a trial parameter value, suppose the fitted event probability is \(p=0.2\) for each record. Their event indicators are \(1,0,1\), and their supplied weights are \(2,0.5,3\), respectively. Calculate the weighted score.

For an intercept-only model, the score contribution is \(W(D-p)\). The first record contributes \(2(1-0.2)=1.6\). The second contributes \(0.5(0-0.2)=-0.1\). The third contributes \(3(1-0.2)=2.4\), not 1.5; the weight is three and the event residual is \(0.8\).

Thus the total score is \(1.6-0.1+2.4=3.9\). The unweighted score would be \(0.8-0.2+0.8=1.4\). The discrepancy illustrates why the weighted and unweighted score equations need not have the same solution: each interval’s residual is multiplied by its own weight.

What the score equation says about fitted parameters

The score equation balances weighted residuals. For an intercept-only model, the balance is between the weighted number of observed events and the sum of weighted fitted probabilities. With treatment terms in the design, there is a corresponding balance for each design component. These are algebraic properties of the fitted equation, not by themselves evidence that the causal assumptions needed for an MSM are satisfied.

Result: For an intercept-only weighted pooled logistic model with at least one at-risk record, finite nonnegative weights, and positive total weight \(S=\sum_{i,t}R_{it}W_{it}\), the score equation has a finite solution if and only if the weighted event total \(E_W=\sum_{i,t}R_{it}W_{it}D_{it}\) satisfies \(0<E_W<S\). In that case, \(p(\hat\beta)=E_W/S\).

To derive this result, when the model has a common probability \(p\), the score is

$$ U_W(\beta)=\sum_{i,t}R_{it}W_{it}(D_{it}-p) =E_W-Sp. $$

Setting the score to zero gives \(p=E_W/S\). A finite logistic intercept requires \(0<p<1\), which is equivalent to \(0<E_W<S\). If \(E_W=0\), the solution would require \(p=0\); if \(E_W=S\), it would require \(p=1\). Neither value corresponds to a finite logistic intercept. This proves the result and also shows how weighted event and non-event totals determine the intercept. \(\square\)

Worked Example: Solving a Weighted Intercept Equation

Suppose four at-risk records have event indicators \(1,0,0,0\) and weights \(2,1,3,2\). Fit an intercept-only pooled logistic model by solving its weighted score equation.

The total weight is \(S=2+1+3+2=8\). The weighted event total is \(E_W=2(1)+1(0)+3(0)+2(0)=2\). Therefore the fitted probability is \(\hat p=E_W/S=2/8=0.25\). The fitted intercept is

$$ \hat\beta=\log\left(\frac{\hat p}{1-\hat p}\right) =\log\left(\frac{0.25}{0.75}\right) =\log(1/3)\approx -1.099. $$

Checking the score at this probability gives \(2(1-0.25)+1(0-0.25)+3(0-0.25)+2(0-0.25)=1.5-0.25-0.75-0.5=0\). The weighted equation is satisfied. The calculation uses weighted totals, not the unweighted event fraction \(1/4\) as a general shortcut; the two happen to agree here only because the sole event record has weight two and the total weight is eight.

Worked Example: A Weighted Binary Treatment Term

Suppose a model has design vector \(x=(1,A)^{\mathsf T}\), where \(A\) is a binary treatment indicator. Across records with \(A=0\), the total weight is 4 and the weighted event total is 1. Across records with \(A=1\), the corresponding totals are 5 and 3. Fit the two parameters in \(\operatorname{logit}(p)=\beta_0+\beta_A A\).

For the \(A=0\) records, the intercept part of the score is \(1-4p_0\), where \(p_0=\operatorname{expit}(\beta_0)\). For the \(A=1\) records, the intercept part is \(3-5p_1\), where \(p_1=\operatorname{expit}(\beta_0+\beta_A)\). The treatment part of the score is \(3-5p_1\), because \(A=0\) records contribute zero to that component.

Setting the treatment score to zero gives \(p_1=3/5=0.6\). The intercept score then requires \(1-4p_0+3-5p_1=0\), so \(p_0=1/4=0.25\). Equivalently, each treatment-group contribution balances separately: \(1-4(0.25)=0\) and \(3-5(0.6)=0\). Thus

$$ \hat\beta_0=\log\left(\frac{0.25}{0.75}\right)=\log(1/3)\approx-1.099, \qquad \hat\beta_A=\log\left(\frac{0.6}{0.4}\right)-\hat\beta_0 =\log(1.5)-\log(1/3)=\log(4.5)\approx1.504. $$

The score check is explicit: the intercept component is \(\{1-4(0.25)\}+\{3-5(0.6)\}=0+0=0\), and the treatment component is \(3-5(0.6)=0\). This example shows that the weighted treatment contrast is built from weighted event and interval totals, rather than raw counts.

Assumptions, diagnostics, and alternatives

The score derivation requires only a well-defined design vector and supplied, finite weights that do not depend on the outcome-model parameter \(\beta\). For its usual survival interpretation, records must be constructed so that a person contributes only while at risk, and each event is represented in its event interval. Subjects, rather than person-interval records, are the independent sampling units; repeated intervals from one person should not be treated as independent people when making inferential claims.

A causal interpretation requires more than solving the equation. It depends on the relevant consistency, sequential exchangeability, and positivity assumptions, as well as suitable treatment-weight construction and an adequately specified MSM. Weighting does not repair a violation of these assumptions. It also does not guarantee a stable fit: a few intervals with very large weights can dominate the score, while extreme concentration of weight on a small portion of the sample makes results sensitive to those records.

Useful checks include verifying that weights are finite and nonnegative, confirming that each weight is aligned with the treatment history available at the start of its interval, and inspecting how much of the total weight is carried by a small number of people or intervals. Compare weighted and unweighted fits as a sensitivity check, not as a test that one is correct. Also inspect convergence and whether the fitted probabilities and coefficients are finite. A score that does not approach zero at the reported estimate can indicate a coding, optimization, or data-structure error.

The ordinary pooled logistic fit is the main contrast: it uses the same interval structure but sets all weights to one. A weighted Cox MSM is a different outcome-model approach, developed for continuous-time survival analysis; its estimating equation is not this logistic score. Neither approach is automatically preferable in every setting. Here the weighted pooled logistic equation is appropriate when the discrete-interval event probability is the target model and the supplied weights are appropriate for the causal analysis.

Finally, a common scaling of all weights does not change the coefficient solution: if every \(W_{it}\) is replaced by \(cW_{it}\) for a fixed \(c>0\), the new score is \(cU_W(\beta)\), which has the same zeros. But changing weights differently across intervals generally changes the zeros. The weights therefore define the relative influence of records in the estimating equation, not just a numerical rescaling of the entire fit.

Check Your Understanding

Use the score equation to answer each question. Solutions follow in brief.

  1. For one at-risk record with \(D=0\), \(p=0.3\), and \(W=4\), what is its intercept score contribution?
  2. In an intercept-only fit, the total weight is 10 and the weighted event total is 7. What are the fitted probability and intercept?
  3. Why is it incorrect to use a treatment value assigned after an interval to choose that interval’s treatment weight?
  4. If all weights are doubled, does the coefficient solution change? Explain using the score.

Solutions. (1) \(4(0-0.3)=-1.2\). (2) \(\hat p=7/10=0.7\), so \(\hat\beta=\log(0.7/0.3)=\log(7/3)\approx0.847\). (3) That treatment value is not part of the treatment history available at the interval’s start; using it misaligns the weight with the interval contribution. (4) No: doubling every weight doubles the whole score, preserving its zeros, so it does not change the coefficient solution when that solution exists.

Clinical Biostats