G-Computation and Regression Adjustment
Turning an outcome model into a causal effect by predicting every unit's outcome under each treatment and averaging, and why that is not the same as reading a coefficient off the regression.
Fit a logistic regression of churn on a retention offer and twelve covariates, and the offer's coefficient is \(-0.9\). The finance team asks how many churners the offer prevents per thousand customers. The coefficient cannot answer that. It is a log-odds ratio conditional on every covariate at once, and even with no confounding at all it is a different number from the population effect finance is asking about. G-computation is the procedure that turns the fitted model into the quantity the decision needs.
Standardisation, step by step
G-computation, also called standardisation or the parametric g-formula, computes the adjustment formula with a model in place of cell means. With treatment \(T\), covariates \(X\) and outcome \(Y\):
- Fit an outcome model \(\hat{Q}(t, x) \approx \mathbb{E}[Y \mid T = t, X = x]\) on all the data.
- Set every unit's treatment to 1 and predict \(\hat{Q}(1, x_i)\). Set it to 0 and predict \(\hat{Q}(0, x_i)\).
- Average and contrast:
Averaging over the observed covariate distribution is what makes the estimate marginal: it targets \(\mathbb{E}[Y(1)] - \mathbb{E}[Y(0)]\) for this population, under exchangeability, positivity and consistency given \(X\). Averaging only over the treated units gives the ATT instead. Standard errors come from the bootstrap, refitting the model on each resample, since the plug-in has no simple closed-form variance (Snowden, Rose and Mortimer, 2011, Implementation of G-Computation on a Simulated Data Set, American Journal of Epidemiology 173(7)).
For a linear model with no treatment-covariate interaction, \(\hat{\tau}_{\text{g}}\) equals the treatment coefficient, which is why the distinction is easy to miss. Add an interaction, or a nonlinear link, and the two diverge.
Marginal and conditional are different estimands
The odds ratio shows the divergence with no confounding in sight. Two equally sized strata, treatment randomised within each:
- Stratum A: risk 0.2 untreated, 0.5 treated. Odds ratio \(= (0.5/0.5)/(0.2/0.8) = 4\).
- Stratum B: risk 0.5 untreated, 0.8 treated. Odds ratio \(= (0.8/0.2)/(0.5/0.5) = 4\).
- Pooled: risk 0.35 untreated, 0.65 treated. Odds ratio \(= (0.65/0.35)/(0.35/0.65) \approx 3.45\).
The conditional odds ratio is 4 in every stratum and the marginal odds ratio is 3.45. Nothing is biased. The odds ratio is non-collapsible: the population odds ratio is not an average of stratum odds ratios, so adjusting for a prognostic covariate changes the number even when it confounds nothing (Greenland, Robins and Pearl, 1999, Confounding and Collapsibility in Causal Inference, Statistical Science 14(1)). The risk difference, 0.30 in both strata and 0.30 pooled, is collapsible. G-computation sidesteps the issue by computing risks under each treatment and contrasting them on whatever scale the decision uses.
Fields disagree about which estimand to report. Clinical trials have long reported covariate-adjusted conditional odds and hazard ratios; much of causal epidemiology and nearly all product analytics wants marginal effects, because a rollout acts on the whole population. Neither is wrong, and reporting one while describing it as the other is.
The g-formula over time
Robins introduced the g-formula for treatments that vary over time, where a covariate \(L_k\) is both a confounder for later treatment and affected by earlier treatment (Robins, 1986, A New Approach to Causal Inference in Mortality Studies with a Sustained Exposure Period, Mathematical Modelling 7, 1393-1512). For a treatment sequence \(\bar{a} = (a_0, \dots, a_K)\),
A single regression of \(Y\) on the whole treatment history cannot recover this: conditioning on \(L_k\) blocks part of the effect of earlier treatment, and not conditioning leaves later treatment confounded. G-computation simulates each covariate forward under the planned treatment sequence. A subscription discount that changes engagement, which then changes who receives the next discount, is this structure.
When it breaks
Everything rides on the outcome model. G-computation is consistent only if \(\hat{Q}\) is correctly specified. There is no second route, unlike doubly robust estimators, and in the time-varying g-formula errors compound across every covariate model simulated forward.
Extrapolation is silent. In regions with no treated units the model still predicts \(\hat{Q}(1, x)\), and the prediction enters the average with full weight. Inverse weighting at least shows the problem as huge weights; g-computation shows nothing. Check propensity overlap even when no propensity model is used.
Flexible learners bring regularisation bias. Plugging a gradient-boosted model into step 1 improves fit and biases the average effect, because the learner shrinks the treatment contrast along with everything else, and naive bootstrap intervals do not account for it. Double machine learning and targeted estimators exist to correct exactly this plug-in bias.
It adjusts for what you give it. Including a mediator or a collider among the \(X\) gives a precise, wrong answer. The adjustment set comes from the causal graph, never from which covariates improve the outcome model's fit.
7 flashcards for this concept
Click a card to reveal the answer.