Why the Averaging Distribution Matters
In longitudinal studies, a covariate measured after an initial treatment can affect both a later treatment and the outcome. It is then a time-varying confounder for the later treatment, but it may also have been changed by the earlier treatment. This feedback means that the people who actually receive a later treatment need not have the covariate distribution that would arise if everyone followed a specified treatment regime.
G-computation handles this distinction by predicting outcomes under the regime and averaging those predictions over the covariate histories generated by that regime. Merely conditioning on observed treatment instead selects people according to the treatment process. The two procedures can use the same conditional outcome model and still produce different means because they average over different distributions.
The Two Distributions
For clarity, first consider a setting with no baseline covariates. Let \(q(l)=P(L_1=l\mid A_0=a_0)\), the observed distribution of the later covariate among those given the initial treatment \(a_0\). Under consistency and exchangeability for the initial treatment, this identifies the distribution \(P(L_1^{a_0}=l)\). Write \(e(l)=P(A_1=a_1\mid A_0=a_0,L_1=l)\) for the probability of receiving the later treatment \(a_1\) at covariate value \(l\).
Among people with \(A_0=a_0\) who are also observed to receive \(A_1=a_1\), covariate values with larger \(e(l)\) are more likely to appear. The resulting conditional distribution is
provided the denominator is positive. By contrast, g-computation averages over \(q(l)\), not over this treatment-selected distribution. Under consistency, sequential exchangeability, and positivity, the two-time g-formula is
In this formula, the conditional outcome mean supplies the predicted outcome at each covariate value under the specified treatments. The factor \(q(l)\) then represents how common that covariate value would be under the initial treatment in the target regime. Conditioning on observed \(A_1=a_1\) instead weights covariate values by both \(q(l)\) and their chance of receiving that later treatment.
Why Later Treatment Changes the Covariate Mix
The distribution among people observed to receive \(a_1\) is a reweighted version of \(q\). In a discrete setting, let \(C=\sum_l q(l)e(l)\), with \(C>0\). The selected distribution equals \(q(l)\) at every value if and only if
For values in the support of \(q\), division by \(q(l)>0\) gives \(e(l)=C\). Thus the two distributions agree exactly when \(e(l)\) is constant on the support of \(q\), or equivalently constant \(q\)-almost surely. It is not enough to say that \(e(l)\) varies somewhere: variation outside the support of \(q\) has no effect. This result concerns equality of distributions; even when the distributions differ, the two averages of an outcome model can coincide if that model is constant over the affected covariate values.
The distinction is especially important under treatment-confounder feedback. The initial treatment changes \(L_1\), and \(L_1\) in turn predicts both later treatment and outcome. Conditioning on the later treatment therefore selects among the \(L_1\) values created under the initial treatment. G-computation instead keeps the distribution of \(L_1\) that belongs to the regime and averages the regime-specific outcome predictions over it.
Worked Example: A Later Treatment Selects a Different Covariate Mix
Suppose a hypothetical longitudinal study has binary \(L_1\). Under \(A_0=1\), assume \(P(L_1=1\mid A_0=1)=0.8\), so \(P(L_1=0\mid A_0=1)=0.2\). Among people with \(A_0=1\), suppose \(P(A_1=1\mid L_1=1)=0.9\) and \(P(A_1=1\mid L_1=0)=0.3\). Finally, suppose the conditional outcome risks under \(A_0=1,A_1=1\) are 0.40 for \(L_1=1\) and 0.10 for \(L_1=0\). Take these conditional risks as identified under the assumptions stated above.
G-computation. The regime \((1,1)\) has \(L_1=1\) probability 0.8 and \(L_1=0\) probability 0.2. Its mean outcome risk is
Observed treatment conditioning. Of those with \(A_0=1\), the proportions who also receive \(A_1=1\) from the two covariate groups are \((0.8)(0.9)=0.72\) and \((0.2)(0.3)=0.06\). The total is \(0.78\). Thus, among those observed to receive both treatments,
Their observed mean risk, using the same two conditional risks, is \((12/13)(0.40)+(1/13)(0.10)=4.9/13\approx0.3769\). That is about 3.69 percentage points higher than the g-computation estimate of 0.34. The difference arises because the observed group is about 92.3% \(L_1=1\), whereas the regime-specific distribution is 80% \(L_1=1\). The observed mean describes the selected group; the g-computation mean targets the specified regime.
Derivation of the Selection Formula
The expression for the covariate distribution among later-treated people follows directly from conditional probability. First, the joint probability of \(L_1=l\) and \(A_1=a_1\), among those with \(A_0=a_0\), factors into the probability of \(L_1=l\) and the conditional probability of later treatment:
Summing over all covariate values gives the probability of later treatment \(a_1\) among those with \(A_0=a_0\):
Dividing the joint probability by this marginal probability yields \(P(L_1=l\mid A_0=a_0,A_1=a_1)\), as stated. The reweighting is therefore a consequence of selecting people by their observed later treatment, not a special feature of a particular outcome model.
Worked Example: Variation Outside the Support Does Not Shift the Distribution
Suppose the regime-specific covariate distribution puts all its mass at \(L_1=0\): \(q(0)=1\) and \(q(1)=0\). Let the later-treatment probabilities be \(e(0)=0.5\) and \(e(1)=0.2\). The treatment probability varies across the two possible covariate values, but \(L_1=1\) never occurs under this distribution.
The denominator is \((1)(0.5)+(0)(0.2)=0.5\), which is positive. Reweighting gives
The selected distribution equals \(q\), even though \(e(0)\ne e(1)\), because \(e\) is constant on the support of \(q\): that support contains only \(L_1=0\). In contrast, if \(q(0)=q(1)=0.5\) with the same treatment probabilities, the unnormalized weights are 0.25 and 0.10, and the selected probabilities are \(5/7\) for \(L_1=0\) and \(2/7\) for \(L_1=1\). In that case treatment probability varies on the support, so the distribution shifts.
Different Initial Treatments, Different Regime Distributions
The distribution to use in g-computation depends on the earlier treatment specified by the regime. Even if the later treatment probability function is unchanged, different initial treatments can produce different distributions of the covariate that predicts later treatment and outcome. An observed group conditioned on both treatments can therefore differ from the relevant regime distribution in more than one way.
Worked Example: Comparing Two Initial-Treatment Regimes
Continue with a hypothetical example in which \(P(L_1=1\mid A_0=0)=0.2\), while \(P(L_1=1\mid A_0=1)=0.8\). Let the probabilities of \(A_1=1\) at \(L_1=1\) and \(L_1=0\) be 0.9 and 0.3, respectively, for either initial treatment. Suppose the conditional outcome risks under \(A_1=1\) are 0.25 for \(A_0=0,L_1=1\), 0.05 for \(A_0=0,L_1=0\), and, as before, 0.40 and 0.10 for \(A_0=1\) at \(L_1=1\) and 0.
For regime \((0,1)\), g-computation uses the distribution \(P(L_1=1\mid A_0=0)=0.2\):
Among people observed with \(A_0=0,A_1=1\), the unnormalized covariate weights are \((0.2)(0.9)=0.18\) for \(L_1=1\) and \((0.8)(0.3)=0.24\) for \(L_1=0\). The total is 0.42, so the selected probability of \(L_1=1\) is \(0.18/0.42=3/7\), not 0.2. Their observed mean risk is \((3/7)(0.25)+(4/7)(0.05)=0.95/7\approx0.1357\).
The regime-specific contrast \(E[Y^{1,1}]-E[Y^{0,1}]\) is \(0.34-0.09=0.25\), or 25 percentage points. The difference between the observed means among people with both treatments, \(0.3769-0.1357\approx0.2412\), is not that regime contrast. Both observed means use distributions selected by later treatment; each regime mean instead uses the covariate distribution generated by its own initial treatment.
How to Keep the Target Clear
A conditional outcome model and an averaging distribution answer different parts of the causal calculation. The model asks what outcome mean is associated with each covariate history under the specified treatment values, subject to the identification assumptions. The distribution determines how those histories are represented in the target population under the regime. Replacing the latter with the distribution among observed later-treated people changes the target.
The difference is not automatically a bias in every numerical situation: if the conditional outcome mean is constant across values whose probabilities shift, both averages can match. Nor does the fact that an observed treated-group mean differs from a g-computation mean by itself show which estimate is correct; the target estimand and assumptions determine the interpretation. The key is not to label an observed-treatment conditional mean as a regime mean without checking its averaging distribution.
Common Mistake
- Wrong reasoning: “I fit the outcome model among people with the observed treatment and averaged their outcomes, so I have the mean under that treatment regime.” This overlooks that the observed later-treated group is selected according to \(e(l)\).
- Correction: For a regime-specific mean, predict the outcome under the regime at each relevant covariate value and average using the covariate distribution induced by the regime. In the two-time setting, that is \(q(l)=P(L_1=l\mid A_0=a_0)\), not generally \(P(L_1=l\mid A_0=a_0,A_1=a_1)\).
- Overstatement to avoid: “Any variation in later-treatment probability changes the covariate distribution.” It changes the distribution only if that variation occurs on the support of \(q\). Equality holds when \(e(l)\) is constant \(q\)-almost surely, assuming a positive denominator.
Check Your Understanding
Use the distinction between an outcome model and its averaging distribution to answer these questions.
- In the two-time setup, what distribution does g-computation use to average conditional outcome predictions under regime \((a_0,a_1)\)?
- If \(q(0)=q(1)=0.5\), \(e(0)=0.4\), and \(e(1)=0.8\), calculate the selected probability of \(L_1=1\) among those with \(A_0=a_0,A_1=a_1\).
- Why can an observed mean among people who received both treatments differ from \(E[Y^{a_0,a_1}]\), even when the conditional outcome risks are correctly estimated?
- Suppose \(q\) assigns probability zero to every covariate value where \(e(l)\) differs from its value on the support of \(q\). Does treatment selection change the covariate distribution? Explain.
- Can the g-computation and observed-treatment averages be numerically equal even when their covariate distributions differ? Give a condition under which this can happen.