@misc{ggdagdagitty,
title = {ggdag / dagitty},
author = {Barrett; Textor and others},
howpublished = {\url{https://r-causal.github.io/ggdag/}},
note = {Software / documentation}
}Before estimation, encode the causal story as a DAG, enumerate the open paths from treatment to outcome, and let the graph hand you a minimal set that blocks every backdoor (and tells you not to condition on a collider). Implied conditional independencies are testable.
Input · what goes in
Subject-matter assumptions about what causes what: nodes (treatment, outcome, confounders, mediators, colliders) and the directed edges between them.
Show data format & exampleHide example
Format — declare the edges; mark the exposure and outcome.
library(ggdag)
dag <- dagify(y ~ x + a + b,
x ~ a + b,
exposure = 'x', outcome = 'y')
ggdag_adjustment_set(dag) # minimal sets that block the backdoors
Pipeline · the recipe ⑂ has parallel branches
↑ Click any step in the diagram to read its logic, code, assumptions & discussion.
Encode your assumptions as a DAG
Data preparation — shapes the raw inputs into what the estimator expects.
Nodes and directed edges make the causal story explicit and falsifiable — the modelling happens here, not in the regression.
dag <- dagify(y ~ x + a + b, x ~ a + b,
exposure='x', outcome='y')
- No comments on this step yet — be the first.
Log in to comment on this step.
Enumerate paths; spot backdoors & colliders
A pre-flight check — run this before trusting any estimate downstream.
Open non-causal paths bias the effect; a collider is the trap — conditioning on it OPENS a path rather than closing it.
ggdag_paths(dag)
- No comments on this step yet — be the first.
Log in to comment on this step.
Minimal sufficient adjustment set
The core estimate — where the causal quantity itself is computed.
The smallest covariate set that blocks every backdoor path (and conditions on no descendant of treatment) identifies the effect.
ggdag_adjustment_set(dag)
- No comments on this step yet — be the first.
Log in to comment on this step.
Test the DAG's implications
A robustness check — does the headline result survive a different lens?
A DAG implies conditional independencies you can actually check in the data — and warns when several DAGs are observationally equivalent.
library(dagitty); impliedConditionalIndependencies(dag)
- No comments on this step yet — be the first.
Log in to comment on this step.
Output · what you get 2 figures
Figures reproduced from ggdag / dagitty — Barrett; Textor et al. — unofficial community showcase; all credit to the original authors.
⚠️ Unofficial community showcase of ggdag. Not affiliated with the authors; all credit to them.
Before any estimation: encode your assumptions as a causal graph, enumerate the backdoor paths from treatment to outcome, and let the graph hand you the minimal set of covariates to adjust for.
Discussion (2)
Log in to join the discussion.
Doing this BEFORE you touch the data is the discipline that prevents collider bias. The 'do not condition on a collider' warning can't be repeated enough.
Testable implied conditional independencies are underused — it's the closest thing to a falsification test for your DAG.
This pairs perfectly with a DoWhy/propensity pipeline: ggdag picks the adjustment set, then you estimate and refute.