[R] bnlearn and cpquery

Ross Chapman rosspjchapman at gmail.com
Thu Jul 13 07:29:12 CEST 2017

Hi all


I have built a Bayesian network using discrete data using the bnlearn


When I try to run the cpquery function on this data it returns NaN for some
some cases.


Running the cpquery in debug mode for such a case (n=10^5, method="lw")
creates the following output:


generated a grand total of 1e+05 samples.

  > event has a probability mass of 14982.37 out of NaN (p = NaN).

[1] NaN



The cpquery command takes the following structure:



        evidence=list(GK_class = "ModHi",

                      GTh_class = "Lo",

                      GU_class = "Lo",

                      El_class = "Hi",

                      E50_class = "Med",

                      E150_class = "Med"

        ) ,

        n=10^5,   method =  "lw", debug=TRUE)


Similarly, when I try to run the predict method on the same data, it returns
the following warning:


Warning message:
In map.prediction(node = node, fitted = object, data = data, n =
extra.args$n,  :
  dropping 38073 observations because generated samples are NAs.



Could you advise me why these queries are generating NaN values, and how
they might be resolved.


The session info is as follows:


R version 3.4.1 (2017-06-30)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
[1] LC_COLLATE=English_Australia.1252  LC_CTYPE=English_Australia.1252
[4] LC_NUMERIC=C                       LC_TIME=English_Australia.1252    
attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     
other attached packages:
[1] bnlearn_4.2
loaded via a namespace (and not attached):
[1] compiler_3.4.1 tools_3.4.1   



Many thanks in advance




	[[alternative HTML version deleted]]

More information about the R-help mailing list