findDescendants: Returns and plots, if asked, the descendants or ancestors of...

View source: R/findDescendants.R

Ancestors and descendants of a node in a directed graphR Documentation

Returns and plots, if asked, the descendants or ancestors of one or all node(s) (or variable(s))

Description

Returns and plots, if asked, the descendants or ancestors of one or all node(s) (or variable(s))

Usage

findDescendants(G, node = NULL, graph = FALSE)
findAncestors(G, node = NULL, graph = FALSE)

Arguments

G

The graph matrix as produced from pc.or or any other algorithm which produces directed graphs.

node

A numerical value indicating the node (or variable) whose descendants are to be returned.

graph

A boolean variable. If TRUE the relevant graph will appear (if there are descendants).

Details

The functions searches for the descendants of some node. This is an S3 class output.

Value

isAnc

A matrix of the same dimensions as the original graph matrix with 0s and 1s. isAnc[i, j] = 1 indicates that the i-th node is an ancestor of the j-th node. If the argument "node" is NULL, only this matrix will be returned.

Ganc

A matrix of dimensions equal to the number of descendants of the node with 0s and 1s, if the argument "node" is not NULL.

anc

The descendants of the node if the argument "node" is not NULL.

Author(s)

Anna Roumpelaki

R implementation and documentation: Anna Roumpelaki <anna.roumpelaki@gmail.com>

See Also

plotnetwork, nei, mb, pc.or

Examples

# simulate a dataset with continuous data
y = rdag(1000, 10, 0.3)
tru = y$G 
x = y$x
mod = pc.con(x)
G = pc.or(mod)$G
plotnetwork(G)
findDescendants(G, 4, graph = FALSE)
findAncestors(G, 4, graph = FALSE)
findAncestors(G)

MXM documentation built on Aug. 25, 2022, 9:05 a.m.