Learn R Programming

pcalg (version 1.0-0)

pdsep: Compute possible d-sep for each node and test and adapt graph accordingly

Description

This function computes the possible d-sep for each node. Then, 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.

Usage

pdsep(G, suffStat, indepTest, p, sepset, pMax, NAdelete = TRUE, verbose
= FALSE, alpha)

Arguments

G
Boolean adjacency matrix (TRUE if there is an edge)
suffStat
Sufficient statistics: 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

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

To make the code more efficient, only condtioning sets that have not been tested in a previous call of skeleton are tested. For example, subsets of the adjacency of a node without additional nodes from possible d-sep are not considered alone, but only in combination with nodes from possible d-sep. Within the nodes of possible d-sep that are not in the adjacency of a node, all possible subsets are tested.

References

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

See Also

qreach for a fast way of finding possible d-sep for a given node

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
G <- (as(skel@graph,"matrix")!=0)
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(G, suffStat, indepTest, p, sepset, pMax, NAdelete,
verbose = TRUE, alpha)

Run the code above in your browser using DataLab