G-Comp Builder
DAG import Β· G-Computation Β· Counterfactual prediction
Β© Dr. Rainer DΓΌsing Β· Interactive Tools by Claude
Workflow
1
Build your DAG in the Golem Builder, mark Exposure & Outcome β†’ click β†’ G-Comp Builder. Formula, adjustment set, and DAG structure are imported automatically.
2
Review and edit the formula. Add optional variables (from DAG: can be controlled) by clicking them. Enter random effects and model type.
3
Fit the model in R: fit <- brm(formula, data = dat, family = ...)
4
Copy R code from the output panel and run it in R. Code updates live with every change.
Validation
  • β„ΉEnter Exposure and Outcome or import from Golem Builder.
G-Comp Builder β€” Help
What is G-Computation?

G-Computation (causal standardization) estimates what would happen on average if we set every person to a specific exposure value β€” as opposed to "which people actually had that value".

Key marginaleffects concept: variables=list(X=val) sets X to val for every observation and averages over all confounder distributions. This is true marginalization β€” not a "typical person" estimate.
Binary exposure β€” estimands
ATE β‰  ATT β‰  ATU when there is effect heterogeneity. Under randomization without interactions they are equal.
Metric exposure β€” AME & ate_k
AME and ate_k are conceptually different: AME is a slope (per unit), ate_k is a total contrast (from–to). Both are causal effects when confounding is controlled.
ate_k β€” contrast strings in marginaleffects
ATT/ATU analogue (metric)

For metric exposures there is no natural "treated/untreated". The analogue splits the population artificially at a cutoff (default: median):

Useful for checking whether the effect differs for already highly exposed vs. low exposed persons β€” effect heterogeneity along the exposure axis.
Dose-response curve

Estimates E[Y | do(X=x)] for 100 values from min to max. Each point is a genuine G-Computation estimate: the entire population is "set to X=x" and the marginal mean is computed.

ICE β€” Individual causal effects

Individual Counterfactual Effects: Ο„Μ‚α΅’ = ΕΆα΅’(x_hi) βˆ’ ΕΆα΅’(x_lo). Shows heterogeneity in the causal effect across persons. Sorted by ΕΆα΅’(x_lo) β€” same row = same person in both plots.

Workflow
  1. Build DAG in Golem Builder β†’ export to G-Comp Builder
  2. Check formula, fit model in R
  3. Copy code, compute estimands
  4. Export MCMC draws β†’ Decision Maker
Only variables from the adjustment set are required in the formula. Precision covariates (causes of Y but not X) can safely be added β€” they reduce variance without introducing bias.