Learn R Programming

pcalg (version 1.0-0)

dsepTest: Test for d-separation in a DAG

Description

This function tests for d-separation of nodes in a DAG. The function was organized in a way, so that it can easily be used in skeleton, pc, fci.

Usage

dsepTest(x, y, S, suffStat)

Arguments

x
Position of node X in adjacency matrix
y
Position of node Y in adjacency matrix
S
Position of set of nodes in adjacency matrix on which is conditioned
suffStat
A list with two elements: (1) Element "g" containing the Directed Acyclic Graph (object of class "graph", see graph-class from th

Value

  • If x and y are d-separated by S in DAG G the result is 1, otherwise it is 0. This is analogous to the p-value of an ideal (without sampling error) conditional independence test on any distribution that is faithful to the DAG G.

Details

The function is based on dsep. For details on d-separation see the reference.

References

Kalisch M. and P. B"uhlmann (2007) Estimating high-dimensional directed acyclic graphs with the PC-algorithm; JMLR, Vol. 8, 613-636, 2007.

See Also

gaussCItest, disCItest and binCItest for similar functions for a conditional independence test on gaussian variables, on discrete variables and on binary variables, respectively.

Examples

Run this code
p <- 8
set.seed(45)
myDAG <- randomDAG(p, prob = 0.3)

## plot the DAG
plot(myDAG, main = "randomDAG(10, prob = 0.2)")

## define sufficient statistics (d-separation oracle)
suffStat <- list(g = myDAG, jp = johnson.all.pairs.sp(myDAG))

dsepTest(1,6,NULL,suffStat) ## not d-separated
dsepTest(1,6,3,suffStat) ## not d-separated by node 3
dsepTest(1,6,c(3,4),suffStat) ## d-separated by node 3 and 4

Run the code above in your browser using DataLab