[R] cpquery problem
    ross.chapman at ecogeonomix.com 
    ross.chapman at ecogeonomix.com
       
    Fri Jul 29 08:37:03 CEST 2016
    
    
  
Hi all
 
I have a problem with the cpquery function in the bnlearn package.
 
I have constructed a hybrid network (using a mix of continuous and discrete
variables).
 
The network is named "fitted".
 
I am interested in predicting the probability of observing a value greater
that a particular threshold in a continuous variable (ABW) from evidence
presented in a mix of continuous and discrete variables.
 
One of the continuous variables (EST) takes 3 values, x, y and z.
 
I find that the cpquery gives very plausible results if the EST is set to
equal x.
 
For example:
 
> cpquery(fitted,event=(ABW>=11), evidence=eval(parse(text="(EST=='x' & TR>9
& BU>15819 &  RF>2989)")),n=10^6)
[1] 0.7471088
 
While inverting the threshold for ABW gives: 
 
> cpquery(fitted,event=(ABW<=11), evidence=eval(parse(text="(EST=='x' & TR>9
& BU>15819 &  RF>2989)")),n=10^6)
[1] 0.2587795
 
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
 
I do not understand why classes y and z are returning 0 probabilities for
these queries.  
 
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.
 
Can you help me understand why my cpquery code is not giving the anticipated
results for x and y? 
 
Many thanks
 
Ross
 
	[[alternative HTML version deleted]]
    
    
More information about the R-help
mailing list