Part 16 · Module 2
Causal Diagrams and Directed Acyclic Graphs
Learn how directed acyclic graphs encode causal assumptions, identify confounders and prevent inappropriate adjustment for mediators or colliders.
Learning outcomes
After completing this lecture, you should be able to:
- Define nodes, arrows, paths and acyclicity.
- Identify confounders, mediators and colliders.
- Apply back-door adjustment logic.
- Explain why adjusting for every variable can increase bias.
- Use DAGs to communicate assumptions and guide analysis.
- Translate a clinical question into a clearly specified DAG.
Overview
A directed acyclic graph, DAG, represents assumed causal relationships using nodes and arrows [1].
DAGs do not estimate effects.
They clarify:
- temporal ordering;
- confounding;
- mediation;
- selection;
- collider bias;
- sufficient adjustment sets.
The graph is only as credible as its assumptions.
Why this matters
“Adjust for all measured variables” is not safe.
Adjustment can increase bias when controlling for:
- mediators;
- colliders;
- consequences of treatment;
- selection variables.
A DAG forces the analyst to decide why each variable is included.
When to use DAGs
Use DAGs before data analysis for causal questions.
They are useful in protocols, analysis plans, sensitivity analyses and peer review.
They are less relevant when the objective is purely descriptive or predictive.
Research question and variables
Nodes represent variables.
A directed path follows arrow directions.
A back-door path enters treatment through an incoming arrow and can create confounding.
A collider is a node receiving two arrows:
Conditioning on can create association between and .
Data structure
Roles in the example DAG
simulated data| Variable | Role |
|---|---|
| Age | Confounder |
| Severity | Confounder |
| Treatment | Exposure |
| Mediator | Post-treatment pathway |
| Outcome | Endpoint |
| Unmeasured U | Mediator–outcome confounder |
Statistical assumptions
Confounders
A confounder is a common cause of exposure and outcome.
Adjusting for age and severity blocks back-door paths in the example.
A variable associated with both treatment and outcome is not necessarily a confounder if it is caused by treatment or is a collider.
Mediators
A mediator lies on the causal pathway:
Adjusting for removes part of the total effect and changes the estimand.
It can also introduce mediator–outcome confounding bias.
Colliders
A collider has two incoming arrows.
Conditioning on a collider opens a non-causal path.
Selection into a study can itself be a collider.
Worked example
Worked analysis in R
library(dagitty)
trial_dag <- dagitty(
"dag {
age -> treatment
age -> outcome
severity -> treatment
severity -> outcome
treatment -> mediator
treatment -> outcome
mediator -> outcome
u -> mediator
u -> outcome
}"
)
exposures(trial_dag) <- "treatment"
outcomes(trial_dag) <- "outcome"
adjustmentSets(
trial_dag,
type = "minimal"
)
impliedConditionalIndependencies(
trial_dag
)
plot(trial_dag)
Selected analysis output
A minimal measured adjustment set is {age, severity}.
The mediator is not included when estimating the total treatment effect.
Visualising the DAG
Back-door criterion
A valid adjustment set:
- blocks every back-door path;
- contains no descendant of treatment;
- is appropriate for the target effect.
Multiple valid sets may exist.
The smallest set is not always operationally best when variables are measured poorly.
DAG limitations
DAGs do not show:
- effect magnitude;
- interactions automatically;
- measurement error;
- functional form;
- stochastic dependence without causal interpretation.
They cannot prove the causal model from observational data alone.
Interpreting the graph
Presenting the analysis
Suggested reporting
Provide the DAG, node definitions, sources of causal assumptions, target estimand and selected adjustment set [2], [3].
A broader potential-outcomes treatment of causal identification and adjustment is provided by Hernán and Robins [4].
Common mistakes
Knowledge check
What is a collider?
Answer and reasoning
A node with at least two incoming causal arrows on a path.
Why avoid mediator adjustment for total effect?
Answer and reasoning
It blocks part of the causal pathway and changes the estimand.
What is a back-door path?
Answer and reasoning
A path from exposure to outcome that begins with an arrow into the exposure.
Can data determine the DAG uniquely?
Answer and reasoning
No. Substantive assumptions are required.
What does a sufficient adjustment set do?
Answer and reasoning
It blocks confounding paths for the target causal effect.
Key take-home messages
References
- Pearl J. Causality. 2nd ed. Cambridge: Cambridge University Press; 2009.
- Greenland S, Pearl J, Robins JM. Causal diagrams for epidemiologic research. Epidemiology. 1999;10(1):37–48.
- Textor J, van der Zander B, Gilthorpe MS, Liśkiewicz M, Ellison GTH. Robust causal inference using DAGs: the R package dagitty. Int J Epidemiol. 2016;45(6):1887–1894. https://doi.org/10.1093/ije/dyw341
- Hernán MA, Robins JM. Causal inference: what if. Boca Raton: Chapman & Hall/CRC; 2020.
These notes support learning and research planning and do not replace statistical consultation for a specific study.