ASKurz / Statistical_Rethinking_with_brms_ggplot2_and_the_tidyverse_2_ed

The bookdown version lives here:
https://bookdown.org/content/4857/
Creative Commons Zero v1.0 Universal
125 stars 37 forks source link

Bonus Waffle House example -- which models are "DAG endorsed"? #27

Closed rpruim closed 1 year ago

rpruim commented 3 years ago

From the end of chapter 6...

The default output of adjustmentSets() produces only minimal sets of variables to condition on. But there may be other adjustments sets that are not minimal. Setting type = all will list them.

library(dagitty)
dag_6.2 <- 
  dagitty("dag {
  A -> D
  A -> M -> D
  A <- S -> M
  S -> W -> D
           }"
  )

paths(dag_6.2, from = "W", to = "D")
#> $paths
#> [1] "W -> D"                "W <- S -> A -> D"      "W <- S -> A -> M -> D"
#> [4] "W <- S -> M -> D"      "W <- S -> M <- A -> D"
#> 
#> $open
#> [1]  TRUE  TRUE  TRUE  TRUE FALSE
adjustmentSets(dag_6.2, exposure = "W", outcome = "D")
#> { A, M }
#> { S }
adjustmentSets(dag_6.2, exposure = "W", outcome = "D", type = "all")
#> { A, M }
#> { S }
#> { A, S }
#> { M, S }
#> { A, M, S }

Created on 2021-03-25 by the reprex package (v1.0.0)

It might be good to mention this so users are aware that the minimal sets are not the only ones endorsed by the DAG. It might even be worth adding a model the is endorsed but not minimal.

ASKurz commented 1 year ago

Good suggestion. Done.