Returns a set of complete partially directed acyclic graphs (CPDAGs) given an
input DAG. CPDAGs are Markov equivalent to the input graph. See
dagitty::equivalentDAGs()
for details.
node_equivalent_dags()
returns a set of DAGs, while
node_equivalent_class()
tags reversable edges.
ggdag_equivalent_dags()
plots all equivalent DAGs, while
ggdag_equivalent_class()
plots all reversable edges as undirected.
Usage
node_equivalent_dags(.dag, n = 100, layout = "auto", ...)
ggdag_equivalent_dags(
.tdy_dag,
...,
node_size = 16,
text_size = 3.88,
label_size = text_size,
text_col = "white",
label_col = "black",
node = TRUE,
stylized = FALSE,
text = TRUE,
use_labels = NULL
)
node_equivalent_class(.dag, layout = "auto")
ggdag_equivalent_class(
.tdy_dag,
expand_x = expansion(c(0.1, 0.1)),
expand_y = expansion(c(0.1, 0.1)),
breaks = ggplot2::waiver(),
...,
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
input graph, an object of class
tidy_dagitty
ordagitty
- n
maximal number of returned graphs.
- layout
a layout available in
ggraph
. Seeggraph::create_layout()
for details. Alternatively,"time_ordered"
will usetime_ordered_coords()
to algorithmically sort the graph by time.- ...
optional arguments passed to
ggraph::create_layout()
- .tdy_dag
an object of class
tidy_dagitty
ordagitty
- 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 usegeom_dag_point
- text
logical. Should text be included in the DAG?
- use_labels
a string. Variable to use for
geom_dag_label_repel()
. Default isNULL
.- expand_x, expand_y
Vector of range expansion constants used to add some padding around the data, to ensure that they are placed some distance away from the axes. Use the convenience function
ggplot2::expansion()
to generate the values for the expand argument.- breaks
One of:
NULL for no breaks
waiver() for the default breaks computed by the transformation object
A numeric vector of positions
A function that takes the limits as input and returns breaks as output
Value
a tidy_dagitty
with at least one DAG, including a dag
column to identify graph set for equivalent DAGs or a reversable
column for equivalent classes, or a ggplot
Examples
g_ex <- dagify(y ~ x + z, x ~ z)
g_ex %>% node_equivalent_class()
#> # A DAG with 3 nodes and 3 edges
#> #
#> # A tibble: 4 × 9
#> name x y direction to xend yend circular reversable
#> <chr> <dbl> <dbl> <fct> <chr> <dbl> <dbl> <lgl> <lgl>
#> 1 x 0 2 -> y 0.5 1 FALSE TRUE
#> 2 y 0.5 1 NA NA NA NA FALSE FALSE
#> 3 z 0.5 3 -> x 0 2 FALSE TRUE
#> 4 z 0.5 3 -> y 0.5 1 FALSE TRUE
g_ex %>% ggdag_equivalent_dags()