This page describes some of the R packages for graphical modelling that I have been involved with. There are many more packages for grapical modelling, and the CRAN Task View gRaphical Models in R lists many of these.
The packages listed above use the graph, RBGL and Rgraphviz packages. These packages are on bioconductor. To enable that these are installed when installing the packates above run
and make sure that
BioC software is checked.
Then install the graphical modelling packages from CRAN with:
install.packages("gRbase", dependencies=TRUE); install.packages("gRain", dependencies=TRUE); install.packages("gRim", dependencies=TRUE)
Development versions of the packages reside on github. To use these versions, PLEASE install the CRAN versions FIRST (see section on installation) to get dependencies right and then AFTERWARDS install the development versions using:
Notice that for this to succeed you will need tools for building R packages from sources on your computer. For windows users this translates to that you will have to install Rtools which can be obtained from https://cran.r-project.org/bin/windows/Rtools/. Just follow the suggestions of the installer.
Notice that the packages are interdependent: For example, gRain depends on gRbase. Therefore, to use the development version of e.g. gRain you must (most likely) also install the development version of gRbase.
Q: Is it possible to specify likelihood evidence (also called virtual evidence) in gRain?
A: Yes, as of version 1.1-2 this has been implemented. The function to use is setEvidence(). A vignette on the topic has also been added.
Please report unexpected behaviour.
Q: I want to build a Bayesian network with 80.000 nodes. Can I do so with gRain?
A: Work has been done on supporting large networks. Please report sucesses and failures.
Q: Does gRain have support for Bayesian networks for variables that are (multivariate) normal? Or for mixtures of discrete and normal variables?
A: No. Implementation for the multivariate normal distribution is - at least in principle - straight forward although there can non-trivial numerical issues.
Q: Does gRain have support for Bayesian networks for variables that are not discrete (and with a finite state space)?
A: Not in full generality. However, using the likelihood evidence facilities, one can work with some types of non-discrete variables.
When reporting unexpected behaviours, bugs etc. PLEASE supply:
A small reproducible example in terms of a short code fragment.
The data. The preferred way of sending the data “mydata” is to copy and paste the result from running dput(mydata).
The result of running the sessionInfo() function.