catnet-package {catnet}R Documentation

catnet: Categorical Bayesian network inference


catnet package provides tools for learning categorical Bayesian networks from data with focus on model selection. A Bayesian network is defined by a graphical structure in form of directed acyclic graph and a probability model given as a set of conditional distributions, one for each node in the network. Considered in the package are only categorical Bayesian networks - networks which nodes represent discrete random variables. The learning functions implemented in catnet are based on exhaustive search and output sets of networks with increasing complexity that fit the data according to MLE-based criteria. The final network selection is left to the user. These selected networks represent the relations between the node-variables in the data optimally.

Before starting to use the package, we suggest the user to take a look at some of the main objects used in catnet such as catNetwork and catNetworkEvaluate and then familiarize with the main search functions cnSearchOrder and cnSearchSA. More details and examples can be found in the manual pages and the vignettes accompanying the package.

Since catnet does not have its own plotting abilities, the user needs to setup some external tools in order to visualize networks, or more precisely, catNetwork objects. catnet provides interface to the Graphviz library for visualizing graphs. Graphviz is not a R-package but a platform independent library that the user have to install in advance on its machine in order to use this option.

In order to use Graphviz, in addition to installing the library, the user has to register a environmental variable with name R_DOTVIEWER with the path to the Dot executable file of Graphviz. The Dot routine generates a postscript or pdf-file from a text dot-file. Also, the user needs a postscript and pdf-viewer. The full path to it has to be given in another variable with name R_PDFVIEWER. Note that R_PDFVIEWER variable might be already setup. To check this call Sys.getenv("R_PDFVIEWER") in R.

The variables R_DOTVIEWER and eventually R_PDFVIEWER can be registered in the .First function residing in the .Rprofile initializing file.

Below we give two examples. On UNIX platform the user may use code like this one

.First <- function() {




On Windows platform the user may have the following two lines in its .First function

.First <- function() {


Sys.setenv(R_PDFVIEWER="\"C:/Program Files (x86)/Adobe/Reader 9.0/Reader/AcroRd32\"")

Sys.setenv(R_DOTVIEWER="\"C:/Program Files (x86)/Graphviz 2.26.3/bin/Dot\"")


Note that all paths in Windows should be embraced by comment marks, "\"".


N. Balov

[Package catnet version 1.15.7 Index]