sdnet
Fitting discrete Bayesian networks using marginal mixture distributions.
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 searching functions implemented in sdnet
output sets of networks with increasing complexity that fit the data
according to the MLE criterion.
These optimal networks is believed to explain and represent the relations between the node-variables. The final network selection is left to the user.
Before starting to use the package, we suggest the user to take a look at some of the main objects used in sdnet
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 sdnet
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.
There are two options: first one is to use igraph
package and second, and better one,
is to use Graphviz
library. 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.
If the user choose the first option, igraph
, the only thing he/she has to do is to install the library in R and set the environment variable R_SDNET_USE_IGRAPH
to TRUE.
A convenient place to do this is in the R .First
function
.First <- function() {
......................
Sys.setenv(R_SDNET_USE_IGRAPH=TRUE)
}
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() {
......................
Sys.setenv(R_DOTVIEWER="/usr/bin/dot")
}
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, "\"".