Last week, I presented ggdag at JSM in Vancouver. As you can imagine, I had a lot of conversations with people about DAGs, confounding, colliders, and all the types of bias that can arise in research. One strange type of bias came up a couple of times that I don’t see discussed very often: measuring either the effect you are studying (x) or a variable along a confounding pathway (z) incorrectly can make it appear as if there is an interaction between x and z, even if there isn’t one.
I’m pleased to announce the release of ggdag 0.1.0 on CRAN! ggdag uses the powerful dagitty package to create and analyze structural causal models and plot them using ggplot2 and ggraph in a tidy, consistent, and easy manner. You can use dagitty objects directly in ggdag, but ggdag also includes wrappers to make DAGs using a more R-like syntax:
install.packages("ggdag") library(ggdag) dag <- dagify(y ~ x + z, x ~ z) %>% tidy_dagitty() dag ## # A tibble: 4 x 8 ## name x y direction to xend yend circular ## <chr> <dbl> <dbl> <fct> <chr> <dbl> <dbl> <lgl> ## 1 x 3.