Skip to contents

Stratifying on colliders can open biasing pathways between variables. activate_collider_paths activates any such pathways given a variable or set of variables to adjust for and adds them to the tidy_dagitty.

Usage

activate_collider_paths(.tdy_dag, adjust_for, ...)

Arguments

.tdy_dag

input graph, an object of class tidy_dagitty or dagitty

adjust_for

a character vector, the variable(s) to adjust for.

...

additional arguments passed to tidy_dagitty()

Value

a tidy_dagitty with additional rows for collider-activated pathways

Examples

dag <- dagify(m ~ x + y, x ~ y)

collided_dag <- activate_collider_paths(dag, adjust_for = "m")
collided_dag
#> # DAG:
#> # A `dagitty` DAG with: 3 nodes and 3 edges
#> # Paths opened by conditioning on a collider: x <-> y, x <-> y
#> #
#> # Data:
#> # A tibble: 6 × 8
#>   name       x      y direction to      xend   yend collider_line
#>   <chr>  <dbl>  <dbl> <fct>     <chr>  <dbl>  <dbl> <lgl>        
#> 1 m     -0.130 -1.10  NA        NA    NA     NA     FALSE        
#> 2 x      0.871 -1.14  ->        m     -0.130 -1.10  FALSE        
#> 3 y      0.404 -0.256 ->        m     -0.130 -1.10  FALSE        
#> 4 y      0.404 -0.256 ->        x      0.871 -1.14  FALSE        
#> 5 x      0.871 -1.14  <->       y      0.404 -0.256 TRUE         
#> 6 x      0.871 -1.14  <->       y      0.404 -0.256 TRUE         
#> #
#> # ℹ Use `pull_dag() (`?pull_dag`)` to retrieve the DAG object and `pull_dag_data() (`?pull_dag_data`)` for the data frame