p <- 10 # Number of random variables
s <- 0.4 # Sparseness of the DAG
## Generate a random DAG
set.seed(42)
require(graph)
dag <- randomDAG(p, s)
nodes(dag) <- sprintf("V%d", 1:p)
## Calculate observational essential graph
res.obs <- dag2essgraph(dag)
## Different argument classes
res2 <- dag2essgraph(as(dag, "GaussParDAG"))
str(res2)
## Calculate interventional essential graph for intervention targets
## {1} and {3}
res.int <- dag2essgraph(dag, as.list(c(1, 3)))
Run the code above in your browser using DataLab