[R] Strange error while passing string as an argument to the function in bnlearn package

Alexandr M rus314 at gmail.com
Fri Nov 14 10:26:48 CET 2014


Hello Marco,

> By any chance, are using that for prediction?

Yes, I am using it for prediction.

> 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.

Thank you! It's exactly what I needed.

---
BR,
Alexandr

On 11 November 2014 23:33, Marco Scutari <marco.scutari at gmail.com> wrote:

> Hi Alexandr,
>
> On 11 November 2014 00:10, Alexandr M <rus314 at 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
>



-- 
Best regards,
Alexander Maslov

	[[alternative HTML version deleted]]



More information about the R-help mailing list