Learn R Programming

pcalg (version 1.1-4)

pdsep: Compute Possible-D-Sep for Each Node and Adapt Graph Accordingly

Description

Computes the Possible-D-Sep for each node and tests conditional independence given all subsets of Possible-D-Sep. The graph is updated accordingly.

Usage

pdsep(skel, suffStat, indepTest, p, sepset,
      pMax, NAdelete = TRUE, verbose = FALSE,
      alpha, unfVect = NULL, biCC = FALSE)

Arguments

skel
Graph object returned by skeleton.
suffStat
sufficient statistic: A list containing all necessary elements for making conditional independence decisions using function indepTest.
indepTest
predefined function for testing conditional independence. The function is internally called as indepTest(x,y,S,suffStat) for testing conditional independence of x and y given S. Here, x
p
number of variables
sepset
List of length p; each element of the list contains another list of length p. The element sepset[[x]][[y]] contains the separation set that made the edge between x and y drop out
pMax
Matrix with the maximal p-values of conditional independence tests in a previous call of skeleton, pc or fci
NAdelete
If indepTest returns NA and this option is TRUE, the corresponding edge is deleted. If this option is FALSE, the edge is not deleted.
verbose
If TRUE, detailed output is provided.
alpha
Significance level for the individual conditional independence tests
unfVect
vector containing numbers that encode the unfaithful triple (as returned by pc.cons.intern). This is needed in the conservative FCI.
biCC
logical; if true, only nodes on some path between a and c are considered to be in sepset(a,c). Uses biconnected components, biConnComp from RBGL.

Value

  • A list with several elements:
  • GUpdated adjecency matrix
  • sepsetUpdated sepset
  • pMaxUpdated matrix containing maximal p-values
  • allPdsepPossible d-sep for each node
  • max.ordMaximal order of conditioning sets during independence tests
  • n.edgetestsNumber of conditional edgetests performed grouped by size of conditioning set.

Details

For a given graph G, a node y is in Possible-D-Sep(x) if x!=y and there is an undirected path U between x and y in G such that for every subpath a,b,c of U either b is a collider on the subpath, or b is not a definite noncollider on U and a,b and c form a trianglein G.

Each pair of nodes x and y which is connected by an edge is tested for conditional independence given every subset in Possible-D-Sep of x or of y. The conditional independence is tested on significance level alpha by using the test given in indepTest. If the pair of nodes is judged to be independent given set S, then S is recorded in the sepset of x,y and in the sepset of y,x and the edge is deleted. Otherwise, the edge is not deleted and no entry to the sepset is made.

To make the code more efficient, tests that have been done during finding the skeleton are not done again.

References

P. Spirtes, C. Glymour and R. Scheines (2000). Causation, Prediction, and Search, 2nd edition. The MIT Press.

See Also

qreach for a fast way of finding Possible-D-Sep for a given node; fci which uses pdsep.

Examples

Run this code
p <- 10
## generate and draw random DAG :
myDAG <- randomDAG(p, prob = 0.2)
## generate 10000 samples of DAG using gaussian distribution
n <- 10000
d.mat <- rmvDAG(n, myDAG, errDist = "normal")

## estimate skeleton
indepTest <- gaussCItest
suffStat <- list(C = cor(d.mat), n = n)
alpha <- 0.01
skel <- skeleton(suffStat, indepTest, p, alpha)

## prepare input for pdsep
sepset <- skel@sepset
pMax <- skel@pMax
n.edgetestsSKEL <- skel@n.edgetests
max.ordSKEL <- skel@max.ord

## call pdsep to find possible d-sep and enhance the skeleton
pdsepRes <- pdsep(skel@graph, suffStat, indepTest, p, sepset, pMax, NAdelete,
verbose = TRUE, alpha)

Run the code above in your browser using DataLab