What is this about?
You have a causal question ("Does X affect Y?") and a model in mind β G-Comp Builder turns it into ready-made, commented
R code for g-computation: from the model formula to the
counterfactual predictions for
ATE,
ATT and
ATU. The tool does not compute anything itself; it builds the code that you run in your own
brms workflow. Unlike the
Causal Calculator (guided example with simulated data), it is meant for your own analysis.
The idea behind it
G-computation (causal standardisation) answers the question:
what would have happened on average if everyone had been exposed β and what if no one had? This works in three steps: first you fit an outcome model with exposure and
confounders. Second, you predict the outcome for
each person twice β once with the exposure at the reference value, once at the treatment value (the "two worlds"). Third, you average the difference across persons β depending on the
estimand over everyone (ATE), only the exposed (ATT) or only the unexposed (ATU). Because your model is a Bayesian model, this happens for every
posterior draw: in the end you get a whole distribution of the causal effect.
How to proceed
β DAG import: the
Golem Builder clarifies which variables you must control for. Take exposure, outcome and
adjustment set from there β or enter them by hand. A banner shows whether an import is present; a button reloads it.
β‘ Model & formula: the formula is suggested from the DAG and directly editable; optional variables from the DAG can be added with a click. If a
mediator was detected, you choose between the
total effect (mediator not in the model: XβMβY plus XβY) and the
direct effect (mediator in the model: only XβY). Plus
random effects, model type (brms, glmmTMB, lm/glm), family and the names of model object and dataframe.
β’ Settings: is the exposure binary or continuous?
Binary: reference and treatment value, estimands (ATE / ATT / ATU, optionally conditional on a moderator to see effect heterogeneity).
Continuous: there is no natural "treated / untreated" β you choose a contrast (minβmax, Q1βQ3, Β±1 SD or manual) and an artificial ATT/ATU analogue via a cutoff (median or your own value). Note the difference between the AME (effect
per unit, a slope) and the contrast
fromβto.
β£ Copy the R code: the code in the output field updates live. Fit your model in R (
brm(...)) and run the code β it uses
marginaleffects, sets the exposure to the respective value for everyone and averages over the confounders.
What the tool does not settle for you
The code is only as causal as your DAG: it assumes that all relevant confounders are measured, that exposed and unexposed persons occur at every confounder level (
overlap) and that the model describes the data decently. The validation box only checks the formal consistency of exposure, outcome and adjustment set β not whether your DAG is right in substance.
And afterwards?
The code exports the
MCMC draws of ATE/ATT/ATU as CSV β on the response scale, so directly interpretable. Load them into the
Decision Maker to derive a well-founded decision with
HDI/
ETI/
ROPE.