2nd Edition

# Bayesian Networks With Examples in R

**Also available as eBook on:**

**Bayesian Networks: With Examples in R, Second Edition** introduces Bayesian networks using a hands-on approach. Simple yet meaningful examples illustrate each step of the modelling process and discuss side by side the underlying theory and its application using R code. The examples start from the simplest notions and gradually increase in complexity. In particular, this new edition contains significant new material on topics from modern machine-learning practice: dynamic networks, networks with heterogeneous variables, and model validation.

The first three chapters explain the whole process of Bayesian network modelling, from structure learning to parameter learning to inference. These chapters cover discrete, Gaussian, and conditional Gaussian Bayesian networks. The following two chapters delve into dynamic networks (to model temporal data) and into networks including arbitrary random variables (using Stan). The book then gives a concise but rigorous treatment of the fundamentals of Bayesian networks and offers an introduction to causal Bayesian networks. It also presents an overview of R packages and other software implementing Bayesian networks. The final chapter evaluates two real-world examples: a landmark causal protein-signalling network published in *Science* and a probabilistic graphical model for predicting the composition of different body parts.

Covering theoretical and practical aspects of Bayesian networks, this book provides you with an introductory overview of the field. It gives you a clear, practical understanding of the key points behind this modelling approach and, at the same time, it makes you familiar with the most relevant packages used to implement real-world analyses in R. The examples covered in the book span several application fields, data-driven models and expert systems, probabilistic and causal perspectives, thus giving you a starting point to work in a variety of scenarios.

Online supplementary materials include the data sets and the code used in the book, which will all be made available from https://www.bnlearn.com/book-crc-2ed/

**Preface to the Second Edition Preface to the First Edition**

**1. The Discrete Case: Multinomial Bayesian Networks ** Introductory Example: Train Use Survey

Graphical Representation

Probabilistic Representation

Estimating the Parameters: Conditional Probability Tables

Learning the DAG Structure: Tests and Scores

Conditional Independence Tests

Network Scores

Using Discrete Bayesian Networks

Using the DAG Structure

Using the Conditional Probability Tables

Exact Inference

Approximate Inference

Plotting Discrete Bayesian Networks

Plotting DAGs

Plotting Conditional Probability Distributions

Further Reading

** 2. The Continuous Case: Gaussian Bayesian Networks**

Introductory Example: Crop Analysis

Graphical Representation

Probabilistic Representation

Estimating the Parameters: Correlation Coefficients

Learning the DAG Structure: Tests and Scores

Conditional Independence Tests

Network Scores

Using Gaussian Bayesian Networks

Exact Inference

Approximate Inference

Plotting Gaussian Bayesian Networks

Plotting DAGs

Plotting Conditional Probability Distributions

More Properties

Further Reading

** 3. The Mixed Case: Conditional Gaussian Bayesian Networks**

Introductory Example: Healthcare Costs

Graphical and Probabilistic Representation

Estimating the Parameters: Mixtures of Regressions

Learning the DAG Structure: Tests and Scores

Using Conditional Gaussian Bayesian Networks

Further Reading

** 4. Time Series: Dynamic Bayesian Networks**

Introductory Example: Domotics

Graphical Representation

Probabilistic Representation

Learning a Dynamic Bayesian Network

Using Dynamic Bayesian Networks

Plotting Dynamic Bayesian Networks

Further Reading

** 5. More Complex Cases: General Bayesian Networks**

Introductory Example: A&E Waiting Times

Graphical and Probabilistic Representation

Building the Model in Stan

Generating Data

Exploring the Variables

Estimating the Parameters in Stan

Further Reading

** 6. Theory and Algorithms for Bayesian Networks ** Conditional Independence and Graphical Separation

Bayesian Networks

Markov Blankets

Moral Graphs

Bayesian Network Learning

Structure Learning

Constraint-based Algorithms

Score-based Algorithms

Hybrid Algorithms

Parameter Learning

Bayesian Network Inference

Probabilistic Reasoning and Evidence

Algorithms for Belief Updating

Exact Inference Algorithms

Approximate Inference Algorithms

Causal Bayesian Networks

Evaluating a Bayesian Network

Further Reading

** 7. Software for Bayesian Networks ** An Overview of R Packages

The deal Package

The catnet Package

The pcalg Package

The abn Package

Stan and BUGS Software Packages

Stan: a Feature Overview

Inference Based on MCMC Sampling

Other Software Packages

BayesiaLab

Hugin

GeNIe

** 8. Real-World Applications of Bayesian Networks**

Learning Protein-Signalling Networks

A Gaussian Bayesian Network

Discretising Gene Expressions

Model Averaging

Choosing the Significance Threshold

Handling Interventional Data

Querying the Network

Predicting the Body Composition

Aim of the Study

Designing the Predictive Approach

Assessing the Quality of a Predictor

The Saturated BN

Convenient BNs

Looking for Candidate BNs

Further Reading

A Graph Theory

A Graphs, Nodes and Arcs

A The Structure of a Graph

A Further Reading

B Probability Distributions

B General Features

B Marginal and Conditional Distributions

B Discrete Distributions

B Binomial Distribution

B Multinomial Distribution

B Other Common Distributions

B Bernoulli Distribution

B Poisson Distribution

B Continuous Distributions

B Normal Distribution

B Multivariate Normal Distribution

B Other Common Distributions

B Chi-square Distribution

B Student’s t Distribution

B Beta Distribution

B Dirichlet Distribution

B Conjugate Distributions

B Further Reading

C A Note about Bayesian Networks

C Bayesian Networks and Bayesian Statistics

### Biography

**Marco Scutari** is a Senior Lecturer at Istituto Dalle Molle di Studisull'Intelligenza Artificiale (IDSIA), Switzerland. He has held positions in Statistics, Statistical Genetics and Machine Learning in the UK and Switzerland since completing his Ph.D. in Statistics in 2011. His research focuses on the theory of Bayesian networks and their applications to biological and clinical data, as well as statistical computing and software engineering.

**Jean-Baptiste Denis** was formerly appointed as a statistician and modeller at the "Mathematics and Applied Informatics from Genome to Environment" unit of the French National Research Institute for Agriculture, Food and Environment. His main research interests were the modelling of two-way tables and Bayesian approaches, especially applied to genotype-by-environment interactions and microbiological food safety.

"The book has a practice-oriented, hands-on approach with R codes and outputs, clear examples, relevant exercises to elucidate the main concepts (with solutions included at the end). [...] Statisticians, data scientists and other researchers new to Bayesian networks might also find it valuable and interesting."

-Anikó Lovik inISCB News,June 2022Praise for the first edition:

"… an excellent introduction to Bayesian networks with detailed user-friendly examples and computer-aided illustrations. I enjoyed reading Bayesian Networks: With Examples in R and think that the book will serve very well as an introductory textbook for graduate students, non-statisticians, and practitioners in Bayesian networks and the related areas."

—Biometrics, September 2015"Several excellent books about learning and reasoning with Bayesian networks are available and Bayesian Networks: With Examples in R provides a useful addition to this list. The book is usually easy to read, rich in examples that are described in great detail, and also provides several exercises with solutions that can be valuable to students. The book also provides an introduction to topics that are not covered in detail in existing books … . It also provides a good list of search algorithms for learning Bayesian network structures. But the major strength of the book is the simplicity that makes it particularly suitable to students with sufficient background in probability and statistical theory, particularly Bayesian statistics."

—Journal of the American Statistical Association, June 2015