Tutorials › Marginal Structural Models › Deriving Longitudinal Treatment Weights by the Chain Rule

Inverse Probability of Treatment Weights · Tutorial 82 of 501

Deriving Longitudinal Treatment Weights by the Chain Rule

See how the chain rule produces a weight for an entire treatment history and why that weight can reweight observed data toward a specified treatment regime.

Advanced 11 min read

What You'll Learn

  • Define the pre-treatment history and sequential treatment probability at each time.
  • Derive the product of treatment probabilities along an observed history.
  • Show algebraically how inverse weights cancel treatment-mechanism factors.
  • Interpret the weighted trajectory distribution under positivity and causal assumptions.
  • Diagnose extreme or undefined weights and distinguish unstabilized from stabilized weights.

Why a Longitudinal Weight Is a Product

With repeated treatment, a person’s treatment history is assigned one decision at a time. The chance of receiving the treatment observed at a later time can depend on earlier treatment and on covariates measured before that decision. Consequently, the probability of an entire treatment history is built from sequential conditional probabilities, not from one probability that ignores the sequence.

Let \(t=1,\ldots,K\) index treatment occasions. Write \(A_t\) for treatment at time \(t\), \(V\) for baseline covariates, and \(L_t\) for covariates measured before \(A_t\). Use \(\bar A_t=(A_1,\ldots,A_t)\) and \(\bar L_t=(L_1,\ldots,L_t)\). The information available immediately before treatment at time \(t\) is \(H_t=(V,\bar L_t,\bar A_{t-1})\), where \(\bar A_0\) is empty. For a specified history \(\bar a=(a_1,\ldots,a_K)\), the relevant probability at time \(t\) is evaluated at \(A_t=a_t\) and the person’s observed pre-treatment history.

Definition: The sequential treatment probability at time \(t\) is \(g_t(a_t\mid H_t)=P(A_t=a_t\mid H_t)\). For an individual with observed history \(\bar A_K\), the longitudinal treatment probability is \(\prod_{t=1}^{K}g_t(A_t\mid H_t)\), and the unstabilized inverse probability treatment weight is \(W_K=\prod_{t=1}^{K}1/g_t(A_t\mid H_t)\).

The product is evaluated along the individual’s realized history. Thus, its factors can differ between people, and the factor at time \(t\) conditions on the covariate and treatment history available at that time. These are conditional probabilities in the true treatment mechanism; in practice, they are replaced by estimates.

Derivation From Sequential Factorization

The chain rule factors a joint distribution into successive conditional distributions. In longitudinal data, factor the observed-data distribution in temporal order: first baseline covariates, then each pre-treatment covariate vector and treatment, followed by the outcome \(Y\). For discrete variables, one version of this factorization is

$$ p(v,\bar l_K,\bar a_K,y) = p(v)\prod_{t=1}^{K} p(l_t\mid v,\bar l_{t-1},\bar a_{t-1}) g_t(a_t\mid h_t) \,p(y\mid v,\bar l_K,\bar a_K). $$

For continuous variables, the corresponding terms are densities; the same factorization and cancellation apply. The covariate factor at time \(t\) conditions on earlier treatments, while the treatment factor conditions on the covariates measured before that treatment. This ordering matters: \(L_t\) is not treated as a cause of the earlier \(A_{t-1}\).

Result: In the sequential factorization, the treatment-mechanism contribution to the probability of the observed trajectory is \(\prod_{t=1}^{K}g_t(A_t\mid H_t)\). Multiplication by \(W_K\) cancels that contribution, leaving the baseline, covariate-transition, and outcome factors.

This is a factorization of the observed trajectory density, not generally a claim that \(\prod_t g_t\) equals a conditional probability given the entire covariate sequence. Later covariates may themselves be affected by earlier treatment. Conditioning on all covariates at once can therefore describe a different conditional distribution from the sequential treatment mechanism.

Worked Example: Computing a Three-Time Weight

Suppose a person receives \(A_1=1,A_2=0,A_3=1\). At the person’s respective pre-treatment histories, the probabilities of these observed decisions are \(0.80\), \(0.30\), and \(0.60\). Find the probability assigned to the observed sequence by the sequential mechanism and its unstabilized weight.

The chain-rule product along this realized history is \(0.80\times0.30\times0.60=0.144\). Thus, the sequential mechanism assigns probability \(0.144\) to this sequence along the realized path. Its inverse is \(1/0.144=6.944\ldots\), so the person’s weight is approximately \(6.94\).

The factors are not three marginal probabilities such as \(P(A_t=a_t)\). Each is conditional on the history available just before that treatment. Replacing them with marginal probabilities would discard the dependence on past treatment and covariates that defines the longitudinal mechanism.

What the Inverse Does

At a single time, inverse weighting has a simple conditional identity. Suppose \(g_t(a\mid H_t)>0\) for the treatment value of interest. Given \(H_t\), the indicator \(I(A_t=a)\) equals one with probability \(g_t(a\mid H_t)\). Therefore,

$$ E\left[\left.\frac{I(A_t=a)}{g_t(a\mid H_t)}\right|H_t\right] = \frac{P(A_t=a\mid H_t)}{g_t(a\mid H_t)} =1. $$

The equality says that, within a given pre-treatment history, the expected weighted contribution from people receiving \(a\) is one unit per person in that history. It does not say every finite sample will balance exactly. The analogous longitudinal operation uses the product of inverse probabilities, with each factor canceling its corresponding treatment factor.

To see this cancellation over a complete trajectory, fix a treatment regime \(\bar a\), and retain only observed individuals with \(\bar A_K=\bar a\). Their trajectory density is the factorization above with the treatment factors evaluated at \(\bar a\). Multiplying by \(I(\bar A_K=\bar a)/\prod_t g_t(a_t\mid H_t)\) removes those factors. The resulting density over \(V,\bar L_K,Y\) is

$$ p(v)\prod_{t=1}^{K} p(l_t\mid v,\bar l_{t-1},\bar a_{t-1}) \,p(y\mid v,\bar l_K,\bar a_K). $$

This is the trajectory distribution generated by setting treatment to \(\bar a\) and retaining the observed covariate-transition and outcome laws for the histories under that regime. To interpret it as a distribution of potential outcomes, consistency and sequential exchangeability are additionally needed: at each time, conditional on \(H_t\), treatment assignment must be independent of the relevant future potential outcomes. Treatment positivity is also required: the regime’s treatment values must have positive conditional probability at histories that can arise under that regime. Under these assumptions, the weighted observed trajectories represent the corresponding regime-specific causal distribution.

Result: Let \(f(V,\bar L_K,Y)\) be an integrable function. Under the factorization above and positivity, $$ E\left[ \frac{I(\bar A_K=\bar a)f(V,\bar L_K,Y)} {\prod_{t=1}^{K}g_t(a_t\mid H_t)} \right] = E^{\bar a}[f(V,\bar L_K,Y)], $$ where the right side is expectation under the distribution generated by setting treatments to \(\bar a\). If consistency and sequential exchangeability hold, this is the corresponding causal regime expectation.

Proof. Expand the expectation on the left as an integral (or sum) over observed trajectories. The indicator restricts the integral to \(\bar A_K=\bar a\). Substitute the sequential factorization of the joint density. On that restricted set, the denominator is \(\prod_t g_t(a_t\mid H_t)\), which cancels the same product in the density. The remaining integrand is \(f\) times \(p(v)\prod_t p(l_t\mid v,\bar l_{t-1},\bar a_{t-1})p(y\mid v,\bar l_K,\bar a_K)\), exactly the regime-specific trajectory density. Integrating gives the stated expectation. Integrability ensures the expectations are defined, and positivity ensures the denominators are nonzero on the histories being weighted. \(\square\)

Worked Example: Weighted Counts Across Two Histories

Suppose 200 people are split evenly between two pre-treatment history groups at time 2, so each group contains 100 people. In both groups, \(P(A_1=1)=0.50\). Among those with \(A_1=1\), the time-2 probability of \(A_2=1\) is \(0.80\) in group X and \(0.20\) in group Z. Calculate the expected weighted count for the history \((A_1,A_2)=(1,1)\) in each group.

For group X, the expected observed count receiving this history is \(100(0.50)(0.80)=40\). Each such person receives weight \(1/(0.50\times0.80)=2.5\). The expected weighted count is \(40(2.5)=100\).

For group Z, the expected observed count is \(100(0.50)(0.20)=10\). Each receives weight \(1/(0.50\times0.20)=10\), giving \(10(10)=100\). Thus the expected weighted count restores 100 contributions from each group, despite different treatment probabilities. This calculation is an expectation under the assignment mechanism, not a promise of exact balance in a realized sample.

Stabilization, Alternatives, and Diagnostics

An unstabilized weight uses one in the numerator at every time. A common alternative is the stabilized weight, which replaces those ones with numerator probabilities that condition on a smaller, prespecified history, often past treatment. For example, a three-time stabilized weight may be written

$$ SW_K= \prod_{t=1}^{K} \frac{P(A_t\mid \bar A_{t-1})} {P(A_t\mid H_t)}. $$

The numerator changes the target weighted treatment distribution and can reduce variability; the denominator remains the sequential probability conditional on the measured pre-treatment history. Stabilization does not repair a denominator probability near zero, and a stabilized weight is not the same quantity as the pure inverse probability of the observed treatment history.

The principal alternative for estimating regime-specific outcomes is the parametric g-formula, which models and combines covariate-transition and outcome distributions rather than reweighting by inverse treatment probabilities. Outcome regression is another modeling strategy. These approaches have different modeling and extrapolation demands; inverse weighting makes the treatment assignment mechanism explicit, but can be unstable when assignment probabilities are small.

In an applied analysis, inspect the distribution of weights and the sequential probabilities that generated them. Look for very large values, a long right tail, or histories with estimated probability zero. Also check weighted covariate balance across treatment histories at each time, not only at baseline. A large maximum weight or poor balance can signal practical positivity problems, a misspecified treatment model, or data-processing errors. The mean of unstabilized weights need not be exactly one in a finite sample, so it is not by itself a definitive diagnostic.

Worked Example: A Stabilized Weight Is Not the Same Weight

For a person with treatment history \((1,0,1)\), suppose the denominator probabilities are \(0.80,0.30,0.60\), as above, and the chosen numerator probabilities for the observed decisions are \(0.60,0.40,0.70\). Calculate both weights.

The unstabilized weight is \(1/(0.80\times0.30\times0.60)=1/0.144\approx6.944\). The stabilized weight is \((0.60\times0.40\times0.70)/(0.80\times0.30\times0.60)=0.168/0.144=7/6\approx1.167\).

The numerator product is not an extra treatment probability to invert. It is a deliberate component of the stabilized ratio. In particular, the stabilized value \(1.167\) cannot be substituted for the unstabilized inverse probability when applying the cancellation identity stated for \(W_K\).

Common Mistake: Treating the Product as a Marginal Probability

A frequent error is to multiply marginal probabilities such as \(P(A_1=a_1)P(A_2=a_2)\), or to calculate one joint probability while ignoring evolving covariate histories. That is not the sequential treatment mechanism unless the required independence conditions happen to hold. The correction is to identify \(H_t\) at each occasion and use \(P(A_t=a_t\mid H_t)\) at that occasion.

A second error is to treat an inverse weight as a guarantee that confounding has been removed. The algebra cancels the modeled treatment factors. A causal interpretation still requires consistency, sequential exchangeability, and positivity, and the probabilities used in practice must adequately represent the treatment mechanism. No amount of inversion creates information about a treatment that was never observed at a relevant history.

Key takeaway: A longitudinal inverse treatment weight is the inverse of the product of conditional probabilities for the treatments actually received, each evaluated at its own pre-treatment history. It reweights by canceling sequential treatment factors; its causal interpretation depends on positivity, consistency, and sequential exchangeability.

Check Your Understanding

Answer each question, then compare with the worked solutions below.

  1. At two times, the observed treatment probabilities are \(0.25\) and \(0.80\). What is the probability product and the unstabilized weight?
  2. Why is \(\prod_t P(A_t=a_t)\) generally not the longitudinal treatment probability?
  3. State the positivity condition needed to weight a specified treatment history.
  4. Does a stabilized weight equal the inverse probability of the observed history? Explain.

Solutions. (1) The product is \(0.25\times0.80=0.20\), and its inverse is \(1/0.20=5\). (2) The relevant factors are conditional on each pre-treatment history, which can include past treatment and covariates; marginal probabilities discard that conditioning. (3) Each specified treatment value must have positive conditional probability at the histories to which the regime assigns positive probability, so the denominators are nonzero there. (4) No. A stabilized weight is a product of numerator-to-denominator probability ratios; its numerator alters the weight and it is not simply the inverse denominator product.

Clinical Biostats