Skip to contents

Identify exogenous (parentless) variables in a DAG.

Usage

query_exogenous(.tdy_dag)

Arguments

.tdy_dag

A tidy DAG object.

Value

A tibble with columns:

  • node: The exogenous variable

  • n_descendants: Number of descendant nodes

Examples

library(ggdag)
dag <- dagify(
  y ~ x + z,
  x ~ w
)

query_exogenous(dag)
#> # A tibble: 2 × 2
#>   node  n_descendants
#>   <chr>         <int>
#> 1 w                 2
#> 2 z                 1