Learn R Programming

pcalg (version 1.0-0)

dsep: Test for d-separation in a DAG

Description

This function tests for d-separation of nodes in a DAG.

Usage

dsep(a, b, S, g, john.pairs = NA)

Arguments

a
Label of node A
b
Label of node B
S
Labels of set of nodes on which is conditioned
g
Element "g" containing the Directed Acyclic Graph (object of class "graph", see graph-class from the package graph)
john.pairs
The shortest path distance matrix for all pairs of nodes as computed by johnson.all.pairs.sp in graph.

Value

  • TRUE if a and b are d-separated by S in G, otherwise FALSE.

Details

This function checks separation in the moralized graph as explained in Lauritzen.

References

S.L. Lauritzen (2004) Graphical Models, Oxford University Press, Chapter 3.2.2

See Also

dsepTest for a wrapper of this function that can easily be included into skeleton, pc or fci

Examples

Run this code
## generate random DAG
p <- 8
set.seed(45)
myDAG <- randomDAG(p, prob = 0.3)
plot(myDAG)

## Examples for d-separation
dsep("1","7",NULL,myDAG)
dsep("4","5",NULL,myDAG)
dsep("4","5","2",myDAG)
dsep("4","5",c("2","3"),myDAG)

## Examples for d-connection
dsep("1","3",NULL,myDAG)
dsep("1","6","3",myDAG)
dsep("4","5","8",myDAG)

Run the code above in your browser using DataLab