Skip to main content

Test d-separation

Source: R/identification.R

Description

Two nodes are d-separated given a conditioning set given if every path between them is blocked. A path is blocked if it contains either a non-collider node in given, or a collider node (and all its descendants) not in given.

Usage

d_separated(cg, x, y, given = character())

Arguments

cg A DAG or PDAG-family (PDAG, CPDAG, MPDAG) graph created with cgraph().
x, y Node name, or character vector of node names (to test whether the two sets are separated).
given Character vector of conditioning node names (may be empty).

Value

TRUE if x and y are d-separated given given.

Examples

chain <- cgraph(A %-->% B, B %-->% C)
d_separated(chain, "A", "C") # chain A --> B --> C is open
#> [1] FALSE
d_separated(chain, "A", "C", "B") # conditioning on B
#> [1] TRUE

collider <- cgraph(A %-->% C, B %-->% C)
d_separated(collider, "A", "B") # collider is blocked
#> [1] TRUE
d_separated(collider, "A", "B", "C") # conditioning opens it
#> [1] FALSE