[R] cpquery problem

Marco Scutari marco.scutari at gmail.com
Fri Jul 29 11:34:58 CEST 2016


Hi Ross,

 first, I have a side question: is there a particular reason why you
are using parse(eval()) in your queries? I know sometimes there is no
other solution if you only use exported functions, but you should try
not to. It makes for brittle code that breaks easily depending on how
variables are scoped.

On 29 July 2016 at 07:37,  <ross.chapman at ecogeonomix.com> wrote:
> However, if I replace EST=='x' with EST=='z' or EST=='y' I get 0 probability
> of obtaining a value for ABW that is either greater or less than the
> threshold.
>
> For example:
>
>> cpquery(fitted,event=(ABW>=11), evidence=eval(parse(text="(EST=='y' & TR>9
> & BU>15819 &  RF>2989)")),n=10^6)
>
> [1] 0
>
> and
>
>> cpquery(fitted,event=(ABW<=11), evidence=eval(parse(text="(EST=='y' & TR>9
> & BU>15819 &  RF>2989)")),n=10^6)
>
> [1] 0

>From this output, my guess is that the evidence has probability
(exactly or close to) zero. You can check by running cpdist(): if the
evidence has probability zero, no random samples will be returned.
Turning on the debugging output in cpquery() should also highlight
what the problem is.

If that turns out to be the case, switch from the default method =
"ls" to method = "lw" in cpdist(). (Note that the syntax changes
slightly, check the documentation for examples.)

> My own knowledge from the data is that these classes should both typically
> return a value for ABW that is very much higher than the threshold value.

That may be, but much depends on the specific sample the model was
fitted from. How does the fitted network look like?

Cheers,
    Marco

-- 
Marco Scutari, Ph.D.
Lecturer in Statistics, Department of Statistics
University of Oxford, United Kingdom



More information about the R-help mailing list