0

I learnt Bayesian Network (BN) structures with the bnlearn package in R. However, for some of my BN, I have undirected edges.

Thus, when I want to fit the BN (i.e. learn the Conditional Probability Tables = CPT), I obtain this error message telling me that it is not possible to learn CPT:

Error in bn.fit(struct_list[[i]][[ii]], data = dbnBnlearn_general %>% ... : the graph is only partially directed.

So my question is: is there a way to force the structure to be directed (I tried the undirected argument of the structure learning algorithm but there are still undirected edges)?

Cheers

FrsLry
  • 348
  • 4
  • 19
  • 1
    `?bnlearn::cextend` (or you could use a score based alg to learn the structure) – user20650 Feb 27 '21 at 11:54
  • I tried to use it but this time I have: `Error in cextend(struct_list[[3]][[1]]) : no consistent extension of struct_list[[3]][[1]] is possible.` – FrsLry Feb 27 '21 at 16:22
  • 1
    see `?cextend` ; you can force it to return a partially directed graph with the `strict` parameter. Maybe then inspect the graph to see why it cannot be extended further? Does adding `debug=TRUE` give any useful info? This question then might be a better fit for https://stats.stackexchange.com -- but an example would be needed. – user20650 Feb 27 '21 at 17:10
  • 1
    ps it may not be possible to extend as it adding an additional edge may introduce new v-structures or cycles. – user20650 Feb 27 '21 at 17:22
  • 1
    Yes, I think it is just not possible to introduce a new v-structure. Thx a lot for your help – FrsLry Feb 27 '21 at 20:09

0 Answers0