I'm trying to train a Bayesian network with a mixed model.
wl <- matrix(c("DR", "DT", "LN", "DL", "DL", "DT"), ncol = 2, byrow = TRUE)
bl <- matrix(c("DT", "D", "DT", "DR", "DT", "DL", "DT", "FT", "DT", "FS", "DT", "FC", "DT", "FA", "DT", "LN", "D", "DL", "DT", "CO", "DT", "BPM25", "DT", "PM10", "DT", "SWS", "DT", "VWD", "DR", "D", "DR", "FT", "DR", "FS", "DR", "FC", "DR", "FA", "DR", "LN", "DR", "CO", "DR", "BPM25", "DR", "PM10", "DR", "SWS", "DR", "VWD", "DL", "D", "DL", "FT", "DL", "FS", "DL", "FC", "DL", "FA", "DL", "LN", "DL", "CO", "DL", "BPM25", "DL", "PM10", "DL", "SWS", "DL", "VWD", "CO", "FT", "CO", "FS", "CO", "FC", "CO", "FA", "BPM25", "FT", "BPM25", "FS", "BPM25", "FC", "BPM25", "FA", "PM10", "FT", "PM10", "FS", "PM10", "FC", "PM10", "FA", "PM10", "VWD", "PM10", "CO", "BPM25", "CO", "DL", "DR", "VWD", "D", "FT", "D", "FS", "D", "FA", "D", "PM10", "D", "LN", "D", "FC", "D", "BPM25", "D", "SWS", "D"), ncol = 2, byrow = TRUE)
net <- hc(df, blacklist = bl, whitelist = wl)
graphviz.plot(net)
fit <- bn.fit(net, df)
The hill-climbing algorithm works fine. However, when I try to fit the data, it fails wit the
INTEGER() can only be applied to a 'integer', not a 'double'
here is my str(df)
output:
'data.frame': 337676 obs. of 14 variables:
$ LN : Factor w/ 15 levels "Alphington","Altona North",..: 1 1 1 1 1 1 1 1 1 1 ...
$ D : Date, format: "2019-04-15" "2019-12-29" "2019-12-29" "2019-12-29" ...
$ DR : num 33.7 33 33 33 33 ...
$ DT : num 381 354 354 354 354 ...
$ FT : Factor w/ 2 levels "BURN","BUSHFIRE": 1 2 2 2 2 2 2 1 2 2 ...
$ FS : Factor w/ 6 levels "BURNT_1","BURNT_2F",..: 3 3 4 4 4 1 4 2 2 1 ...
$ FC : Factor w/ 7 levels "0-9","10-29",..: 6 6 6 6 6 6 6 5 6 6 ...
$ FA : Factor w/ 6 levels "L","M","NA","S",..: 6 2 4 6 6 6 6 6 6 2 ...
$ CO : Factor w/ 2 levels "LOW","MED": 1 1 1 1 1 1 1 1 1 1 ...
$ BPM25: Factor w/ 3 levels "HIGH","LOW","MED": 3 2 2 2 2 2 2 3 2 2 ...
$ PM10 : Factor w/ 3 levels "HIGH","LOW","MED": 1 3 3 3 3 3 3 3 3 3 ...
$ SWS : Factor w/ 3 levels "HIGH","LOW","MED": 2 2 2 2 2 2 2 3 2 2 ...
$ VWD : Factor w/ 5 levels "East","Eeast",..: 3 5 5 5 5 5 5 3 5 5 ...
$ DL : num 41 41 41 41 41 41 41 41 41 41 ...
And this is a learned network:
and link to the dataset https://1drv.ms/u/s!AjYX1QIwxaySkngPNn6nvcmL5L0g?e=chehjR