[R] Using "cpquery" function from bnlearn package inside loop

Ryan Morrison ryan.r.morrison at me.com
Fri Oct 11 21:44:43 CEST 2013


Hi Marco,

Thanks for the clarification. For my immediate purposes I think using the likelihood weighting method will suffice. I'm calculating conditional probabilities based on a single instantiation each time I use the function. The evidence I use for instantiation changes for each i+1 in my loop, and a new probability is computed using the new evidence. Since I'm using a single instantiation of the conditioning variables for each calculation in my loop, I believe the likelihood weighting method will work. Don't hesitate to correct me if I'm wrong.

Thanks,

---
Ryan

On Oct 11, 2013, at 1:25 PM, Marco Scutari <marco.scutari at gmail.com> wrote:

> Dear Ryan,
> 
> On 11 October 2013 16:50, Ryan Morrison <ryan.r.morrison at me.com> wrote:
>> The cpquery function is definitely easier to use given that my evidence is
>> contained in lists.
> 
> For the record, this is not a general solution to the bug. It's true
> that likelihood weighting (method = "lw") is easier to use in a
> programmatic way, but it is much more limited in the events you can
> use for conditioning. Logic sampling (method = "ls") accepts an
> arbitrary R expression as a conditioning event; likelihood weighting
> at the moment accepts only a single instantiation of the conditioning
> variables.
> 
> Cheers,
>    Marco
> 
> -- 
> Marco Scutari, Ph.D.
> Research Associate, Genetics Institute (UGI)
> University College London (UCL), United Kingdom



More information about the R-help mailing list