This function receives a simple list with one or more couple of variables and mount a new data frame in "bnlearn" syntax. The final result must return an object similar to the result of bnlearn command "data.frame(from = c('B', 'F'), to = c('F', 'B'))" that is more complex syntax.
is a list of couple of variables.
A new data frame with the 'from' and 'to' variables
Scutari M (2017). Bayesian Network Constraint-Based Structure Learning Algorithms: Parallel and Optimized Implementations in the bnlearn R Package. Journal of Statistical Software, 77(2), 1-20.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
# Clean environment closeAllConnections() rm(list=ls()) # Set enviroment # setwd("To your working directory") # Load packages library(bnpa) library(bnlearn) # Load data sets from package data(dataQuantC) # Show the first lines of data head(dataQuantC) # Learn the BN structure without black and white list bn.structure <- hc(dataQuantC) # Split graph panel in 2 columns par(mfrow=c(1,2)) # Show the BN structure bnlearn::graphviz.plot(bn.structure) # Mounting the black list black.list <- ("A-C,D-F") black.list <- mount.wl.bl.list(black.list) black.list white.list <- ("A-B,D-G") white.list <- mount.wl.bl.list(white.list) white.list # Learn the BN structure with black and white list bn.structure <- hc(dataQuantC, whitelist = white.list, blacklist = black.list) # Show the BN structure bnlearn::graphviz.plot(bn.structure)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.