0

I have a data frame with all columns in discrete format. I apply the following code to generate a BN using bnlearn package. However I get this error that says "score 'bic' may be used with discrete data only" while essentially my data are discrete! Here is a sample of my data:

      A         B         C
      3         2         0
      0         0         5
      5         1         7
      0         0         2
      4         6         1

And this is what I run:

  > test=hc(dat, score="bic")
  Error in check.score(score, x) : 
  score 'bic' may be used with discrete data only.

I don't get why my data is not seen as discrete?

13554N
  • 37
  • 9
  • 1
    Your data is very likely numeric or integer (check with sapply(dat, class) ), hence bnlearn will treat it as continuous.Then the score to use is bic-g. If your data represent categories then coerce them to factors. – user20650 Jul 28 '17 at 12:07
  • the "bic-g" is for the Gaussian data types? What if my data is not Gaussian? – 13554N Jul 29 '17 at 05:23
  • 1
    bnlearn, only fits gaussian, conditional linear gaussian , and discrete nets. For other distributions, you will need a different tool (which will be less efficient). http://www.r-bayesian-networks.org/ (untested) or if you have a net you can use mcmc methods for inference – user20650 Jul 29 '17 at 12:25

0 Answers0