I'm using an r-package "bnlearn" to work with a bayes net I have constructed:
bn.gs <- gs(x = dat, cluster = NULL, whitelist = wl, blacklist = bl, test = NULL, alpha = 0.05, B = NULL, debug = FALSE, optimized = TRUE, strict = FALSE, undirected = FALSE)
It gives me a nice plot and everything seems to work well. All the variables are continuous and between -1 and 1. The feeding variables (those with no parents) were generated as below (N = 1000):
A <- runif(N, min=-1, max=1)
Let's assume that my variables are A, B, ... Z, and I know the values of C, G and M. Now I would like to predict the values of the rest of the nodes (A, B, D, ...) given C, G and M. As far as I am concerned, predict() works for one node at a time.
Is there a method to predict multiple nodes simultaneously, or should I end up getting right values by applying predict() to each node at time? I already tried to predict the value for node "A", given the value of "C":
predict(bn.gs, node = "A", testdata, debug = TRUE)
where testdata is a data frame in this form:
A B C D E ...
0.0 0.0 0.7 0.0 0.0 ...
but I get this:
* predicting values for node A.
> prediction for observation 1 is nan with predictor:
(0.000000) + (0.000000) * (nan) + (0.000000) * (nan)
[1] NA
I'm positive that I am doing something wrong here. In my network there are arcs C -> S -> A. Also "nan"s are weird, since my network should be well defined.
Thank you already :).