I have an undirected graph (i.e. a set of undirected arcs). Bnlearn package doesn't seem to allow to learn from an undirected graph/network. For eg giving undirected graph for 'start' parameter in hill-climbing hc() function gives error "the graph is only partially directed". Is there a way to learn a directed acyclic graph (DAG) from an undirected graph either using bnlearn or any other package in R ? Thanks in Advance.
Asked
Active
Viewed 76 times
0
-
You **may** be able to coerce the undirected graph to a directed prior to learning using `cextend` (but there is no guarantee that this will be possible e.g. you wont be able to do this if it introduces new v-structures) which you could than pass to the structure learning algorithm. – user20650 Apr 11 '23 at 16:35
-
Perhaps as an alt this might work; use a Bayesian learning score and add a prior to each edge 0f 0.5 in each direction. For example, to start with an undirected edge between nodes `A` and `C`, add a prior on the edge of 0.5 e,g, `b=data.frame(from=c("A","F"), to=c("F","A"), prob=0.5); m = hc(learning.test, score="bde", prior="cs", beta=b)`. You should be able to programmatically convert your undirected graph to an edge list easily enough. – user20650 Apr 11 '23 at 16:51
-
Thanks for your response. What does prior="cs" stand for ? and what parameter is beta in hc() function which I could not find in the documentation of hc() function. – Kumar Apr 20 '23 at 11:17
-
Kumar; please see the [documentation for the score function](https://www.bnlearn.com/documentation/man/score.html). btw on reading my second comment; this might not be what you want as (I think) it will ensure that the edges that you supply (that are present in your undirected graph) are present in the final graph, in one direction or the other (v-structures permitting).. – user20650 Apr 20 '23 at 13:58