Tutorials › Causal Inference › A Two-Visit Calculation of Stabilized Treatment Weights

Marginal Structural Models · Tutorial 736 of 972

A Two-Visit Calculation of Stabilized Treatment Weights

Work through two-visit stabilized treatment-weight calculations, checking each numerator, denominator, visit-specific ratio, and cumulative weight against the subject’s observed treatment history.

Advanced 10 min read

What You'll Learn

  • Identify the observed-treatment probability needed at each visit for a binary treatment.
  • Distinguish numerator models from denominator models in a two-visit stabilized weight.
  • Calculate a visit-specific probability ratio using the subject’s actual treatment value.
  • Multiply visit-specific ratios to obtain a cumulative stabilized treatment weight.
  • Check that each probability is conditioned on the correct treatment and covariate history.
  • Recognize what a weight calculation does and does not establish about causal validity.

From Treatment Histories to Individual Weights

In longitudinal studies, a person’s treatment at a later visit may depend on earlier treatment and on health measurements that also predict the outcome. A marginal structural model uses treatment weights to reweight the observed data so that treatment histories are less tied to those measured confounders. The calculations can look abstract until each probability is matched to one person’s actual history.

This tutorial works through the arithmetic for a binary treatment observed at two visits. At each visit, the weight contribution is a ratio: a numerator probability from a simpler treatment model divided by a denominator probability from a model that conditions on the measured covariate history. The cumulative stabilized weight is the product of the two visit-specific ratios.

Definition: Let \(A_{i1}\) and \(A_{i2}\) denote person \(i\)’s binary treatment at visits 1 and 2, with values 0 or 1. Let \(L_{i0}\) denote measured baseline covariates and \(L_{i1}\) measured covariates available before treatment at visit 2. A two-visit stabilized treatment weight is the product, across the visits, of the probability of the treatment actually received under a numerator model divided by the probability of that same treatment under a denominator model.

For the specific models used here, the visit-1 numerator conditions on no covariates, and the visit-1 denominator conditions on baseline covariates. At visit 2, the numerator conditions on prior treatment, while the denominator also conditions on measured baseline and time-varying covariates. Other numerator specifications can be appropriate for other estimands; the conditioning sets must therefore be stated rather than inferred from the word “stabilized.”

$$ SW_i(2) = \frac{P(A_{i1}\mid \text{numerator history})} {P(A_{i1}\mid \text{denominator history})} \times \frac{P(A_{i2}\mid \text{numerator history})} {P(A_{i2}\mid \text{denominator history})} $$

With the models specified above, this becomes

$$ SW_i(2) = \frac{P(A_{i1})}{P(A_{i1}\mid L_{i0})} \times \frac{P(A_{i2}\mid A_{i1})} {P(A_{i2}\mid A_{i1},L_{i0},L_{i1})}. $$

Every probability in this expression refers to the probability of the observed value of treatment for person \(i\). If the person received treatment (\(A_{ik}=1\)), use the modeled probability of 1. If the person did not receive treatment (\(A_{ik}=0\)), use the probability of 0, which is one minus the modeled probability of 1.

What the Two Models Contribute

The denominator model estimates treatment probabilities conditional on measured history that predicts treatment. In this example, it includes baseline covariates at visit 1 and baseline plus time-varying covariates at visit 2. The numerator model is simpler: its visit-1 probability is marginal, and its visit-2 probability depends on prior treatment. Including prior treatment in the second numerator preserves the structure of treatment histories while leaving out the measured covariates included in the denominator.

These probabilities are usually estimated from specified treatment models, such as logistic regression models. They are not automatically equal to crude proportions in a small subgroup. In the arithmetic examples below, treat the stated probabilities as fitted values supplied by the models. The calculation itself does not show that the models are correctly specified or that all confounders were measured.

Probability check: For a binary treatment, if a model gives \(P(A_{ik}=1\mid H)=q\) for history \(H\), then \(P(A_{ik}=0\mid H)=1-q\). Use \(q\) for a person with observed treatment 1 and \(1-q\) for a person with observed treatment 0. The numerator and denominator at a visit must both refer to that same observed treatment value.

Worked Example: One Person Treated at Visit 1 and Untreated at Visit 2

Suppose a hypothetical person has history \(A_{i1}=1\), \(A_{i2}=0\). The fitted numerator probability of treatment at visit 1 is \(P(A_{i1}=1)=0.40\), while the denominator probability for this person’s baseline covariates is \(P(A_{i1}=1\mid L_{i0})=0.70\). At visit 2, the numerator model gives \(P(A_{i2}=1\mid A_{i1}=1)=0.60\), and the denominator model gives \(P(A_{i2}=1\mid A_{i1}=1,L_{i0},L_{i1})=0.25\).

At visit 1, the person received treatment, so use probabilities of 1:

$$ SW_{i1}=\frac{0.40}{0.70}=\frac{4}{7}\approx 0.5714. $$

At visit 2, the person did not receive treatment. Therefore use the probabilities of 0, not the probabilities of 1. The visit-2 numerator probability is \(1-0.60=0.40\), and the denominator probability is \(1-0.25=0.75\):

$$ SW_{i2}=\frac{0.40}{0.75}=\frac{8}{15}\approx 0.5333. $$

The cumulative weight is the product of the visit-specific ratios:

$$ SW_i(2)=\frac{0.40}{0.70}\frac{0.40}{0.75} =\frac{4}{7}\frac{8}{15} =\frac{32}{105} \approx 0.3048. $$

The weight is dimensionless. Its value below 1 is not an error: both observed treatment choices were less probable under the numerator models than under the corresponding denominator models, so both ratios were below 1.

A Short Justification for Multiplying the Ratios

The product form follows from the sequential factorization of a treatment history. Given the modeled histories, the probability of observing the two-visit treatment sequence is the probability of the visit-1 treatment multiplied by the conditional probability of the visit-2 treatment given visit-1 treatment and the relevant covariates. Applying this factorization to the numerator and denominator treatment models gives a ratio for the whole history that is the product of the visit-specific ratios:

$$ \frac{ P(A_{i1}\mid \text{numerator history}) P(A_{i2}\mid A_{i1},\text{numerator history}) }{ P(A_{i1}\mid \text{denominator history}) P(A_{i2}\mid A_{i1},\text{denominator history}) } = \prod_{k=1}^{2} \frac{ P(A_{ik}\mid \text{numerator history at }k) }{ P(A_{ik}\mid \text{denominator history at }k) }. $$

This is a factorization of probabilities, not a claim that the two visit-specific treatment assignments are independent. The second probability is conditional on the earlier treatment, and the histories in the denominator can include covariates measured before the corresponding treatment.

Worked Example: Checking a Treatment History Before Calculating

Consider a second hypothetical person with \(A_{i1}=0\) and \(A_{i2}=1\). Suppose the visit-1 numerator and denominator models give probabilities of treatment 1 equal to 0.40 and 0.30, respectively. At visit 2, for this person’s history with \(A_{i1}=0\), suppose the numerator model gives \(P(A_{i2}=1\mid A_{i1}=0)=0.25\) and the denominator model gives \(P(A_{i2}=1\mid A_{i1}=0,L_{i0},L_{i1})=0.20\).

First check the observed visit-1 value: \(A_{i1}=0\). The numerator probability of the observed value is \(1-0.40=0.60\), and the denominator probability is \(1-0.30=0.70\). Thus,

$$ SW_{i1}=\frac{0.60}{0.70}=\frac{6}{7}\approx 0.8571. $$

At visit 2, \(A_{i2}=1\), so use the stated probabilities of 1 directly:

$$ SW_{i2}=\frac{0.25}{0.20}=1.25. $$

The cumulative weight is

$$ SW_i(2)=\frac{6}{7}\times 1.25 =\frac{6}{7}\times\frac{5}{4} =\frac{15}{14} \approx 1.071. $$

The visit-2 probabilities are specifically for people with \(A_{i1}=0\). Substituting probabilities from the \(A_{i1}=1\) history would calculate a different person’s visit-2 ratio, even if the numerical probabilities happened to look plausible.

Comparing Several Subjects

A history check is easiest when the treatment values and modeled probabilities are displayed together. The following table continues with hypothetical fitted probabilities. At visit 1, the numerator probability of treatment 1 is 0.40 for everyone. At visit 2, the numerator probability of treatment 1 is 0.60 when \(A_{i1}=1\) and 0.25 when \(A_{i1}=0\). Denominator probabilities vary by each person’s measured covariates and treatment history.

Person\((A_{i1},A_{i2})\)Visit-1 denominator \(P(A_{i1}=1\mid L_{i0})\)Visit-2 denominator \(P(A_{i2}=1\mid A_{i1},L_{i0},L_{i1})\)
1(1, 0)0.700.25
2(0, 1)0.300.20
3(1, 1)0.700.25

Worked Example: Completing the Weight for a Third History

For person 3, the observed history is \((A_{i1},A_{i2})=(1,1)\). At visit 1, the numerator and denominator probabilities of the observed value 1 are 0.40 and 0.70. At visit 2, because prior treatment was \(A_{i1}=1\), the numerator probability of treatment 1 is 0.60; the denominator probability for this person’s measured history is 0.25.

The first visit-specific ratio is

$$ SW_{i1}=\frac{0.40}{0.70}=\frac{4}{7}. $$

The second visit-specific ratio uses the \(A_{i1}=1\) numerator history and the observed visit-2 value 1:

$$ SW_{i2}=\frac{0.60}{0.25}=\frac{12}{5}=2.4. $$

Multiplying gives

$$ SW_i(2)=\frac{4}{7}\frac{12}{5} =\frac{48}{35} \approx 1.371. $$

The visit-2 ratio is greater than 1, but the visit-1 ratio is less than 1. The cumulative weight is their product; it is not obtained by adding the ratios or by looking only at the last visit.

Assumptions and Interpretation

The arithmetic defines the weight once the fitted probabilities and observed history are given. A causal interpretation of weighting requires more than correct arithmetic. In particular, the denominator probabilities must adequately represent treatment assignment conditional on the relevant measured history; treatment probabilities for the histories being analyzed must be positive; and the causal analysis requires consistency and sequential exchangeability, meaning no unmeasured confounding of treatment at each visit after conditioning on the relevant recorded past. These conditions are substantive and modeling assumptions, not facts established by calculating a weight.

Positivity matters directly to the calculation: if a denominator probability for an observed treatment is zero, the ratio is undefined; if it is very close to zero, the ratio can be very large. The numerator probabilities must also correspond to the specified numerator model and the observed treatment. Neither extreme nor moderate values alone certify that the assumptions hold.

A stabilized weight changes the relative contribution of records compared with an unstabilized inverse-probability weight. It does not mean that each person is literally assigned a fractional number of people, nor does a weight below 1 indicate that the person should be discarded. The weights are inputs to subsequent marginal structural model estimation; their causal role depends on the design, assumptions, and model specifications. The mechanics of fitting that outcome model are a separate step.

Common Mistakes

  • Using the probability of treatment 1 for everyone. For an observed treatment of 0, the required probability is \(1-P(A_{ik}=1\mid H)\). Use the probability of the actual treatment value in both numerator and denominator.
  • Mixing histories across visits. The visit-2 numerator probability must match the person’s prior treatment, and the denominator must match that treatment plus the specified covariate history.
  • Multiplying the wrong quantities. The cumulative stabilized weight is the product of the two ratios. Check each division and then check the product separately.
  • Calling a computed weight proof of no confounding. Weight calculation does not verify sequential exchangeability or correct model specification. It only applies the stated probability models to the observed histories.
Key takeaway: At each visit, identify the person’s observed treatment value, obtain its probability under the numerator model and denominator model, divide numerator by denominator, and multiply the visit-specific ratios. A correct history check is as important as the arithmetic.

Check Your Understanding

For each question, keep the observed treatment value and its conditioning history explicit.

  1. A subject has \(A_{i1}=0\). If the numerator model gives \(P(A_{i1}=1)=0.35\) and the denominator model gives \(P(A_{i1}=1\mid L_{i0})=0.50\), what is the visit-1 ratio?
  2. At visit 2, a subject has \(A_{i2}=0\). The numerator model gives probability 0.70 for treatment 1 and the denominator gives probability 0.80 for treatment 1. What probability of the observed value belongs in each part of the ratio?
  3. Why must the visit-2 numerator probability be selected using the subject’s observed \(A_{i1}\)?
  4. If the visit-specific ratios are 0.80 and 1.50, calculate the cumulative two-visit stabilized weight.
  5. Does a finite, correctly calculated weight establish that sequential exchangeability holds? Explain briefly.
Clinical Biostats