Tutorials › Causal Inference › Bootstrap Inference With Estimated Longitudinal Weights

Marginal Structural Models · Tutorial 747 of 972

Bootstrap Inference With Estimated Longitudinal Weights

Learn how to reproduce the complete weighting and model-fitting procedure in each bootstrap sample, and why holding estimated weights fixed can understate uncertainty.

Advanced 12 min read

What You'll Learn

  • Identify the independent sampling unit and resample its complete longitudinal record.
  • Refit treatment and censoring models in every bootstrap replicate.
  • Recalculate stabilized longitudinal weights and refit the weighted marginal structural model.
  • Calculate bootstrap standard errors and percentile confidence intervals.
  • Explain what a fixed-weight bootstrap leaves out and when bootstrap results may be unreliable.

Why the Bootstrap Must Reproduce the Analysis

In a longitudinal marginal structural model (MSM), the final estimate depends on more than the outcome model. It also depends on estimated treatment and censoring probabilities, which are combined into weights and then used to fit the MSM. Consequently, uncertainty in those probability estimates can contribute to uncertainty in the causal effect estimate.

A bootstrap intended to quantify uncertainty in the full procedure must repeat the full procedure. In each replicate, resample independent study units, re-estimate the treatment and censoring models, reconstruct the weights, and refit the MSM. Resampling the data while keeping the original weights fixed answers a narrower question: how much does the MSM estimate vary when the observed records change but the estimated weighting procedure is treated as known?

Definition: A full-pipeline bootstrap for a weighted longitudinal MSM resamples independent study units and, in every bootstrap replicate, re-estimates the treatment and censoring models, recalculates the longitudinal weights, and refits the MSM. The resulting replicate estimates approximate the sampling variation of the complete estimation procedure, subject to the usual conditions for bootstrap validity.

What Must Be Repeated in Each Replicate

Let \(i\) index independent study units and \(t=0,\ldots,K\) index treatment times. Write \(A_{it}\) for treatment, \(H_{it}\) for the observed history used in the treatment model, and \(C_{it}=1\) if the person is censored during interval \(t\). A stabilized longitudinal weight combines treatment and censoring probability ratios. Schematically, for a person observed through the relevant times, it has the form

$$ \widehat W_i = \prod_{t=0}^{K} \frac{\widehat q_t(A_{it}\mid V_{it})} {\widehat g_t(A_{it}\mid H_{it})} \, \frac{\widehat s_t(C_{it}=0\mid V_{it},A_{it})} {\widehat r_t(C_{it}=0\mid H_{it},A_{it})}. $$

Here \(\widehat g_t\) and \(\widehat r_t\) are fitted denominator probabilities, while \(\widehat q_t\) and \(\widehat s_t\) are fitted numerator probabilities; \(V_{it}\) denotes the history included in the corresponding numerator model. The exact factors depend on the specified weight construction and the person's observed follow-up. The important point for bootstrapping is that these are estimated quantities. They must be estimated anew from each resampled data set.

The independent sampling unit is usually the person, not the person-visit record. Draw \(n\) people with replacement. For each selected person, carry along the complete longitudinal record required by the analysis, including treatment, covariate, censoring, and outcome information. If a person is selected more than once, their copies must be treated as separate bootstrap copies when fitting the models. Resampling visit rows separately would break within-person histories and would not reproduce the original sampling design.

Within each replicate, fit the same treatment and censoring model specifications used in the original analysis. Then calculate the replicate-specific weights, apply the same prespecified truncation rule if truncation is part of the analysis, and fit the same weighted MSM. The resulting coefficient or contrast is one bootstrap estimate, say \(\widehat\psi^{*(b)}\). The full-pipeline sequence is summarized below.

1
Resample units.
Draw \(n\) independent units with replacement and retain each selected unit’s longitudinal record.
2
Re-estimate probability models.
Fit the specified treatment and censoring numerator and denominator models in the bootstrap sample.
3
Rebuild weights.
Calculate the replicate-specific longitudinal weights and apply the original analysis’s prespecified weight processing.
4
Refit the MSM.
Fit the weighted marginal structural model and save the target coefficient or contrast.
5
Summarize replicates.
Use the distribution of the saved estimates to estimate uncertainty and, where appropriate, form a confidence interval.

Worked Example: Reconstructing a Longitudinal Weight

Suppose a hypothetical two-time treatment analysis has fitted probabilities for one person's observed treatment and uncensored status as follows. At the first time, the treatment numerator and denominator probabilities are \(0.40\) and \(0.50\); at the second time they are \(0.30\) and \(0.60\). The corresponding censoring numerator and denominator probabilities are \(0.90\) and \(0.95\) at the first time, and \(0.80\) and \(0.90\) at the second time. Assume these are the probabilities for the observed events and that the person contributes at both times.

The person's combined stabilized weight is the product of the four ratios:

$$ \widehat W_i = \frac{0.40}{0.50} \times \frac{0.30}{0.60} \times \frac{0.90}{0.95} \times \frac{0.80}{0.90} = \frac{0.40\times0.30\times0.90\times0.80} {0.50\times0.60\times0.95\times0.90} \approx 0.3368. $$

The calculation uses the original ratios through the multiplication; the displayed decimal is rounded only at the end. In a bootstrap replicate, the same calculation is made with probabilities from models refitted to that replicate, rather than with the probabilities from the original sample. Thus the replicate weight can differ even for a resampled copy of the same observed person.

Bootstrap Standard Errors and Intervals

For \(B\) bootstrap replicates, let \(\widehat\psi^{*(1)},\ldots,\widehat\psi^{*(B)}\) be the estimates from the complete procedure. Their sample standard deviation estimates the bootstrap standard error:

$$ \overline{\widehat\psi^*} = \frac{1}{B}\sum_{b=1}^{B}\widehat\psi^{*(b)}, \qquad \widehat{SE}_{\mathrm{boot}} = \sqrt{ \frac{1}{B-1} \sum_{b=1}^{B} \left(\widehat\psi^{*(b)}-\overline{\widehat\psi^*}\right)^2 }. $$

A percentile bootstrap confidence interval uses the empirical quantiles of the replicate estimates. For example, the 2.5th and 97.5th percentiles give a nominal 95% percentile interval. Under suitable sampling and regularity conditions, the bootstrap distribution approximates the sampling distribution of the estimator. This does not mean there is a 95% probability that a fixed causal parameter lies in the interval. The interval procedure is designed to cover the parameter in about 95% of repeated samples when its assumptions and approximation are adequate.

Worked Example: Calculating a Bootstrap Standard Error

In a small hypothetical demonstration, five full-pipeline bootstrap replicates produce effect estimates of \(1.7\), \(2.1\), \(2.5\), \(2.9\), and \(2.3\) units. These five replicates are chosen to show the arithmetic; a real analysis would use many more.

Their mean is

$$ \overline{\widehat\psi^*} = \frac{1.7+2.1+2.5+2.9+2.3}{5} = \frac{11.5}{5} = 2.3\text{ units}. $$

The squared deviations from \(2.3\) are \(0.36\), \(0.04\), \(0.04\), \(0.36\), and \(0\), with sum \(0.80\) squared units. Therefore,

$$ \widehat{SE}_{\mathrm{boot}} = \sqrt{\frac{0.80}{5-1}} = \sqrt{0.20} \approx 0.4472\text{ units}. $$

This is a bootstrap estimate of the standard error, not a standard error of \(0.4472\) units known without uncertainty. With only five replicates it is highly imprecise. In practice, use enough replicates for the standard error and the interval quantiles to be stable, and report the number of replicates and the interval construction.

Why Fixed-Weight Resampling Can Miss Variation

A fixed-weight bootstrap resamples units and refits the MSM but carries the original estimated weights into every replicate. This can be useful for a limited conditional calculation, but it is not the bootstrap analogue of the full analysis. It omits changes in the fitted treatment and censoring probabilities across resamples and the resulting changes in the weights.

One way to understand the distinction is through a first-order expansion. Let \(\widehat\eta\) collect the nuisance-model parameters used to estimate the weights. In a regular setting, the full estimator's error can be represented schematically as

$$ \widehat\psi-\psi \approx \frac{1}{n}\sum_{i=1}^{n}\phi_i + D(\widehat\eta-\eta), $$

where \(\phi_i\) represents the contribution from sampling variation in the estimating procedure when the nuisance parameters are held at their true values, and \(D(\widehat\eta-\eta)\) represents the first-order effect of estimating those nuisance parameters. This is a justification, not an exact decomposition for every estimator. In a full bootstrap, both the empirical data and the fitted nuisance models vary, so the replicate distribution can reflect both sources of variation and their dependence. A fixed-weight bootstrap holds \(\widehat\eta\) constant and does not reproduce its estimation contribution. The two standard errors therefore need not be equal; there is no general guarantee that the full-pipeline result is larger in every finite sample.

Worked Example: Comparing Full and Fixed-Weight Bootstrap Results

Suppose five hypothetical resamples are used to illustrate two procedures. Refitting all weights and the MSM gives estimates \(1.7, 2.1, 2.5, 2.9, 2.3\) units. Holding the original weights fixed and refitting only the MSM gives \(1.9, 2.1, 2.3, 2.5, 2.2\) units. These values are illustrative replicate outputs, not a claim about which method must be more variable in every data set.

For the full-pipeline estimates, the mean is \(2.3\) units and the squared deviations sum to \(0.80\) squared units. The estimated standard error is therefore

$$ \widehat{SE}_{\mathrm{full}} = \sqrt{\frac{0.80}{4}} = 0.4472\text{ units}. $$

For the fixed-weight estimates, the mean is

$$ \frac{1.9+2.1+2.3+2.5+2.2}{5} = 2.2\text{ units}. $$

Their squared deviations from \(2.2\) sum to \(0.20\) squared units, so

$$ \widehat{SE}_{\mathrm{fixed}} = \sqrt{\frac{0.20}{4}} = 0.2236\text{ units}. $$

In this illustration, the fixed-weight bootstrap reports less variation because it does not refit the probability models. This numerical comparison alone does not prove the fixed-weight estimate is always too small; rather, it shows why it answers a different uncertainty question and may omit a relevant source of variation.

Practical Checks and Common Pitfalls

A bootstrap cannot repair a poorly specified analysis or guarantee reliable inference when the estimator behaves irregularly. Before interpreting the results, check that the independent units were resampled correctly, that each replicate followed the original model-fitting and weight-processing rules, and that the fitting procedure succeeded. The usual bootstrap justification relies on independent sampling units and a sufficiently regular estimator. Sparse treatment histories, probabilities near zero, separation in a fitted model, or severe weight instability can make replicate estimates erratic or cause model fitting to fail.

If a prespecified truncation rule is part of the target analysis, apply that same rule inside every replicate after recalculating the replicate weights. Do not choose a new truncation rule in each replicate based on which choice gives the most appealing result. If a model fails to converge or a bootstrap sample contains no information for a required model component, record the problem and investigate it; silently discarding failed replicates can distort the bootstrap distribution.

  • Wrong: “The weights are already estimated, so I can resample rows and reuse them.” Correction: For full-pipeline uncertainty, resample independent units and refit the treatment and censoring models to recalculate weights.
  • Wrong: “Each visit is an independent observation for resampling.” Correction: Resample the independent unit, ordinarily the person, and retain that unit’s longitudinal record.
  • Wrong: “The full-pipeline bootstrap must always have a larger standard error.” Correction: It includes nuisance-model re-estimation, but finite-sample variability can move in either direction.
  • Wrong: “A large number of replicates fixes unstable weights or model failure.” Correction: More replicates reduce Monte Carlo error; they do not resolve identification, positivity, or fitting problems in the data and models.
Key takeaway: Bootstrap the estimator you actually used. For a weighted longitudinal MSM, each replicate should resample complete independent-unit histories, re-estimate the treatment and censoring models, rebuild the weights under the same rules, and refit the MSM. A fixed-weight bootstrap leaves the weight-estimation step outside the resampling and therefore targets a narrower source of uncertainty.

Check Your Understanding

Try these questions without looking back.

  1. Why is resampling person-visit rows separately inappropriate when people contribute repeated observations?
  2. Name the main model-fitting and weight-calculation steps that must be repeated in a full-pipeline bootstrap replicate.
  3. In what sense does a fixed-weight bootstrap answer a narrower uncertainty question than a full-pipeline bootstrap?
  4. If weight truncation is part of the original analysis, when and how should the truncation rule be applied in each replicate?
  5. Why does increasing the number of bootstrap replicates not resolve separation or extreme-weight problems?
Clinical Biostats