DarrenRhodes
DarrenRhodes

Reputation: 1503

Dimension Error found in bnlearn package application

This question has been asked before see here but not adequately answered.

Here's my code

library(bnlearn)
cpt_A <- matrix(c(0.8, 0.2), ncol = 2,
                     dimnames = list(NULL, c("True", "False")))
cpt_B <- matrix(c(0.2, 0.8), nrow = 1, ncol = 2,
                   dimnames = list(NULL, c("True", "False")))
cpt_C <- array(c(0.9, 0.6, 0.01, 0.1, 0.1, 0.4, 0.99, 0.9),
                      dim = c(2,2,2),
                      dimnames = list(A = c("True", "False"),
                                      B = c("True", "False"),
                                      C = c("True", "False")
                      )
)
net_C <- model2network("[A][B][C|A:B]")
fit_C <- custom.fit(net_C, list(A = cpt_A, 
                                B = cpt_B, 
                                C = cpt_C))

which returns the following error,

Error in check.dnode.rvalue.vs.parents(node, new = dist[[node]], parents = fitted[node.parents]) : 
  wrong dimensions for node C.

Can anyone provide an answer but with an explanation particularly with respect to debugging if this happens again?

Upvotes: 0

Views: 40

Answers (0)

Related Questions