Hi Alexandr, On 11 November 2014 00:10, Alexandr M <rus...@gmail.com> wrote: > Sorry that I formulated my question not very accurately. > I form expressions/(logic conditions for parameters evidence and event) > dynamically inside the loop and they are sometimes quite long.
By any chance, are using that for prediction? Because predict(..., method = "bayes-lw") does posterior predictions from any set of variables. As an alternative, you can do cpdist(..., method = "lw") which also generates from the posterior distribution: > str(cpdist(fit, node = "A", evidence = list(B = "b"), method = "lw")) Classes ‘bn.cpdist’ and 'data.frame': 10000 obs. of 1 variable: $ A: Factor w/ 3 levels "a","b","c": 1 2 2 3 1 1 1 2 1 1 ... - attr(*, "weights")= num 0.114 1 1 0.428 0.114 ... - attr(*, "method")= chr "lw" To compute P(A = a | whatever you conditioned on), just sum the corresponding weights over the total weight mass. Since no language trickery is involved, this works reliably. Cheers, Marco -- Marco Scutari, Ph.D. Lecturer in Statistics, Department of Statistics University of Oxford, United Kingdom ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.