Downloads
current release: 3.6 link ]
latest snapshot + bugfixes: 3.6 link ]

bnlearn is an R package for learning the graphical structure of Bayesian networks, estimate their parameters and perform some useful inference.

bnlearn implements the following constraint-based structure learning algorithms:

  • Grow-Shrink (GS);
  • Incremental Association Markov Blanket (IAMB);
  • Fast Incremental Association (Fast-IAMB);
  • Interleaved Incremental Association (Inter-IAMB);

the following score-based structure learning algorithms:

  • Hill Climbing (HC);
  • Tabu Search (Tabu);

the following hybrid structure learning algorithms:

  • Max-Min Hill Climbing (MMHC);
  • General 2-Phase Restricted Maximization (RSMAX2);

the following local discovery algorithms:

  • Chow-Liu;
  • ARACNE;
  • Max-Min Parents & Children (MMPC);
  • Semi-Interleaved Hiton-PC;

and the following Bayesian network classifiers:

  • naive Bayes;
  • Tree-Augmented naive Bayes (TAN).

Discrete (multinomial) and continuous (multivariate normal) data sets are supported, both for structure and parameter learning. The latter can be performed using either maximum likelihood or Bayesian estimators.
Each costraint-based algorithm can be used with several conditional independence tests:

  • categorical data (multinomial distribution):
    • mutual information (parametric, semiparametric and permutation tests);
    • shrinkage-estimator for the mutual information;
    • Pearson's X^2 (parametric, semiparametric and permutation tests);
  • ordinal data:
    • Jonckheere-Terpstra (parametric and permutation tests);
  • continuous data (multivariate normal distribution):
    • linear correlation (parametric, semiparametric and permutation tests);
    • Fisher's Z (parametric, semiparametric and permutation tests);
    • mutual information (parametric, semiparametric and permutation tests);
    • shrinkage-estimator for the mutual information;

and each score-based algorithm can be used with several score functions:

  • categorical data (multinomial distribution):
    • the multinomial log-likelihood;
    • the Akaike Information Criterion (AIC);
    • the Bayesian Information Criterion (BIC);
    • a score equivalent Dirichlet posterior density (BDe);
    • a modified Bayesian Dirichlet for mixtures of interventional and observational data;
    • the K2 score;
  • continuous data (multivariate normal distribution):
    • the multivariate Gaussian log-likelihood;
    • the corresponding Akaike Information Criterion (AIC);
    • the corresponding Bayesian Information Criterion (BIC);
    • a score equivalent Gaussian posterior density (BGe).

Package installation

It's available on CRAN and can be downloaded from its web page in the Packages section (here).
It can be installed with a simple:

install.packages("bnlearn")

The only suggested packages not hosted on CRAN are graph and Rgraphviz, which can be installed from BioConductor:

source("http://bioconductor.org/biocLite.R")
biocLite("Rgraphviz")

following the instructions present on its web page. Development snapshots, which may include bugfixes for the CRAN release as well as new features, can be downloaded from the links above.