Introduction
This article explains the broader R DAG ecosystem and positions DAGassist within it. It also explains the dependencies necessary to maximize DAGassist’s functionality.
-
dagittyfor DAG specification and reasoning -
ggdagto visualize DAGs -
modelsummaryto format regression tables -
broomto tidy models (coefs & goodness-of-fit) -
writexlto export multi‑sheet Excel workbooks -
rmarkdownto render shareable docs (HTML/Word/PDF) that embed DAGassist outputs
The Differences Between dagitty, ggdag,
and DAGassist
dagitty
- The core DAG toolkit for R. Creates the actual DAG object that
ggdagandDAGassistuse. - Supports causal queries:
-
dagitty::adjustmentSets()scans adagittyobject to identify adjustment sets. -
dagitty::isAcyclic()verifies acyclicity. -
dagitty::findCycle()identifies cyclical variable relationships.
-
Making a DAG with dagitty:
#via dagitty
library(dagitty)
dag_model <- dagitty('dag {
EffectiveN_electoral
Gov_effectiveness_0_5
LR_Polarization_perceived
PID_noleaners [exposure]
Presidentialsystem
VoterAPI_Party [outcome]
Year_0
EffectiveN_electoral -> VoterAPI_Party
Gov_effectiveness_0_5 -> VoterAPI_Party
LR_Polarization_perceived -> VoterAPI_Party
PID_noleaners -> LR_Polarization_perceived
PID_noleaners -> VoterAPI_Party
Presidentialsystem -> EffectiveN_electoral
Presidentialsystem -> VoterAPI_Party
Year_0 -> PID_noleaners
Year_0 -> VoterAPI_Party
}')
ggdag
- A visualization layer for DAGs.
- Also provides a more intuitive way to make
dagittyobjects.
Making an identical DAG with ggdag:
#via ggdag
library(ggdag)
dag_model <- dagify(
VoterAPI_Party ~ PID_noleaners + LR_Polarization_perceived +
Gov_effectiveness_0_5 + EffectiveN_electoral + Presidentialsystem,
LR_Polarization_perceived ~ PID_noleaners,
EffectiveN_electoral ~ Presidentialsystem,
exposure = "PID_noleaners",
outcome = "VoterAPI_Party"
)
DAGassist
- The glue between your DAG models and regressions.
- Uses
dagittylogic to classify the causal relationships embedded in a DAG. - Identifies those relationships and their implications for your covariate selection in a concise, publication-grade report.
It uses dagitty logic to derive minimal and canonical
adjustment sets, according to these criteria:
| Path / Node Type | Minimal | Canonical |
|---|---|---|
| Fork/Common–Cause Confounder (Z) | ✓ | ✓ |
| Chain/Mediator (M) | ✗ | ✗ |
| Collider (C) | ✗ | ✗ |
| Descendant of Mediator (N) | ✗ | ✗ |
| Descendant of Collider (Q) | ✗ | ✗ |
| Descendant of Outcome (I) | ✗ | ✗ |
| M-Bias | ✗ | ✗ |
| Butterfly Bias | ✗ | ✗ |
| Neutral Control on Treatment (E → X) | ✗ | ✓ |
| Neutral Control on Outcome (F → Y) | ✗ | ✓ |
| Descendant of Confounder off Backdoor Path (W) | ✗ | ✗ |
| Descendant of Confounder on Backdoor Path (V) | Z or V | Z and V |
Note: ✓ = adjust; ✗ = do not adjust. There may be multiple minimal sets; the canonical set is unique.
