Skip to contents

Test whether two sets of nodes are m-separated given a conditioning set in an ancestral graph (AG) or an ADMG.

M-separation generalizes d-separation to AGs/ADMGs and applies to DAGs.

Usage

m_separated(
  cg,
  X = NULL,
  Y = NULL,
  Z = NULL,
  X_index = NULL,
  Y_index = NULL,
  Z_index = NULL
)

Arguments

cg

A caugi object of class AG, ADMG, or DAG.

X, Y, Z

Node selectors: character vector of names, unquoted expression (supports + and c()), or NULL. Use *_index to pass 1-based indices. If Z is NULL or missing, no nodes are conditioned on.

X_index, Y_index, Z_index

Optional numeric 1-based indices (exclusive with X,Y,Z respectively).

Value

A logical value; TRUE if X and Y are m-separated given Z.

Examples

# Classic confounding example
cg <- caugi(
  L %-->% X,
  X %-->% Y,
  L %-->% Y,
  class = "ADMG"
)
m_separated(cg, X = "X", Y = "Y") # FALSE (connected via L)
#> [1] FALSE
m_separated(cg, X = "X", Y = "Y", Z = "L") # TRUE (L blocks the path)
#> [1] FALSE