node_instrumental tags instrumental variables given an exposure and outcome. ggdag_instrumental plots all instrumental variables. See dagitty::instrumentalVariables() for details.

node_instrumental(.dag, exposure = NULL, outcome = NULL, ...)

ggdag_instrumental(.tdy_dag, exposure = NULL, outcome = NULL, ...,
  node_size = 16, text_size = 3.88, label_size = text_size,
  text_col = "white", label_col = text_col, node = TRUE,
  stylized = FALSE, text = TRUE, use_labels = NULL)

Arguments

.dag, .tdy_dag

input graph, an object of class tidy_dagitty or dagitty

exposure

character vector of length 1, name of exposure variable. Default is NULL, in which case it will check the input DAG for exposure.

outcome

character vector of length 1, name of exposure variable. Default is NULL, in which case it will check the input DAG for exposure.

...

additional arguments passed to tidy_dagitty()

node_size

size of DAG node

text_size

size of DAG text

label_size

size of label text

text_col

color of DAG text

label_col

color of label text

node

logical. Should nodes be included in the DAG?

stylized

logical. Should DAG nodes be stylized? If so, use geom_dag_nodes and if not use geom_dag_point

text

logical. Should text be included in the DAG?

use_labels

a string. Variable to use for geom_dag_repel_label(). Default is NULL.

Value

a tidy_dagitty with an instrumental column for instrumental variables or a ggplot

Examples

library(dagitty) node_instrumental(dagitty("dag{ i->x->y; x<->y }"), "x", "y")
#> # A DAG with 3 nodes and 3 edges #> # #> # A tibble: 4 x 11 #> name x y direction to xend yend circular instrumental_na… #> <chr> <dbl> <dbl> <fct> <chr> <dbl> <dbl> <lgl> <chr> #> 1 i 16.3 8.44 -> x 15.9 9.51 FALSE i #> 2 x 15.9 9.51 -> y 15.5 10.3 FALSE i #> 3 x 15.9 9.51 <-> y 15.5 10.3 FALSE i #> 4 y 15.5 10.3 <NA> <NA> NA NA FALSE i #> # ... with 2 more variables: adjusted <fct>, instrumental <chr>
ggdag_instrumental(dagitty("dag{ i->x->y; i2->x->y; x<->y }"), "x", "y")