38.3 Example DAG

library(dagitty)
library(ggdag)

dag <- dagitty("dag {
  X -> Z -> Y
  Z <- U -> Y
}")

coordinates(dag) <- list(
  x = c(X = 1, Z = 2, Y = 3, U = 1.5),
  y = c(X = 1, Z = 1, Y = 1, U = 2)
)

ggdag(dag) +
  theme_dag()

This DAG has:

  • A mediator path: XZY
  • A backdoor path through an unobserved confounder: XUY

Use adjustmentSets(dag, exposure = "X", outcome = "Y") to identify a valid adjustment set.