Ask Mallard

Marginal standardization and g-computation

G-computation, also called marginal standardization, uses a fitted model to predict what would have happened if everyone had been exposed and if nobody had been, then contrasts those averages.

What question does this help answer?

It converts a model coefficient into the quantity a clinician can act on: an absolute risk under each condition, and a risk difference or risk ratio between them. An odds ratio rarely answers "how many fewer events"; this does.

How it works in plain language

Fit the model as usual. Then take the whole dataset, set the exposure to "treated" for everyone, and average the predicted risks. Repeat with the exposure set to "untreated" for everyone. The two averages are standardized risks over the actual covariate distribution of the study population, and their difference is the marginal effect. Nothing about the fitting changed; the contrast is constructed afterwards.

What the standardization steps look like

G-computation as a flow. An outcome model is fitted to the observed data. Everyone is then set to treated and everyone to untreated, each person's risk is predicted under both, the predictions are averaged, and the two averages are contrasted. Uncertainty comes from repeating every step in bootstrap samples.Marginal standardization: predict everyone both ways, then averageOutcome model fitted to the observed dataEveryone set to treated: predict each riskEveryone set to untreated: predict eachriskAverage predicted risk if treatedAverage predicted risk if untreatedContrast: risk difference or ratioUncertainty: repeat every step in bootstrap samplesThe contrast is causal only if the adjustment set was sufficient; the ordinary model standard errors donot carry through the averaging.
Conceptual diagram. It shows the structure of the idea, not data from any study.

Why this solves the non-collapsibility problem

An odds ratio is non-collapsible: the adjusted odds ratio differs from the unadjusted one even with no confounding, purely because of how odds behave when averaged. Risk differences and risk ratios do not have that property. Standardizing the model's predictions gives a marginal estimate on a collapsible scale, which is both more interpretable and more comparable across studies.

When not to use it

It does not rescue a model whose adjustment set is wrong. Every causal claim made from standardized risks rests on the same no-unmeasured-confounding assumption the coefficients rested on, stated no more loudly for being expressed in absolute terms.

Why Mallard may recommend it

Mallard may recommend marginal standardization when the estimand names a risk difference or risk ratio but the natural model is logistic, which is a common combination: the model is chosen for the outcome type and the estimand is chosen for the reader.

Key assumptions and design requirements

  • The model is correctly specified enough for its predictions to be usable, including interactions that matter.
  • The adjustment set is sufficient; standardization inherits every assumption the model made.
  • Standard errors come from the bootstrap or the delta method, since the model's own do not carry through the averaging.
  • The population being standardized to is stated: the whole sample, the treated, or an external population are different targets.
  • Predictions are not extrapolated into covariate regions where nobody was actually observed under one of the conditions.

What to watch out for

The absolute risks it produces are only as good as the model and the adjustment set behind them, and presenting them as a causal contrast asserts that adjustment was sufficient. Standard errors need the bootstrap or the delta method, because the ordinary model standard errors do not carry through the averaging step.

Clinical example

Question: What is the absolute reduction in 30-day readmission from a discharge pharmacy review? Analysis: Fit an adjusted logistic model, predict each patient's risk with the review set on and then off, average each, and report the difference with bootstrap confidence intervals as the standardized risk difference.

Code for this method
Loading…
Recent studies that used this
Searching PubMed…
Related Learn pages
Sources & further reading
  1. Implementation of G-computation on a simulated data set: demonstration of a causal inference technique (opens in a new tab) · Am J Epidemiol · doi 10.1093/aje/kwq472
  2. Principles of confounder selection (opens in a new tab) · Eur J Epidemiol · doi 10.1007/s10654-019-00494-6
The first paper walks through the procedure on simulated data where the truth is known, which is the clearest way to see what standardization does and does not fix. The second covers choosing the adjustment set, which is the assumption standardization inherits rather than removes.
Last source review: 2026-09-06
AI-generated educational content
Mallard uses reputable methodological and reporting sources, but this material may contain errors or omit important context. Verify important methodological decisions with the cited sources and, when appropriate, a qualified research methodologist or statistician.