Why TABU algorithm in bnlearn gives error for some numeric type dataset?

147 views Asked by At

I was trying to use 'tabu' algorithm in bnlearn package in r to draw the Bayesian network. I have a data frame contains large data set and all of the columns are numeric type. I am getting the following error:

Error in if (abs(x1 - x2) < sqrt(.Machine$double.eps)) return(0) else return(x1 -  : 
  missing value where TRUE/FALSE needed

I don't have any missing vales in my data set.

Here is my attempt:

  data = data.frame(data)
  res=tabu(data)
  graphviz.plot(res) 

Thanks in advance.

1

There are 1 answers

0
user20650 On

The error was due to a bug in tabu, in bnlearn versions <= 4.8.1, in how constant, or latent, variables were treated.

The package author has released an update which can be installed from the bnlearn website

install.packages("https://www.bnlearn.com/releases/bnlearn_4.9-20230309.tar.gz", type="source", repos=NULL)

Now the following example should run without the error observed in the OP

library(bnlearn)  # packageVersion("bnlearn") ‘4.9.20230309’
data(gaussian.test)
gaussian.test$L = 1.21
tabu(gaussian.test)