R bnlearn package: prevent node from having any parents

433 views Asked by At

Using the package bnlearn, is it possible to set a node to not be able to have any parents? I've found it is technically possible using the blacklist function. Example preventing "A" from having any parents in the included test data:

library(bnlearn)
blacklist = data.frame(from = c("B", "C", "D", "E", "F"), to = c("A"))
dat = gs(learning.test, blacklist = blacklist)

However, I'm working with data that has tens of thousands of nodes which should not be parents to each other, resulting in a blacklist that would be millions of lines long. I'm essentially looking for something like:

blacklist = data.frame(from = c("*", "A"))

Meaning no node can be a parent of A. Is this possible? If not, is there a Bayesian learning package anyone can recommend that has this functionality?

1

There are 1 answers

0
Flavia On

Also using blacklists but a bit more generic, you could do:

node.names <- names(learning.test)
blacklist <- data.frame(from = node.names[-grep("A", node.names)], 
                        to   = c("A"))