Packages for graphical modelling with R

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.

1  Packages

  • gRim is an R package for graphical interaction models.
  • gRim implements graphical log-linear models for discrete data, Gaussian graphical models for continuous data and Mixed interaction models for mixed data.
  • Vignettes are available here.
  • See also Højsgaard, Edwards Lauritzen (2012) Graphical Modelling with R. Springers UseR! series.
  • Slides about gRim from a tutorial at useR!2015 in Aalborg are available here.
  • gRbase provides efficient graph algorithms, functions for easy creation of graphs, functions for manipulation of highdimensional tables, data relevant to graphical models.
  • gRbase does not provide modelling facilities. These facilities are provided by other packages (who depends on gRbase).
  • The reference to gRbase is: Dethlefsen, C., Højsgaard, S. (2005) A Common Platform for Graphical Models in R: The gRbase Package. Journal of Statistical Software Vol. 14, No. 17.
  • Vignettes are available here.
  • gRc is an R package for Inference in Graphical Gaussian Models with Edge and Vertex Symmetries
  • The reference to gRc is: Højsgaard, Søren ; Lauritzen, Steffen L. (2007) Inference in Graphical Gaussian Models with Edge and Vertex Symmetries with the gRc Package for R. Journal of Statistical Software, Vol. 23, No. 6, 2007.
  • A related paper is: Højsgaard, Søren ; Lauritzen, Steffen L. Graphical Gaussian models with edge and vertex symmetries. Journal of the Royal Statistical Society; Series B: Statistical Methodology, Vol. 70, No. 5, 2008, p. 1005-1027.

2  Books

3  Tutorial at useR!2015 in Aalborg

The tutorial is organized together with Therese Graversen, University of Copenhagen.
Download material here.

4  Installation

  1. The packages listed above use the graph, RBGL and Rgraphviz packages. These packages are NOT on CRAN but on bioconductor. To install these packages, execute
    source(""); biocLite(c("graph","RBGL","Rgraphviz"))
  2. Then install the packages from CRAN in the usual way:
    install.packages("gRbase", dependencies=TRUE); install.packages("gRain", dependencies=TRUE); install.packages("gRim", dependencies=TRUE)

5  Development versions of the packages

Development versions of the packages may be available here. If you decide to use these versions, please install the CRAN versions first and the afterwards install the development versions.

6  Reporting unexpected behaviours (bugs)

When reporting unexpected behaviours, bugs etc. in the packages, PLEASE supply:
  1. A reproducible example in terms of a short code fragment.
  2. The data. The preferred way of sending the data "mydata" is to copy and paste the result from running dput(mydata).
  3. The result of running the sessionInfo() function.

7  FAQ (frequently asked questions)

Is it possible to specify likelihood evidence (also called virtual evidence) in gRain?
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.
I want to build a Bayesian network with 80.000 nodes. Can I do so with gRain?
Work has been done on supporting large networks. Please report sucesses and failures.
Does gRain have support for Bayesian networks for variables that are (multivariate) normal? Or for mixtures of discrete and normal variables?
No. Implementation for the multivariate normal distribution is straight forward (if you work with the canoncical rather than the moment parameters). Any contribution would be most welcome. For mixed variables, the only algorithm I know of is numerically unstable.
Does gRain have support for Bayesian networks for variables that are not discrete (and with a finite state space)?
Not in full generality. However, using the likelihood evidence facilities, one can work with some types of non-discrete variables.
Søren Højsgaard sorenh [at] math [dot] aau [dot] dk

File translated from TEX by TTH, version 4.06.
On 20 Aug 2015, 14:30.