Tutorials › Causal Inference › Parametric G-Formula From Conditional Outcome Models

The G-Formula and Dynamic Regimes · Tutorial 714 of 972

Parametric G-Formula From Conditional Outcome Models

Build a regime-specific mean from sequential covariate and outcome models, and see how each model contributes to the final causal estimate.

Advanced 10 min read

What You'll Learn

  • Define the parametric g-formula for a longitudinal treatment regime.
  • Distinguish covariate transition models from the conditional outcome model.
  • Substitute static or dynamic regime-assigned treatments into the models.
  • Average predictions over covariate histories and the target population.
  • Identify the causal and modeling assumptions needed for interpretation.

From Conditional Models to a Regime-Specific Mean

A longitudinal treatment policy can change more than the treatment received at each visit. Earlier treatment may alter a later covariate, and that covariate may in turn predict the outcome and affect later treatment decisions. To estimate the mean outcome under a specified policy, the analysis must account for the covariate histories that would arise under that policy—not simply hold each person's observed covariates fixed.

The parametric g-formula does this by combining sequential models for covariates with a conditional model for the outcome. It sets treatment values according to a regime, propagates the covariate distribution under those assigned values, predicts outcomes for the resulting histories, and averages those predictions over a target population.

Definition: Let \(L_0\) denote baseline covariates, \(A_t\) treatment at time \(t\), and \(L_{t+1}\) covariates measured after \(A_t\) and before the next treatment. Let \(Y\) be the outcome measured after the final treatment. A treatment regime \(d\) specifies the treatment \(A_t=d_t(\bar L_t)\) at each time, where \(\bar L_t=(L_0,\ldots,L_t)\) is the covariate history available when treatment is assigned. The parametric g-formula is a model-based expression for the mean counterfactual outcome under that regime, obtained by combining conditional models for covariate transitions and the outcome.

For a fixed number \(K\) of treatment occasions, the covariates observed before the last treatment are \(L_0,\ldots,L_{K-1}\), and the treatments are \(A_0,\ldots,A_{K-1}\). Write \(m(\bar l_{K-1},\bar a_{K-1})\) for the conditional mean of \(Y\) given those covariate and treatment histories. Write \(f_t(l_{t+1}\mid \bar l_t,\bar a_t)\) for the conditional distribution of the next covariate. Under regime \(d\), the g-formula is

$$ \psi(d) = \int m\!\left(\bar l_{K-1},\bar d_{K-1}(\bar l)\right) \prod_{t=0}^{K-2} f_t\!\left(l_{t+1}\mid \bar l_t,\bar d_t(\bar l)\right) \,dF_{L_0}^{*}(l_0)\,d\bar l_{1:K-1}. $$

Here \(F_{L_0}^{*}\) is the baseline covariate distribution in the target population. The notation \(\bar d_t(\bar l)\) means that the regime's treatment rule is applied at each time using the covariate history available then. For discrete covariates, the integrals over their values are sums. For continuous covariates, they are integrals. The covariate-transition factors describe how later covariates are distributed under the assigned earlier treatments; they are not treatment-assignment probabilities.

What Must Be Modeled—and What Is Set by the Regime

The formula has two distinct modeling tasks. First, specify a conditional distribution for each covariate that evolves after treatment. Second, specify the conditional mean of the final outcome given the relevant history. The regime supplies the treatment values in these models. Thus, treatment is set to the policy value, while covariate histories are allowed to vary according to the modeled consequences of earlier treatment.

ComponentRole in the formulaWhat happens under regime \(d\)
Baseline distribution \(F_{L_0}^{*}\)Represents the target population at baselineAverage over its covariate distribution
Covariate model \(f_t\)Describes the next covariate given the history so farEvaluate it at the treatments assigned by \(d\)
Outcome model \(m\)Predicts the conditional mean of \(Y\) given the full historyEvaluate it at the regime-assigned treatment history
Treatment assignment mechanismDescribes treatment choices in the observed dataNot multiplied into this intervention formula

A dynamic regime can use the current covariate history—for example, assign a higher dose if a measured symptom score exceeds a threshold. In that case, the assigned treatment at a later visit can differ across the covariate histories generated by the transition models. A static regime instead specifies the same treatment at a given occasion regardless of that history. In either case, treatment values in the conditional models are replaced according to the rule; the covariates are not replaced by fixed observed values.

Worked Example: Reading the Components in a Two-Visit Study

Suppose \(L_0\) is a baseline risk score, \(A_0\) is an initial treatment, \(L_1\) is a symptom score measured afterward, \(A_1\) is a second treatment, and \(Y\) is a health score after the second treatment. A regime specifies \(A_0=d_0(L_0)\) and \(A_1=d_1(L_0,L_1)\). Identify the models needed for its g-formula.

The baseline component is the target distribution of \(L_0\). The sequential covariate model is the distribution of \(L_1\) given \(L_0\) and \(A_0\), written \(f_0(l_1\mid l_0,a_0)\). The conditional outcome model is \(m(l_0,l_1,a_0,a_1)=E(Y\mid L_0=l_0,L_1=l_1,A_0=a_0,A_1=a_1)\).

For each baseline value, the rule first sets \(a_0=d_0(l_0)\). The covariate model is evaluated at that value to represent the symptom scores that could follow the initial treatment. For each resulting symptom score, the rule sets \(a_1=d_1(l_0,l_1)\), and the outcome model predicts the conditional mean. The formula averages those predictions over the symptom-score distribution and then over the target distribution of \(L_0\). This identifies the parts of the calculation without treating the observed symptom score as if it could not change under another initial treatment.

Identification and the Parametric Assumptions

The g-formula is not causal merely because conditional models have been written down. Its causal interpretation relies on the longitudinal identification conditions established for regime-specific counterfactual outcomes. In brief, consistency connects observed outcomes to the counterfactual outcomes for the treatment history actually received; sequential exchangeability rules out unmeasured confounding of each treatment decision given the measured history; and positivity requires support for the treatments the regime assigns within relevant histories. These conditions concern the study and the target regime, not just the quality of a regression fit.

The parametric version adds a modeling requirement: the chosen conditional models must adequately represent the covariate transition distributions and the conditional outcome mean over the histories used by the regime. If a model is misspecified, the resulting plug-in mean can be wrong even when the causal identification conditions hold. Positivity also matters practically: a model's numerical ability to produce a prediction does not establish that the corresponding treatment-history combinations are supported by the data.

Key result: Under consistency, sequential exchangeability, positivity, and correct specification of the relevant conditional models, the g-formula identifies the mean counterfactual outcome under regime \(d\). The formula integrates the outcome mean over the covariate histories that would arise under \(d\), beginning with the target population's baseline distribution.

The basic justification is iterated expectation. Under the regime, first condition on baseline covariates and the subsequent covariate history. The conditional mean of the outcome is then averaged over the regime-specific distribution of that history. Sequential exchangeability and consistency allow the conditional quantities in this counterfactual expectation to be represented by the corresponding observed-data conditional models evaluated at regime-assigned treatments. Applying the law of total expectation successively gives the product of covariate transition distributions in the formula.

$$ \begin{aligned} E(Y^d) &= \int E(Y^d\mid \bar L_{K-1}^d=\bar l)\, dF_{\bar L_{K-1}^d}(\bar l)\\ &= \int m\!\left(\bar l,\bar d_{K-1}(\bar l)\right) \prod_{t=0}^{K-2} f_t\!\left(l_{t+1}\mid \bar l_t,\bar d_t(\bar l)\right) dF_{L_0}^{*}(l_0)\,d\bar l_{1:K-1}. \end{aligned} $$

The first line is an expectation over the covariate history that would occur under the regime. The second line expresses that expectation using the observed conditional outcome and covariate models, with the regime's treatments substituted. This is why the covariate models are essential: they determine the distribution over which outcome predictions are averaged.

Worked Calculations

Worked Example: Substituting a Regime into an Outcome Model

For illustration, suppose a fitted conditional mean model for a health score, measured in points, is

$$ m(x,l,z_0,z_1) =50+2x-4z_0+0.5l-3z_1+z_0z_1, $$

where \(x\) is baseline age in decades above 40, \(l\) is the symptom score, and \(z_t\) indicates receipt of a 10-mg dose at visit \(t\) (zero indicates no dose). Consider the history \(x=2\), \(l=8\), under a regime assigning a 10-mg dose at both visits. The regime therefore gives \(z_0=1\) and \(z_1=1\). Substitution gives

$$ \begin{aligned} m(2,8,1,1) &=50+2(2)-4(1)+0.5(8)-3(1)+(1)(1)\\ &=50+4-4+4-3+1\\ &=52. \end{aligned} $$

The model predicts a conditional mean health score of 52 points for this specified history under the assigned treatments. This is one prediction, not yet the regime-specific population mean: the g-formula must also average over the symptom histories generated under the initial treatment and over the target population's baseline ages.

Worked Example: Averaging Over a Regime-Specific Covariate Distribution

Consider a simplified target population in which every person has the same baseline covariates. Under the first treatment assigned by a regime, suppose the modeled probabilities for the later symptom category are 0.20 for low, 0.50 for medium, and 0.30 for high. These probabilities sum to \(0.20+0.50+0.30=1.00\). Suppose the regime assigns the same second treatment for each category, and the outcome model predicts conditional means of 40, 50, and 60 points for low, medium, and high symptoms, respectively.

The regime-specific mean is the outcome prediction averaged using the covariate distribution under the regime:

$$ \begin{aligned} \psi(d) &=(0.20)(40)+(0.50)(50)+(0.30)(60)\\ &=8+25+18\\ &=51\text{ points}. \end{aligned} $$

The weights are not the proportions of symptom categories among people who happened to receive a particular observed treatment. They are the conditional probabilities from the covariate model evaluated at the regime-assigned earlier treatment. If that earlier treatment changes the symptom distribution, the weights—and therefore the regime-specific mean—can change.

Worked Example: Standardizing Across Baseline Strata

Now suppose the target population has two baseline strata, \(X=0\) and \(X=1\), each containing half the population. Under the specified regime, the covariate model gives low, medium, and high symptom probabilities of \((0.20,0.50,0.30)\) for \(X=0\), and \((0.40,0.40,0.20)\) for \(X=1\). Each row sums to one. The outcome model's conditional mean predictions under the regime are \((40,50,60)\) points for \(X=0\) and \((44,54,64)\) points for \(X=1\), in the same symptom-category order.

Within the \(X=0\) stratum, the averaged prediction is

$$ (0.20)(40)+(0.50)(50)+(0.30)(60)=8+25+18=51\text{ points}. $$

Within the \(X=1\) stratum, it is

$$ (0.40)(44)+(0.40)(54)+(0.20)(64)=17.6+21.6+12.8=52\text{ points}. $$

Finally, average those stratum-specific means using the target population weights:

$$ \psi(d)=(0.50)(51)+(0.50)(52)=25.5+26=51.5\text{ points}. $$

Thus, the model-based mean outcome under this regime for this target population is 51.5 points. A different target population with different baseline-stratum weights could have a different regime-specific mean, even if the conditional models were unchanged.

Common Mistake: Holding Later Covariates Fixed

A tempting shortcut is to set treatment to the regime value in an outcome regression while leaving each person's later covariate at its observed value, then average the predictions. That calculation generally does not implement the g-formula. A later covariate may itself be affected by earlier treatment, so its observed value need not represent the covariate value that would arise under the intervention. The correction is to use the covariate transition model to obtain the distribution of later covariates under the regime, and average outcome predictions over that distribution.

A second error is to multiply by the observed treatment probabilities as if the goal were to reproduce the natural treatment-assignment process. The intervention formula replaces treatment assignment with the regime; its sequential probability factors describe covariate evolution, not the probability that people receive the assigned treatment. This distinction is central to interpreting the formula.

1
Specify the target and regime.
State the baseline population and the treatment rule at each occasion, including any covariates the rule uses.
2
Identify the conditional models.
Use a model for each post-treatment covariate transition and a conditional mean model for the final outcome.
3
Substitute assigned treatments.
Evaluate the transition and outcome models at treatment values specified by the regime for each history.
4
Average over histories and baseline.
Integrate or sum over the covariate histories generated under the regime, then average over the target baseline distribution.
Key takeaway: The parametric g-formula is a sequence of conditional models joined by regime-based treatment substitution and averaging. It predicts the outcome under a policy by allowing the covariate history to evolve as that policy would make it evolve, rather than conditioning on the history observed under the actual treatment process.

Check Your Understanding

Use the definitions and calculations above to answer these questions.

  1. In a two-treatment-occasion study, which conditional distribution determines the modeled distribution of the covariate measured between the treatments?
  2. Why does a regime-specific mean require averaging over later covariates rather than simply fixing each later covariate at its observed value?
  3. If a dynamic rule assigns treatment using the current symptom score, at what stage is that rule applied in the g-formula?
  4. In the second worked calculation, what does the weight 0.30 represent, and why is it not an observed treatment probability?
  5. Name the causal identification conditions and the additional parametric modeling requirement needed for a causal interpretation of the parametric g-formula.
Clinical Biostats