is_collider: Detecting colliders in DAGs

View source: R/colliders.R

Test if Variable Is ColliderR Documentation

Detecting colliders in DAGs

Description

Detecting colliders in DAGs

Usage

is_collider(.dag, .var, downstream = TRUE)

is_downstream_collider(.dag, .var)

Arguments

.dag

an input graph, an object of class tidy_dagitty or dagitty

.var

a character vector of length 1, the potential collider to check

downstream

Logical. Check for downstream colliders? Default is TRUE.

Value

Logical. Is the variable a collider or downstream collider?

Examples

dag <- dagify(m ~ x + y, m_jr ~ m)
is_collider(dag, "m")
is_downstream_collider(dag, "m_jr")

#  a downstream collider is also treated as a collider
is_collider(dag, "m_jr")

#  but a direct collider is not treated as a downstream collider
is_downstream_collider(dag, "m")


ggdag documentation built on Sept. 11, 2024, 6:12 p.m.