AI Glossary / Probabilistic machine learning / Intermediate

g-computation

Definition

G-computation estimates outcomes under specified interventions by applying the g-formula to observed-data relationships. In a simple baseline-treatment setting, it fits an outcome model, predicts everyone's outcome under each treatment choice and averages those predictions over a target population. A causal interpretation depends on identification assumptions and adequate estimation, not on prediction alone.

What it means

The question is what the average outcome would be if the same population received one intervention versus another. This differs from comparing people who happened to receive different interventions, because those groups may have differed beforehand. G-computation standardizes the comparison to a common distribution of relevant characteristics.

Treatment can mean a business action, an educational program or another well-defined intervention; it need not be medical. The target population, timing and outcome must be specified. G-computation does not reveal both potential outcomes for each individual. It uses assumptions connecting observed data to a population-level counterfactual quantity.

How it works

For one baseline treatment A, outcome Y and sufficient pretreatment covariates L, estimate m(a, l) = E[Y | A = a, L = l]. Predict m(a, L_i) for each target observation as if treatment were set to a, then average. Repeat for another treatment and compare the standardized means.

The standard causal interpretation requires consistency with a well-defined intervention, conditional exchangeability or no unmeasured confounding given L, and positivity: the relevant treatments must be possible across the covariate profiles being compared. Estimation also needs an adequate outcome model or another suitable estimator of the conditional means.

For repeated interventions and time-varying covariates, the longitudinal g-formula respects temporal order and averages or simulates covariate histories under each intervention. This is more involved than replacing one column in a static table, especially when earlier treatment affects later confounders. Uncertainty estimation should reflect the fitted models and sampling design.

Three practical examples

1. Training evaluation: estimate completion rates if a defined population were offered one onboarding program versus another, accounting for relevant baseline differences in who received each program.

2. Service design: compare hypothetical follow-up policies using appropriately collected histories. If actions change over time in response to earlier outcomes, use a longitudinal formulation that represents that feedback.

3. Product experimentation: standardize trial outcomes to a specified mix of eligible users. Clearly distinguish estimating an effect within the trial population from transporting it to a different population, which needs additional justification.

Think of it this way

Think of running two carefully specified versions of the same population through a statistical model, changing the intervention while using the appropriate population characteristics. The analogy is a structured comparison, not an actual parallel world. The model cannot manufacture causal identification when important confounders are missing or the intervention is poorly defined.

Worked example

Consider a hypothetical target population that is 60% new users and 40% experienced users. An outcome model predicts onboarding completion probabilities under program A of 0.70 for new users and 0.90 for experienced users. Under program B, the corresponding predictions are 0.60 and 0.85.

Standardizing program A to the target mix gives 0.6 × 0.70 + 0.4 × 0.90 = 0.78. Program B gives 0.6 × 0.60 + 0.4 × 0.85 = 0.70. The standardized difference is 0.08, or eight percentage points.

Suppose the observed A group instead contained 80% experienced users, while the observed B group contained only 20%. Using these different group mixes with the same conditional probabilities would give 0.86 for A and 0.65 for B, a 21-point difference. The two comparisons answer different questions because they average over different populations.

The eight-point result is a causal effect only if the stated intervention, confounding, support and modeling assumptions are adequate. The example stipulates model predictions; it does not show that user experience alone suffices to control confounding in a real onboarding study.

Illustrative case study

Fictional case: Larch Software wants to compare two onboarding approaches from historical records. Analysts discover that the more intensive approach was preferentially offered to accounts already receiving extra support. They define the intervention and outcome window and examine which baseline variables were recorded before assignment.

They present standardized estimates alongside uncertainty and an explicit discussion of potentially missing assignment drivers. The team considers a prospective experiment to resolve remaining uncertainty. This fictional case illustrates the distinction between calculating an adjusted estimate and establishing a credible causal conclusion.

Common misconceptions and mistakes

Do not interpret an outcome model's treatment coefficient as automatically equal to the standardized average effect, particularly with nonlinear models or treatment interactions. G-computation averages predicted outcomes under the intervention rather than relying on that shortcut.

Predictive accuracy does not prove no unmeasured confounding. Adjusting for every available variable can be harmful if some are consequences of treatment or colliders. Positivity problems can force extrapolation into poorly supported combinations. Ordinary outcome-regression g-computation is not automatically doubly robust; misspecification of the necessary outcome relationships can bias the estimate.

Business use

Before modeling, document the policy comparison, eligibility rules, intervention timing, outcome horizon and target population. Review how treatment was assigned and which covariates are needed for the causal question. Separate this reasoning from the choice of predictive algorithm.

Report standardized outcomes as well as their contrast so decision-makers can understand absolute implications. Examine sensitivity to model specification, missing data and unsupported regions. If the decision depends on effects for a subgroup or a changing policy over time, align the estimand and analysis with that question rather than reusing an overall static average.

People also ask

Is g-computation the same as ordinary prediction?

No. It uses prediction within a counterfactual intervention calculation whose causal meaning requires additional assumptions.

Must the outcome model be linear?

No. Different estimators can be used, but flexibility does not remove identification or uncertainty challenges.

Is g-estimation another name for it?

No. G-estimation is a distinct approach associated with structural nested models; both belong to the broader family of g methods.

Check your understanding

Why does the worked example use the same 60/40 user mix for both programs?

Answer: It compares interventions for the same target population. Using different mixes would combine intervention differences with differences in population composition.

Related terms

  • Standardization
  • Consistency
  • G-formula
  • potential outcome
  • exchangeability
  • positivity
  • time-varying confounding
  • outcome regression

Learn next

Practice standardizing a small table of conditional outcome means, then distinguish the calculation from its causal assumptions. Next study longitudinal treatment-confounder feedback and why the g-formula must represent covariate evolution under intervention.

  • Treatment-confounder feedback

More in Probabilistic machine learning

  • Forward stagewise additive modeling - Forward stagewise additive modeling builds a predictive function by adding one fitted component at a time while leaving previously added components fixed.
  • Free bits objective - The free bits objective is a modification of a variational autoencoder training objective that stops rewarding further reductions in a latent group's KL...
  • Fully independent training conditional approximation - The fully independent training conditional approximation (FITC) is a sparse Gaussian process regression approximation that makes training function values...
  • Gaussian discriminant analysis - Gaussian discriminant analysis (GDA) is a classification approach that models the feature distribution within each class as Gaussian and combines those...
  • Gaussian-Gaussian model - A Gaussian-Gaussian model combines a Gaussian observation model with a Gaussian prior for an unknown mean or related continuous quantity.
  • Gaussian scale mixture - A Gaussian scale mixture is a probability distribution formed by combining Gaussian distributions that share a location but vary in scale.

Sources

Delicatessen authors, standardization and parametric g-formula implementation: https://deli.readthedocs.io/en/latest/Examples/Hernan-Robins-2023.html

Naimi, Cole and Kennedy, An Introduction to G Methods: https://pmc.ncbi.nlm.nih.gov/articles/PMC6074945/

Independent review consulted Delicatessen’s standardization formula and Naimi’s author-hosted paper, assumptions and longitudinal g-formula: https://ainaimi.github.io/files/publications/Naimi_et_al_2017_IJE.pdf . PMC presented a browser challenge. Original arithmetic verified.

Previous: Fuzzy set theory Next: G-prior

  • Home
  • Daily AI Updates
  • Blog
  • AIFBL Academy
  • AI Glossary
  • Products and Tools
  • Store
  • Free CFO AI Prompt Pack
  • About Shihan Sheriff
  • Privacy Policy
  • Terms of Use
  • Refund Policy
  • Cookie Policy
  • Earnings Disclaimer