Skip to contents

Get the anterior set of nodes in a graph. The anterior set (Richardson and Spirtes, 2002) includes all nodes reachable by following paths where every edge is either undirected or directed toward the target node.

For DAGs, the anterior set equals the ancestor set (since there are no undirected edges). For PDAGs, it includes both ancestors and nodes reachable via undirected edges.

Usage

anteriors(cg, nodes = NULL, index = NULL)

Arguments

cg

A caugi object of class DAG or PDAG.

nodes

A vector of node names, a vector of unquoted node names, or an expression combining these with + and c().

index

A vector of node indexes.

Value

Either a character vector of node names (if a single node is requested) or a list of character vectors (if multiple nodes are requested).

References

Richardson, T. and Spirtes, P. (2002). Ancestral graph Markov models. The Annals of Statistics, 30(4):962-1030.

Examples

# PDAG example with directed and undirected edges
cg <- caugi(
  A %-->% B %---% C,
  B %-->% D,
  class = "PDAG"
)
anteriors(cg, "A") # NULL (no anteriors)
#> NULL
anteriors(cg, "C") # A, B
#> [1] "A" "B"
anteriors(cg, "D") # A, B, C
#> [1] "A" "B" "C"

# For DAGs, anteriors equals ancestors
cg_dag <- caugi(
  A %-->% B %-->% C,
  class = "DAG"
)
anteriors(cg_dag, "C") # A, B
#> [1] "A" "B"