Skip to content
StatsOtter A workspace for causal thinking
Method library WORKFLOW / 041
Research workflow/4 steps

Draw the DAG, find the adjustment set (ggdag & dagitty)

Source ggdag / dagitty — Barrett; Textor et al.
01
The method workspace

Follow the analysis.

Select a node to explore the method

Method mapInput → 4 steps → output
START WITHInput data
ARRIVE ATResults
Read step 01
Inside the methodReasoning, equations & implementation
Step 1 of 4
01
Data prep

Encode your assumptions as a DAG

Data preparation — shapes the raw inputs into what the estimator expects.

What happens here

Nodes and directed edges make the causal story explicit and falsifiable — the modelling happens here, not in the regression.

Formula
G=(V,E);\quad \tau=\mathbb E[Y\mid do(X{=}1)]-\mathbb E[Y\mid do(X{=}0)]
Reads fromNot specified Feeds intoNot specified
Key code
dag <- dagify(y ~ x + a + b, x ~ a + b,
              exposure='x', outcome='y')

Reference / docs ↗

Discussion on this step (0)
StatsOtterDiscussion starter · Editorial note

Before using this step, make its assumptions and its output explicit. A useful peer note explains what you would check, what could go wrong, or what would change your interpretation.

Questions to explore
  1. Which assumption matters most here, and what evidence could challenge it?
  2. What would you check before passing this output to the next step?

Peer discussion

  • Bring your experience, a question, or a different perspective.
02
Data contract

Inputs & data

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
03
Read the evidence

Results & interpretation

2 figures Workflow discussion 2
01FigureThe minimal adjustment set {a, b}: conditioning on those nodes blocks the backdoor paths (greyed) and leaves the direct x → y effect identified.
02FigureEvery open path from treatment x to outcome y: the direct causal path (red) plus the backdoor paths (teal) that confound it until they're blocked.

Figures reproduced from ggdag / dagitty — Barrett; Textor et al. — unofficial community showcase; all credit to the original authors.

Context & interpretation

⚠️ 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.

Peer notes

Discuss the workflow (2)

  • 2

    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.

  • 0

    Testable implied conditional independencies are underused — it's the closest thing to a falsification test for your DAG.

    1

    This pairs perfectly with a DoWhy/propensity pipeline: ggdag picks the adjustment set, then you estimate and refute.

IN THE MARGINS

Peer discussion