dag2cpdag | R Documentation |
Convert a DAG (Directed Acyclic Graph) to a Completed Partially Directed Acyclic Graph (CPDAG).
dag2cpdag(g)
g |
an R object of class |
This function converts a DAG into its corresponding
(unique) CPDAG as follows. Because every DAG in the
Markov equivalence class described by a CPDAG shares the same skeleton
and the same v-structures, this function takes the skeleton and the
v-structures of the given DAG g
. Afterwards it simply uses the
3 orientation rules of the PC algorithm (see references) to orient as
many of the remaining undirected edges as possible.
The function is a simple wrapper function for dag2essgraph
which is more powerfull since it also allows the calculation of the
Markov equivalence class in the presence of interventional data.
The output of this function is exactly the same as the one using
pc(suffStat, indepTest, alpha, labels)
using the true correlation matrix in the function gaussCItest
with a large virtual sample size and a large alpha, but it is much
faster.
A graph object containing the CPDAG.
Markus Kalisch (kalisch@stat.math.ethz.ch) and Alain Hauser(alain.hauser@bfh.ch)
C. Meek (1995). Causal inference and causal explanation with background knowledge. In Proceedings of the Eleventh Conference on Uncertainty in Artificial Intelligence (UAI-95), pp. 403-411. Morgan Kaufmann Publishers, Inc.
P. Spirtes, C. Glymour and R. Scheines (2000) Causation, Prediction, and Search, 2nd edition, The MIT Press.
dag2essgraph
, randomDAG
, pc
## A -> B <- C
am1 <- matrix(c(0,1,0, 0,0,0, 0,1,0), 3,3)
colnames(am1) <- rownames(am1) <- LETTERS[1:3]
g1 <- as(t(am1), "graphNEL") ## convert to graph
cpdag1 <- dag2cpdag(g1)
if(requireNamespace("Rgraphviz")) {
par(mfrow = c(1,2))
plot(g1)
plot(cpdag1)
}
## A -> B -> C
am2 <- matrix(c(0,1,0, 0,0,1, 0,0,0), 3,3)
colnames(am2) <- rownames(am2) <- LETTERS[1:3]
g2 <- as(t(am2), "graphNEL") ## convert to graph
cpdag2 <- dag2cpdag(g2)
if(requireNamespace("Rgraphviz")) {
par(mfrow = c(1,2))
plot(g2)
plot(cpdag2)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.