- Introduced by
- James M. Robins
- Year
- 1986
- Type
- Parametric causal effect estimation
- Family
- Causal
What does it do?
G-computation is a causal inference method for estimating the effect of an exposure or intervention on an outcome using observational data.
James M. Robins introduced the g-formula in a 1986 paper on causal inference in mortality studies with sustained exposure periods. In its parametric form, the method estimates population-level effects by fitting a model, predicting outcomes under specified intervention scenarios, and averaging those predictions over the observed population.
The intuition behind the method
G-computation fits a model that relates the outcome to the exposure and to confounders. It then uses that fitted model to predict each individual's outcome under each intervention scenario, such as everyone exposed, no one exposed, or a rule that changes exposure over time, while keeping the baseline covariates at their observed values. Averaging these predictions across the population gives an estimate of the outcome under each scenario, and comparing the averages gives a causal contrast. The estimate is valid only under the identifiability assumptions: exchangeability (all relevant confounders are measured, so there is no unmeasured confounding), positivity (every exposure level of interest occurs with non-zero probability within every confounder stratum), consistency (the intervention is well defined, and the outcome observed under the observed exposure equals the outcome that would occur under that exposure), and a correctly specified model. Exchangeability, consistency and model specification cannot be fully verified from the data and must be argued on subject-matter grounds. Positivity can be partly checked by examining exposure distributions within confounder strata.
History
James M. Robins introduced the g-formula in 1986 in a paper on causal inference in mortality studies with sustained exposure periods, applied to control of the healthy worker survivor effect. Taubman and colleagues (2009) applied the parametric g-formula to estimate the population risk of coronary heart disease under hypothetical joint lifestyle interventions, using data from the Nurses' Health Study, and described it as the first large-scale application of the parametric g-formula in an epidemiologic cohort. Ahern, Hubbard and Galea (2009) presented a step-by-step illustration of a closely related imputation-based procedure (model the exposure-outcome association, impute outcomes while setting the exposure, average, and bootstrap) for estimating population effects of interventions, using neighborhood smoking norms as the example.
When to use it
Use g-computation when estimating causal effects of exposures in observational studies where confounding is a concern and you are willing to assume that all important confounders are measured. It is particularly suitable for time-varying confounders affected by past exposure, for joint or dynamic interventions, and for questions about hypothetical population-level interventions. In the time-varying setting it requires the full parametric g-formula with models for each time-varying covariate, not a single outcome regression. It is less suitable when the positivity assumption is severely violated or when the required models are difficult to specify correctly.
Limitations and considerations
- Relies on the assumption of no unmeasured confounding, which cannot be tested from data alone
- Requires a correct outcome model; misspecification biases the estimates, and there is no simple way to detect it
- Requires the positivity assumption (non-zero probability of every exposure value at every level of the confounders), which may be violated with rare exposures
- Computationally intensive, especially with large datasets, complex outcome models, or bootstrap resampling
- Performance depends heavily on the overlap between exposure groups in the confounder distribution
Source conditions do not replace independent scientific review or validation by an analysis engine.
Strengths
- Handles time-varying confounders and exposures that are affected by past outcomes, situations where simple regression adjustment fails
- Can estimate effects of dynamic interventions, where the exposure rule depends on evolving individual characteristics over time
- Flexible in specifying the outcome model, allowing nonlinear models and flexible functional forms
- Intuitive interpretation: the estimated effect is the difference in population outcomes under different intervention scenarios
- Can estimate effects of sustained interventions and cumulative effects in longitudinal studies
Applications
- Estimating the 20-year risk of coronary heart disease under a hypothetical joint intervention of no smoking, increased exercise, improved diet, moderate alcohol consumption and reduced body mass index
- Estimating how the population smoking prevalence would change if neighborhood smoking norms could be manipulated, by setting the exposure to different values and averaging the predicted probabilities
- Assessing the causal effect of cumulative air pollution exposure on lung function decline over time, where residential mobility may create time-varying confounding
- Comparing outcomes under dynamic intervention rules, in which treatment decisions depend on the evolving values of time-dependent factors
How it works
How it works
Define the target population, the exposure or intervention, the outcome, and the set of confounders. Separate baseline confounders, measured before exposure assignment, from time-varying confounders, measured between exposure periods in longitudinal data. Specify the intervention scenarios to compare, for example never treated versus always treated, or the observed exposure pattern versus a hypothetical one. State the intervention precisely, since the consistency assumption depends on it.
With a single point exposure and baseline confounders, fit a regression model for the outcome as a function of exposure and confounders. For each individual, set the exposure to the value defined by each scenario, keep the other variables at their observed values, and predict the outcome. Average these predictions across the population for each scenario; the difference between scenario averages is the estimated marginal causal effect. With time-varying confounders affected by prior exposure, a single outcome regression is not sufficient. The parametric g-formula instead models the outcome and also the distribution of each time-varying covariate given its history, and simulates the joint distribution of covariates and outcome forward in time under the intervention. The risk or mean outcome under the intervention is then obtained by averaging over the simulated histories.
Formula
E[Y^{a}] = \sum_{l} E[Y \mid A=a, L=l]\, P(L=l)Ahern and colleagues (2009) obtain confidence intervals for the imputation-based procedure by bootstrapping: resample the data with replacement, refit the model(s), repeat the g-computation step, and use the spread of the bootstrap estimates. This reflects uncertainty from both model fitting and the averaging step. Analytical approaches such as the delta method are an alternative, but they require a separate derivation for each estimator. Examine the point estimates across scenarios and, where relevant, across subgroups to see whether the effect varies.
Check whether the model adequately describes the observed relationship, including whether important interaction or nonlinear terms are needed. Examine overlap in the confounder distributions between exposure groups, since the method extrapolates to scenarios that the data may not support. Conduct sensitivity analyses for unmeasured confounding and for the definition of the intervention. Temporal ordering, stability of the exposure definition and the assumption of treatment assignment under the scenarios cannot be fully verified from the data, so their plausibility must be argued on subject-matter grounds.
Common pitfalls
- Using a misspecified outcome model that omits important interactions or nonlinear relationships between exposure and outcome, which biases the causal estimates
- Ignoring positivity violations by estimating effects for subgroups with no natural variation in the exposure
- Failing to include all relevant confounders in the model, which leaves residual confounding even when the model fits the observed data well
- Applying a single outcome regression when time-varying confounders are affected by prior exposure, instead of the full parametric g-formula
- Not checking overlap in confounder distributions between exposure groups; poor overlap means predictions rely on extrapolation
- Reporting uncertainty from the outcome model alone; bootstrap the whole procedure, including the model fitting and averaging steps
Frequently asked questions
How is g-computation different from simple outcome regression adjustment?
Regression adjustment fits a single outcome model and reports the coefficient for exposure, which is a conditional effect given the covariates. G-computation uses the same kind of model but predicts each individual's outcome under each intervention scenario and averages those predictions over the observed covariate distribution, which gives a marginal, population-level effect. The marginal population effect is the estimand g-computation targets; conditional coefficients answer a different question. For non-collapsible models, such as logistic regression, and in the presence of effect modification, the conditional and marginal effects can differ substantially.
Do I need to assume no unmeasured confounding for g-computation to work?
Yes. Like other standard causal inference methods, g-computation requires that all confounders are measured. If important confounders are unmeasured, bias remains even when the outcome model is correctly specified. Sensitivity analyses can assess how robust the estimate is to unmeasured confounding.
What should I do if my outcome model does not fit well?
Poor fit suggests the model may be misspecified. Consider more flexible functional forms, interaction terms, or nonparametric or semiparametric methods. Improved fit to the observed data does not guarantee that the model gives correct predictions under intervention scenarios, so examine residuals, test for interactions, and run sensitivity analyses.
How do I get confidence intervals for g-computation estimates?
Bootstrap resampling is the approach used by Ahern and colleagues (2009): resample the data with replacement, refit the model(s) to each bootstrap sample, perform the g-computation step, and repeat. The distribution of the bootstrap estimates gives the confidence interval. The delta method is an analytical alternative but requires its own derivation.
Related methods
Sources
Robins, J. M. (1986). A new approach to causal inference in mortality studies with sustained exposure periods: application to control of the healthy worker survivor effect. Mathematical Modelling, 7(9-12), 1393-1512.
Open DOI referenceTaubman, S. L., Robins, J. M., Mittleman, M. A., & Hernán, M. A. (2009). Intervening on risk factors for coronary heart disease: an application of the parametric g-formula. International Journal of Epidemiology, 38(6), 1599-1611.
Open DOI referenceAhern, J., Hubbard, A., & Galea, S. (2009). Estimating the effects of potential public health interventions on population disease burden: a step-by-step illustration of causal inference methods. American Journal of Epidemiology, 169(9), 1140-1147.
Open DOI reference