Tutorials › Marginal Structural Models › Accounting for Estimated Weights in Cox Model Uncertainty

Fitting MSMs for Survival Outcomes · Tutorial 182 of 501

Accounting for Estimated Weights in Cox Model Uncertainty

Separate uncertainty conditional on supplied weights from uncertainty that includes estimating them, using joint score equations or a bootstrap that refits the entire analysis.

Advanced 12 min read

What You'll Learn

  • Distinguish conditional-on-weights uncertainty from uncertainty that includes weight estimation.
  • Derive the weighted Cox estimator’s influence function when treatment-model parameters are estimated.
  • Identify the covariance terms omitted by treating estimated weights as fixed.
  • Implement a person-level bootstrap that refits the weight and outcome models.
  • Diagnose instability from weak overlap, extreme weights, or failed refits.

Why the Origin of the Weights Matters

A weighted Cox fit uses treatment weights to form its risk-set score. If those weights were estimated from the same study data, they are random too. The uncertainty in the fitted treatment-effect parameter can therefore depend on both the outcome score and the way the weight estimates vary across samples. Treating estimated weights as fixed answers a narrower question: how variable would the outcome fit be if these particular weights were held unchanged?

This distinction is about uncertainty, not a change to the fitted coefficient. For a weighted Cox estimator, the coefficient may be computed identically under either approach; what changes is its variance estimate. The discussion below assumes independent study participants, with each participant’s complete repeated-interval record treated as one sampling unit.

Definition: Let \(\beta\) denote the weighted Cox model parameter and \(\alpha\) the parameter in the treatment-weight model. Write \(U_n(\beta,\alpha)=\sum_{i=1}^n u_i(\beta,\alpha)\) for the participant-level weighted Cox score and \(Q_n(\alpha)=\sum_{i=1}^n q_i(\alpha)\) for the treatment-model estimating equation. The fitted values solve \(U_n(\hat\beta,\hat\alpha)=0\) and \(Q_n(\hat\alpha)=0\). Treating weights as fixed omits variation due to \(\hat\alpha\); accounting for estimated weights includes it.

Here \(u_i\) is the contribution of participant \(i\) to the weighted Cox score, including that participant’s event and risk-set contributions. It is a participant-level contribution even when the data have several rows per participant. If more than one model is used to construct the weights, \(\alpha\) and \(q_i\) can collect all their parameters and estimating equations.

Joint Estimating Equations and Their Variance

Suppose the treatment-weight model has a well-defined population parameter \(\alpha_0\), satisfying \(E[q_i(\alpha_0)]=0\), and the weighted Cox target \(\beta_0\) satisfies \(E[u_i(\beta_0,\alpha_0)]=0\). Define the expected derivatives

$$ A=E\!\left[\frac{\partial u_i}{\partial\beta^\mathsf{T}}\right], \qquad B=E\!\left[\frac{\partial u_i}{\partial\alpha^\mathsf{T}}\right], \qquad C=E\!\left[\frac{\partial q_i}{\partial\alpha^\mathsf{T}}\right], $$

with derivatives evaluated at \((\beta_0,\alpha_0)\) for \(A,B\), and at \(\alpha_0\) for \(C\). Assume these matrices are finite and nonsingular where required, the equations are differentiable near their targets, their sample derivatives converge to these expectations, and the participant-level scores have finite second moments. Also assume the estimating equations have consistent roots and a joint central limit theorem applies. These regularity conditions exclude, for example, a treatment-model estimate at a separation boundary or a weight model whose parameters cannot be identified.

Theorem: Under the stated regularity conditions, the first-order influence contribution for \(\hat\beta\) is $$ \phi_i=-A^{-1}\left\{u_i(\beta_0,\alpha_0)-BC^{-1}q_i(\alpha_0)\right\}. $$ Consequently, if \(\Omega=\operatorname{Var}\{u_i-BC^{-1}q_i\}\), then $$ \operatorname{Var}(\hat\beta)\ \approx\ \frac{1}{n}A^{-1}\Omega A^{-\mathsf{T}}. $$

Derivation. Expand the two sample equations around their population roots. The first-order terms are

$$ 0=\frac{1}{n}\sum_{i=1}^n u_i+ A(\hat\beta-\beta_0)+B(\hat\alpha-\alpha_0)+o_p(n^{-1/2}), $$

and

$$ 0=\frac{1}{n}\sum_{i=1}^n q_i+ C(\hat\alpha-\alpha_0)+o_p(n^{-1/2}). $$

The second equation gives \(\hat\alpha-\alpha_0=-C^{-1}n^{-1}\sum_i q_i+o_p(n^{-1/2})\). Substituting this into the first equation yields

$$ \hat\beta-\beta_0 =-A^{-1}\frac{1}{n}\sum_{i=1}^n \left(u_i-BC^{-1}q_i\right)+o_p(n^{-1/2}). $$

The central limit theorem applied to the mean of the bracketed participant contributions gives the stated variance. In practice, estimate \(A,B,C\) by sample derivatives and estimate \(\Omega\) by the sample covariance of the fitted contributions \(u_i-\hat B\hat C^{-1}q_i\). This is a joint sandwich calculation: the same participant contributes to both equations, so their covariance is retained. The minus sign in the influence function does not affect its covariance.

By contrast, a conditional-on-weights calculation uses the outcome-score contribution \(u_i\) alone and treats the fitted \(\hat\alpha\) as nonrandom. Its first-order variance is based on \(A^{-1}\operatorname{Var}(u_i)A^{-\mathsf{T}}/n\). That calculation can be appropriate when the weights really are fixed externally and the inferential target is conditional on them. It does not, by itself, represent uncertainty from estimating the weights in the study at hand.

Worked Example: The Nuisance-Estimation Term Changes the Variance

Consider a scalar illustration with \(A=2\), \(B=1\), and \(C=2\). Suppose the participant-level scores at the target have \(\operatorname{Var}(u_i)=1\), \(\operatorname{Var}(q_i)=4\), and \(\operatorname{Cov}(u_i,q_i)=0\). The joint influence contribution is

$$ \phi_i=-\frac{1}{2}\left(u_i-\frac{1}{2}q_i\right). $$

First, \(\operatorname{Var}(u_i-\frac12q_i)=\operatorname{Var}(u_i)+\frac14\operatorname{Var}(q_i)-\operatorname{Cov}(u_i,q_i)=1+1-0=2\). Therefore \(\operatorname{Var}(\phi_i)=\frac14(2)=0.5\), and the approximate variance of \(\hat\beta\) is \(0.5/n\). If \(\alpha\) were treated as fixed, the corresponding variance would be \(\operatorname{Var}(u_i)/A^2n=1/(4n)=0.25/n\). In this example, fixing the estimated weight parameter understates the first-order variance by a factor of two. The values illustrate the formula; they are not universal properties of weighted Cox fits.

Full-Pipeline Bootstrap

A bootstrap can capture weight-estimation uncertainty without explicitly calculating \(B\) and \(C\). The essential requirement is to repeat the entire estimation procedure in every replicate: resample independent participants, fit the treatment or censoring models used for the weights, construct the weights, and refit the weighted Cox model. With repeated intervals, resample participants and carry all their intervals together. Resampling rows independently would break the within-person structure.

1
Resample the independent units.
Draw \(n\) participants with replacement, retaining all records for each selected participant.
2
Re-estimate the weights.
Refit every model that estimated a component of the weights, then reconstruct weights in the resampled data.
3
Refit the outcome model.
Fit the weighted Cox model using the replicate’s weights and record \(\hat\beta^{(b)}\).
4
Summarize across replicates.
Use the empirical spread of the replicate estimates as a bootstrap estimate of sampling variability, provided the fitting procedure is stable and the bootstrap is appropriate for the sampling design.

Under the same smoothness and sampling conditions that give the joint influence representation, the bootstrap reproduces its first-order variation. In outline, the full estimator is a smooth function of empirical averages of the outcome and weight-model contributions. Resampling participants perturbs both sets of averages together; refitting both models applies the same function to those perturbed averages. The conditional bootstrap central limit theorem therefore reproduces the joint first-order distribution, including the covariance between \(u_i\) and \(q_i\). Holding the original weights fixed instead perturbs only the outcome fit, so it cannot reproduce the \(q_i\) component or its covariance with \(u_i\). This justification does not guarantee good finite-sample behavior when the fitted procedure is unstable.

Worked Example: A Small Bootstrap Summary

Suppose an analysis reports \(\hat\beta=0.40\). For illustration, five full-pipeline bootstrap replicates give \(0.20, 0.30, 0.40, 0.50, 0.60\). Their mean is \(0.40\), and their squared deviations from the mean sum to

$$ (-0.20)^2+(-0.10)^2+0^2+(0.10)^2+(0.20)^2 =0.04+0.01+0+0.01+0.04=0.10. $$

The usual sample variance of these five replicate estimates is \(0.10/(5-1)=0.025\), giving a bootstrap standard error of \(\sqrt{0.025}\approx0.158\). If an outcome-only calculation that holds weights fixed had instead reported a standard error of \(0.08\), the difference would signal that the two calculations represent different sources of variation. Five replicates are far too few for a reliable standard-error estimate in a real analysis; this arithmetic only demonstrates how the summary is calculated.

Worked Example: Weight Estimation Can Affect a Risk-Set Score

Consider one risk set with two participants: an event participant with covariate \(x=1\), and a non-event participant with \(x=0\). Let the event participant’s weight be \(1\), and let the other participant’s weight be \(e^\alpha\), with outcome-model coefficient \(\beta\). The weighted risk-set mean of \(x\) is \(e^\beta/(e^\beta+e^\alpha)\), so the event’s score contribution is

$$ U(\beta,\alpha)=1-\frac{e^\beta}{e^\beta+e^\alpha}. $$

At \(\beta=0,\alpha=0\), this contribution is \(1-\frac12=\frac12\). Its sensitivity to the weight parameter is

$$ \left.\frac{\partial U}{\partial\alpha}\right|_{(0,0)} =\left.\frac{e^{\beta+\alpha}}{(e^\beta+e^\alpha)^2}\right|_{(0,0)} =\frac{1}{4}. $$

Thus even this single risk set has a nonzero derivative with respect to the parameter that determines the weight. In a full analysis, such derivatives across risk sets contribute to \(B\). This calculation does not imply a particular direction for the variance change: the result also depends on the variability of the weight-model score and its covariance with the Cox score.

Choosing an Approach and Checking Stability

ApproachWhat variesWhen it is usefulMain caution
Outcome fit with supplied weights held fixedOutcome score, conditional on the weight valuesWeights are genuinely external and the target is conditional on themMisses study-sample weight-estimation uncertainty when weights were estimated internally
Joint estimating-equation sandwichOutcome and weight-model scores, including their covarianceEquations and derivatives can be specified and computed reliablyRequires correct participant-level contributions and stable derivative estimates
Full-pipeline participant bootstrapAll re-estimated steps, through the final Cox fitThe complete analysis pipeline can be refit in each replicateMay be unstable or computationally costly; failed fits must be investigated, not silently discarded

The joint sandwich and full-pipeline bootstrap are alternatives for propagating estimated-weight uncertainty, not substitutes for sound modeling. A practical diagnostic is to compare the joint sandwich standard error and the full-pipeline bootstrap spread when both are feasible. Large disagreement can indicate finite-sample instability, an implementation error, or a distribution for which the chosen approximation is poor. Also inspect whether treatment-model fits fail, estimated weights become extreme, or bootstrap replicates have very different weight distributions. These patterns can make either variance estimate unreliable.

If weights are truncated, the bootstrap must repeat the prespecified truncation rule in each replicate. If the truncation thresholds themselves were selected from the data, that selection step should also be repeated to reflect its variability. Likewise, any estimated censoring-weight model belongs in the re-estimation pipeline. A bootstrap that refits treatment weights but leaves another estimated weight component fixed is only partially propagating uncertainty.

Neither approach repairs a misspecified treatment model, a lack of positivity, or an outcome target that is not identified under the study assumptions. Extreme weights can cause a few participants to dominate the fit, and bootstrap replicates may expose this by producing unusually large coefficients or failed fits. Report the number and handling of failed replicates and investigate their causes. Do not present the spread of successful replicates as if failures were irrelevant.

Common pitfall: “The weights are already in the data, so their estimation is irrelevant to the Cox standard error.” This confuses having weight values available with knowing them without error. If they were estimated from the same participants, their sampling variation is part of the estimator’s variation. The correction is to state the inferential target: use a conditional calculation only when conditioning on fixed supplied weights is intended; otherwise propagate the weight-estimation step using joint equations or a full-pipeline resampling procedure.

Key takeaway: For study-estimated weights, the outcome and weight-model equations form a joint estimator. Its uncertainty depends on both score variances and their covariance. A bootstrap captures that dependence only when it resamples independent participants and refits every estimated step.

Check Your Understanding

Answer each question, then compare your reasoning with the solutions.

  1. What source of variation does an outcome fit with weights held fixed omit when those weights were estimated in the study?
  2. Why does the joint influence contribution include \(BC^{-1}q_i\), rather than only the Cox score \(u_i\)?
  3. For repeated-interval data, what should be resampled in a full-pipeline bootstrap?
  4. In the scalar worked example, what is the joint variance contribution per participant, and what is the fixed-weight contribution?

Solutions. (1) It omits variation in the estimated weight-model parameter and its covariance with the outcome score. (2) The weight-model equation implies \(\hat\alpha-\alpha_0\approx-C^{-1}n^{-1}\sum_i q_i\); substituting this variation into the Cox equation produces the \(BC^{-1}q_i\) term. (3) Resample independent participants, carrying each selected participant’s complete set of intervals together, then refit the weight models and Cox model. (4) The joint contribution is \(0.5/n\), while the fixed-weight contribution is \(0.25/n\), using the stated scalar values.

Clinical Biostats