
Theory and Algorithms for Bayesian Networks 95
It is also easy, for the sake of the example, to perform moralisation man-
ually. First, we ide ntify the v-structures in the DAG and we link the parents
within each v-structure with an undirected arc (e.g., an edge).
> mg2 <- dag
> vs <- vstructs(dag)
> for (i in seq(nrow(vs)))
+ mg2 <- set.edge(mg2, from = vs[i, "X"], to = vs[i, "Y"],
+ check.cycles = FALSE)
This step appears to introduce potential cycles in the resulting PDAG. How-
ever, we can safely ignore them since we are going to construct the undirected
graph underlying mg2, thus replacing each directed arc with an undirected
one.
> mg2 <- skeleton(mg2) ...