I am new to Bayesian Networks. I am trying to use catnet package in R, however, I am having difficulty understanding the output of cnProb() function. For instance, here is a new catnetwork object:
cnet_test <- cnNew(
nodes = c("a", "b", "c"),
cats = list(c("1","2"), c("1","2"), c("1","2")),
parents = list(NULL, c(1), c(1,2)))
This should then result in a network like this, right? I am assuming parents = parameter here means node X is parent of ...
However, when doing cnProb() on this catnet object, it returns the following:
$a
1 2
0.19 0.81
$b
a 1 2
A 1 0.396 0.604
B 2 0.611 0.389
$c
a b 1 2
A 1 1 0.519 0.481
B 1 2 0.878 0.122
A 2 1 0.666 0.334
B 2 2 0.89 0.11
This seems the exact opposite of the network diagram. According to the documentation, cnprob:
Returns the list of conditional probabilities of nodes specified by which parameter of a catNetwork object. Node probabilities are reported in the following format. First, node name and its parents are given, then a list of probability values corresponding to all combination of parent categories (put in brackets) and node categories. For example, the conditional probability of a node with two parents, such that both the node and its parents have three categories, is given by 27 values, one for each of the 333 combination.
I am wondering how exactly do we interpret the output from cnProb? or is my interpretation of cnNew's parents parameter wrong. Any information will be helpful.
Your interpretation of "parents" parameter in cnNew() is incorrect and your diagram does not corresponds to the network you actually define. "parents = list(NULL, c(1), c(1,2))" means that "1" is parent of "2" and "1 and 2" are parents of "3". So, the network is {a->b; a->c, b->c}.