1

Hi Stackoverflow users,

I'm trying to use the bnlearn package in R to learn the structure of a Bayes Net, however my training data is incomplete. When I try to fit a baynes net using any learning algorithm gs(), hc()... i get an error message.

Does anyone know how I can get around this problem? It seems there isn't a suitable alternative package in R that can deal with missing data yet.

> wildelakedata[wildelakedata==9999]<-NA
> wildelakedata[1:10,]
   Install.Yr Hist Eco PWA Anom SF
1        1968    1   4   0   NA NA
2        1968    1   4   0   NA NA
3        1968    1   4   1   NA NA
4        1968    1   4   1   NA NA
5        1968    1   4   1   NA NA
6        1968    1   4   1   NA NA
7        1968    1   4   0   NA NA
8        1968    1   4   0   NA NA
9        1968    1   4   1   NA NA
10       1968    1   4   0   NA NA
> BN<-hc(wildelakedata)
Error in check.data(x) : the data set contains NULL/NaN/NA values.

Thomas

ThomasChen
  • 11
  • 3
  • 1
    With programming questions you should post a [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and the code you've tried. If you're seeking a methodological recommendation for dealing with missing data in a Bayes Net, you should post to [stats.se] instead. – MrFlick Jun 19 '15 at 17:53
  • `bnlearn` requires no missing data. You can omit rows with any missing data with `na.omit`, which obviously makes assumptions over the type of missing... ie `BN <- hc(na.omit(wildelakedata))`. But i would look at the proportion of missing in each column - if `Anom` and `SF` have a lot it might be as well omitting them from the search. if your variables are all categorical, perhaps `catnet` package offers an alternative. – user20650 Jul 03 '15 at 03:18
  • thanks for the response! i'll look into using the catnet package, if not I can just drop the covarites with missing data, the na.omit function will cut my training set in more than half – ThomasChen Jul 27 '15 at 13:47

0 Answers0