Bayesian Networks: With Examples in R, Second Edition introduces Bayesian networks using a hands-on approach. Simple yet

*496*
*129*
*19MB*

*English*
*Pages 274
[252]*
*Year 2021*

- Author / Uploaded
- Marco Scutari
- Jean-Baptiste Denis

Bayesian Networks

CHAPMAN & HALL/CRC Texts in Statistical Science Series Joseph K. Blitzstein, Harvard University, USA Julian J. Faraway, University of Bath, UK Martin Tanner, Northwestern University, USA Jim Zidek, University of British Columbia, Canada Recently Published Titles Statistical Analysis of Financial Data With Examples in R James Gentle Statistical Rethinking A Bayesian Course with Examples in R and STAN, Second Edition Richard McElreath Statistical Machine Learning A Model-Based Approach Richard Golden Randomization, Bootstrap and Monte Carlo Methods in Biology Fourth Edition Bryan F. J. Manly, Jorje A. Navarro Alberto Principles of Uncertainty, Second Edition Joseph B. Kadane Beyond Multiple Linear Regression Applied Generalized Linear Models and Multilevel Models in R Paul Roback, Julie Legler Bayesian Thinking in Biostatistics Gary L. Rosner, Purushottam W. Laud, and Wesley O. Johnson Linear Models with Python Julian J. Faraway Modern Data Science with R, Second Edition Benjamin S. Baumer, Daniel T. Kaplan, and Nicholas J. Horton Probability and Statistical Inference From Basic Principles to Advanced Models Miltiadis Mavrakakis and Jeremy Penzer Bayesian Networks With Examples in R, Second Edition Marco Scutari and Jean-Baptiste Denis For more information about this series, please visit: https://www.crcpress.com/ Chapman--Hall/CRC-Texts-in-Statistical-Science/book-series/CHTEXSTASCI

Bayesian Networks With Examples in R Second Edition

Marco Scutari Jean-Baptiste Denis

Second edition published 2022 by CRC Press 6000 Broken Sound Parkway NW, Suite 300, Boca Raton, FL 33487-2742 and by CRC Press 2 Park Square, Milton Park, Abingdon, Oxon, OX14 4RN © 2022 Taylor & Francis Group, LLC First edition published by CRC Press Taylor & Francis Group, 2014 CRC Press is an imprint of Taylor & Francis Group, LLC The right of Marco Scutari and Jean-Baptiste Denis to be identified as authors of this work has been asserted by him/her/them in accordance with sections 77 and 78 of the Copyright, Designs and Patents Act 1988. Reasonable efforts have been made to publish reliable data and information, but the author and publisher cannot assume responsibility for the validity of all materials or the consequences of their use. The authors and publishers have attempted to trace the copyright holders of all material reproduced in this publication and apologize to copyright holders if permission to publish in this form has not been obtained. If any copyright material has not been acknowledged please write and let us know so we may rectify in any future reprint. Except as permitted under U.S. Copyright Law, no part of this book may be reprinted, reproduced, transmitted, or utilized in any form by any electronic, mechanical, or other means, now known or hereafter invented, including photocopying, microfilming, and recording, or in any information storage or retrieval system, without written permission from the publishers. For permission to photocopy or use material electronically from this work, access www.copyright. com or contact the Copyright Clearance Center, Inc. (CCC), 222 Rosewood Drive, Danvers, MA 01923, 978-750-8400. For works that are not available on CCC please contact [email protected] Trademark notice: Product or corporate names may be trademarks or registered trademarks and are used only for identification and explanation without intent to infringe. Library of Congress Cataloging-in-Publication Data ISBN: 978-0-367-36651-3 (hbk) ISBN: 978-0-429-34743-6 (ebk) ISBN: 978-1-032-03849-0 (pbk) DOI: 10.1201/9780429347436 Typeset in LMR10 font by KnowledgeWorks Global Ltd. Visit the companion website/eResources: https://www.bnlearn.com/book-crc-2ed/

To the UK, my home for the last decade

To my wife, Jeanie

Contents

Preface to the Second Edition

xi

Preface to the First Edition

xiii

1 The Discrete Case: Multinomial Bayesian Networks 1.1 1.2 1.3 1.4 1.5 1.6

1.7 1.8

1

Introductory Example: Train-Use Survey . . . . . . . . . . Graphical Representation . . . . . . . . . . . . . . . . . . . Probabilistic Representation . . . . . . . . . . . . . . . . . Estimating the Parameters: Conditional Probability Tables Learning the DAG Structure: Tests and Scores . . . . . . . 1.5.1 Conditional Independence Tests . . . . . . . . . . . . 1.5.2 Network Scores . . . . . . . . . . . . . . . . . . . . . Using Discrete Bayesian Networks . . . . . . . . . . . . . . 1.6.1 Using the DAG Structure . . . . . . . . . . . . . . . 1.6.2 Using the Conditional Probability Tables . . . . . . 1.6.2.1 Exact Inference . . . . . . . . . . . . . . . 1.6.2.2 Approximate Inference . . . . . . . . . . . Plotting Discrete Bayesian Networks . . . . . . . . . . . . . 1.7.1 Plotting DAGs . . . . . . . . . . . . . . . . . . . . . 1.7.2 Plotting Conditional Probability Distributions . . . Further Reading . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . .

2 The Continuous Case: Gaussian Bayesian Networks 2.1 2.2 2.3 2.4 2.5 2.6 2.7

Introductory Example: Crop Analysis . . . . . . . . Graphical Representation . . . . . . . . . . . . . . . Probabilistic Representation . . . . . . . . . . . . . Estimating the Parameters: Correlation Coefficients Learning the DAG Structure: Tests and Scores . . . 2.5.1 Conditional Independence Tests . . . . . . . . 2.5.2 Network Scores . . . . . . . . . . . . . . . . . Using Gaussian Bayesian Networks . . . . . . . . . 2.6.1 Exact Inference . . . . . . . . . . . . . . . . . 2.6.2 Approximate Inference . . . . . . . . . . . . . Plotting Gaussian Bayesian Networks . . . . . . . .

1 2 6 10 13 14 17 19 20 22 22 26 28 28 30 33 37

. . . . . . . . . . .

. . . . . . . . . . .

. . . . . . . . . . .

. . . . . . . . . . .

. . . . . . . . . . .

37 38 42 45 48 48 51 52 52 54 56 vii

viii

2.8 2.9

2.7.1 Plotting DAGs . . . . . . . . . . . . . . . . . . 2.7.2 Plotting Conditional Probability Distributions More Properties . . . . . . . . . . . . . . . . . . . . . Further Reading . . . . . . . . . . . . . . . . . . . . .

. . . .

. . . .

. . . .

. . . .

3 The Mixed Case: Conditional Gaussian Bayesian Networks 3.1 3.2 3.3 3.4 3.5 3.6

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 4.1 4.2 4.3 4.4 4.5 4.6 4.7

Introductory Example: Domotics . . . Graphical Representation . . . . . . . Probabilistic Representation . . . . . Learning a Dynamic Bayesian Network Using Dynamic Bayesian Networks . . Plotting Dynamic Bayesian Networks Further Reading . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . .

5.4 5.5

Introductory Example: A&E Waiting Times Graphical and Probabilistic Representation Building the Model in Stan . . . . . . . . . 5.3.1 Generating Data . . . . . . . . . . . 5.3.2 Exploring the Variables . . . . . . . Estimating the Parameters in Stan . . . . . Further Reading . . . . . . . . . . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

63 64 69 73 74 77

. . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

Conditional Independence and Graphical Separation Bayesian Networks . . . . . . . . . . . . . . . . . . . Markov Blankets . . . . . . . . . . . . . . . . . . . . Moral Graphs . . . . . . . . . . . . . . . . . . . . . Bayesian Network Learning . . . . . . . . . . . . . . 6.5.1 Structure Learning . . . . . . . . . . . . . . . 6.5.1.1 Constraint-Based Algorithms . . . . 6.5.1.2 Score-Based Algorithms . . . . . . . 6.5.1.3 Hybrid Algorithms . . . . . . . . . . 6.5.2 Parameter Learning . . . . . . . . . . . . . .

79 81 82 84 86 87 88 91

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

6 Theory and Algorithms for Bayesian Networks 6.1 6.2 6.3 6.4 6.5

63

79

5 More Complex Cases: General Bayesian Networks 5.1 5.2 5.3

56 58 61 62

91 93 96 97 98 99 102 105

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

105 107 111 114 117 121 122 127 130 133

ix 6.6

6.7 6.8 6.9

Bayesian Network Inference . . . . . . . . . . . . . 6.6.1 Probabilistic Reasoning and Evidence . . . 6.6.2 Algorithms for Belief Updating . . . . . . . 6.6.2.1 Exact Inference Algorithms . . . . 6.6.2.2 Approximate Inference Algorithms Causal Bayesian Networks . . . . . . . . . . . . . Evaluating a Bayesian Network . . . . . . . . . . . Further Reading . . . . . . . . . . . . . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

7 Software for Bayesian Networks 7.1

7.2 7.3

An Overview of R Packages . . . . . . . . . 7.1.1 The deal Package . . . . . . . . . . 7.1.2 The catnet Package . . . . . . . . . 7.1.3 The pcalg Package . . . . . . . . . 7.1.4 The abn Package . . . . . . . . . . . Stan and BUGS Software Packages . . . . 7.2.1 Stan: A Feature Overview . . . . . . 7.2.2 Inference Based on MCMC Sampling Other Software Packages . . . . . . . . . . 7.3.1 BayesiaLab . . . . . . . . . . . . . . 7.3.2 Hugin . . . . . . . . . . . . . . . . . 7.3.3 GeNIe . . . . . . . . . . . . . . . . .

155 . . . . . . . . . . . .

. . . . . . . . . . . .

. . . . . . . . . . . .

. . . . . . . . . . . .

. . . . . . . . . . . .

. . . . . . . . . . . .

. . . . . . . . . . . .

. . . . . . . . . . . .

. . . . . . . . . . . .

. . . . . . . . . . . .

8 Real-World Applications of Bayesian Networks 8.1

8.2

8.3

133 134 136 136 141 145 148 152

Learning Protein-Signalling Networks . . . . . . . . 8.1.1 A Gaussian Bayesian Network . . . . . . . . 8.1.2 Discretising Gene Expressions . . . . . . . . . 8.1.3 Model Averaging . . . . . . . . . . . . . . . . 8.1.4 Choosing the Significance Threshold . . . . . 8.1.5 Handling Interventional Data . . . . . . . . . 8.1.6 Querying the Network . . . . . . . . . . . . . Predicting the Body Composition . . . . . . . . . . 8.2.1 Aim of the Study . . . . . . . . . . . . . . . . 8.2.2 Designing the Predictive Approach . . . . . . 8.2.2.1 Assessing the Quality of a Predictor 8.2.2.2 The Saturated BN . . . . . . . . . . 8.2.2.3 Convenient BNs . . . . . . . . . . . 8.2.3 Looking for Candidate BNs . . . . . . . . . . Further Reading . . . . . . . . . . . . . . . . . . . .

155 157 159 161 162 164 165 166 167 167 168 168 171

. . . . . . . . . . . . . . .

. . . . . . . . . . . . . . .

. . . . . . . . . . . . . . .

. . . . . . . . . . . . . . .

. . . . . . . . . . . . . . .

171 173 174 177 181 183 187 190 191 192 192 193 194 196 203

x A Graph Theory

205

A.1 Graphs, Nodes and Arcs . . . . . . . . . . . . . . . . . . . . A.2 The Structure of a Graph . . . . . . . . . . . . . . . . . . . . A.3 Further Reading . . . . . . . . . . . . . . . . . . . . . . . . . B Probability Distributions B.1 General Features . . . . . . . . . . . . . B.2 Marginal and Conditional Distributions B.3 Discrete Distributions . . . . . . . . . . B.3.1 Binomial Distribution . . . . . . B.3.2 Multinomial Distribution . . . . B.3.3 Other Common Distributions . . B.3.3.1 Bernoulli Distribution . B.3.3.2 Poisson Distribution . . B.4 Continuous Distributions . . . . . . . . B.4.1 Normal Distribution . . . . . . . B.4.2 Multivariate Normal Distribution B.4.3 Other Common Distributions . . B.4.3.1 Chi-Square Distribution B.4.3.2 Student’s t Distribution B.4.3.3 Beta Distribution . . . B.4.3.4 Dirichlet Distribution . B.5 Conjugate Distributions . . . . . . . . . B.6 Further Reading . . . . . . . . . . . . .

205 206 208 209

. . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . .

C A Note about Bayesian Networks C.1 Bayesian Networks and Bayesian Statistics

209 210 212 212 213 213 213 213 214 214 214 215 215 216 216 217 217 218 219

. . . . . . . . . .

219

Glossary

221

Solutions

227

Bibliography

251

Index

257

Preface to the Second Edition We have been gratified by the popularity of the first edition of Bayesian Networks with Examples in R, which has been well beyond our expectations. Following the publication of the first edition, the book has been translated to French by Jean-Baptiste, and a Japanese translation by Kyoritsu Shuppan is in the works (possibly due in 2021). It has been cited more than 250 times according to Google Scholar, and many readers got in touch with us over the years while using it as a reference in their own work. This motivated us to produce a second edition containing several improvements: the result is a somewhat longer book and one we hope will answer more of the common questions that practitioners have when using Bayesian networks in their work. Firstly, we would like to thank the many readers who have reported assorted errors and typos. We gladly owned up to any mistakes we did in preparing the first edition of the book, and we have done our best not to introduce more in this new edition. We would also like to thank our editor, John Kimmel, for his support and encouragement. Secondly, we have included new material on topics chosen by popular demand: • conditional Gaussian Bayesian networks (Chapter 3); • dynamic Bayesian networks (Chapter 4); • a new chapter on general Bayesian networks (Chapter 5), now using Stan instead of JAGS; • better coverage of exact inference via junction trees, with a step-by-step example (Section 6.6.2.1); and • how to assess the quality of a Bayesian network (Section 6.8). The homepage for this new edition is: https://www.bnlearn.com/book-crc-2ed/

The R code used in the book can be downloaded from there: we extracted it from the book sources when compiling them with the knitr package. We also provide the list of the R packages we used and their reference version, as well as any errata that we will become aware of. Lugano, Switzerland Guyancourt, France January 2021

Marco Scutari Jean-Baptiste Denis

xi

Preface to the First Edition Applications of Bayesian networks have multiplied in recent years, spanning such different topics as systems biology, economics, social sciences and medical informatics. Different aspects and properties of this class of models are crucial in each field: the possibility of learning causal effects from observational data in social sciences, where collecting experimental data is often not possible; the intuitive graphical representation, which provides a qualitative understanding of pathways in biological sciences; the ability to construct complex hierarchical models for phenomena that involve many interrelated components, using the most appropriate probability distribution for each of them. However, all these capabilities are built on the solid foundations provided by a small set of core definitions and properties, on which we will focus for most of the book. Handling high-dimensional data and missing values, the fine details of causal reasoning, learning under sets of additional assumptions specific to a particular field, and other advanced topics are beyond the scope of this book. They are thoroughly explored in monographs such as Nagarajan et al. (2013), Pourret et al. (2008) and Pearl (2009). The choice of the R language is motivated, likewise, by its increasing popularity across different disciplines. Its main shortcoming is that R only provides a command-line interface, which comes with a fairly steep learning curve and is intimidating to practitioners of disciplines in which computer programming is not a core topic. However, once mastered, R provides a very versatile environment for both data analysis and the prototyping of new statistical methods. The availability of several contributed packages covering various aspects of Bayesian networks means that the reader can explore the contents of this book without reimplementing standard approaches from literature. Among these packages, we focus mainly on bnlearn (written by the first author, at version 3.5 at the time of this writing) to allow the reader to concentrate on studying Bayesian networks without having to first figure out the peculiarities of each package. A much better treatment of their capabilities is provided in Højsgaard et al. (2012) and in the respective documentation resources, such as vignettes and reference papers. Bayesian Networks: With Examples in R aims to introduce the reader to Bayesian networks using a hands-on approach, through simple yet meaningful examples explored with the R software for statistical computing. Indeed, being hands-on is a key point of this book, in that the material strives to detail each modelling step in a simple way and with supporting R code. We know very well that a number of good books are available on this topic, and we xiii

xiv

Bayesian Networks: With Examples in R

referenced them in the “Further Reading” sections at the end of each chapter. However, we feel that the way we chose to present the material is different and that it makes this book suitable for a first introductory overview of Bayesian networks. At the same time, it may also provide a practical way to use, thanks to R, such a versatile class of models. We hope that the book will also be useful to non-statisticians working in very different fields. Obviously, it is not possible to provide worked-out examples covering every field in which Bayesian networks are relevant. Instead, we prefer to give a clear understanding of the general approach and of the steps it involves. Therefore, we explore a limited number of examples in great depth, considering that experts will be able to reinterpret them in the respective fields. We start from the simplest notions, gradually increasing complexity in later chapters. We also distinguish the probabilistic models from their estimation with data sets: when the separation is not clear, confusion is apparent when performing inference. Bayesian Networks: With Examples in R is suitable for teaching in a semester or half-semester course, possibly integrating other books. More advanced theoretical material and the analysis of two real-world data sets are included in the second half of the book for further understanding of Bayesian networks. The book is targeted at the level of a M.Sc. or Ph.D. course, depending on the background of the student. In the case of disciplines such as mathematics, statistics and computer science the book is suitable for M.Sc. courses, while for life and social sciences the lack of a strong grounding in probability theory may make the book more suitable for a Ph.D. course. In the former, the reader may prefer to first review the second half of the book, to grasp the theoretical aspects of Bayesian networks before applying them; while in the latter he can get a hang of what Bayesian networks are about before investing time in studying their underpinnings. Introductory material on probability, statistics and graph theory is included in the appendixes. Furthermore, the solutions to the exercises are included in the book for the convenience of the reader. The real-world examples in the last chapter will motivate students by showing current applications in the literature. Introductory examples in earlier chapters are more varied in topic, to present simple applications in different contexts. The skills required to understand the material are mostly at the level of a B.Sc. graduate. Nevertheless, a few topics are based on more specialised concepts whose illustration is beyond the scope of this book. The basics of R programming are not covered in the book, either, because of the availability of accessible and thorough references such as Venables and Ripley (2002), Spector (2009) and Crawley (2013). Basic graph and probability theory are covered in the appendixes for easy reference. Pointers to literature are provided at the end of each chapter, and supporting material will be available online from www.bnlearn.com . The book is organised as follows. Discrete Bayesian networks are described first (Chapter 1), followed by Gaussian Bayesian networks (Chapter 2).

Preface to the First Edition

xv

Hybrid networks (which include arbitrary random variables, and typically mix continuous and discrete ones) are covered in Chapter 3. These chapters explain the whole process of Bayesian network modelling, from structure learning to parameter learning to inference. All steps are illustrated with R code. A concise but rigorous treatment of the fundamentals of Bayesian networks is given in Chapter 6, and includes a brief introduction to causal Bayesian networks. For completeness, we also provide an overview of the available software in Chapter 7, both in R and other software packages. Subsequently, two real-world examples are analysed in Chapter 8. The first replicates the study in the landmark causal protein-signalling network paper published in Science by Sachs et al. (2005). The second investigates possible graphical modelling approaches in predicting the contributions of fat, lean and bone to the composition of different body parts. Last but not least, we are immensely grateful to friends and colleagues who helped us in planning and writing this book, and its French version Résaux Bayésiens avec R: élaboration, manipulation et utilisation en modélisation appliquée. We are also grateful to John Kimmel of Taylor & Francis for his dedication in improving this book and organising draft reviews. We hope not to have unduly raised his stress levels, as we did our best to incorporate the reviewers’ feedback and we even submitted the final manuscript on time. Likewise, we thank the people at EDP Sciences for their interest in publishing a book on this topic: they originally asked the second author to write a book in French. He was not confident enough to write a book alone and looked for a coauthor, thus starting the collaboration with the first author and a wonderful exchange of ideas. The latter, not being very proficient in the French language, prepared the English draft from which this Chapman & Hall book originates. The French version is also planned to be in print by the end of this year. London, United Kingdom Jouy-en-Josas, France March 2014

Marco Scutari Jean-Baptiste Denis

1 The Discrete Case: Multinomial Bayesian Networks

In this chapter we will introduce the fundamental ideas behind Bayesian networks (BNs) and their interpretation using a hypothetical survey on the usage of different means of transport. We will focus on modelling discrete data, leaving continuous data to Chapter 2 and more complex data types to Chapters 3 and 5.

1.1

Introductory Example: Train-Use Survey

Consider a simple, hypothetical survey whose aim is to investigate the usage patterns of different means of transport, with a focus on cars and trains. Such surveys are used to assess customer satisfaction across different social groups, to evaluate public policies and to improve urban planning. Some real-world examples can be found, for instance, in Kenett et al. (2012). In our current example we will examine, for each individual, the following six discrete variables (labels used in computations and figures are reported in parenthesis): • Age (A ): the age, recorded as young (young ) for individuals below 30 years old, adult (adult ) for individuals between 30 and 60 years old, and old (old ) for people older than 60. • Sex (S ): the biological sex, recorded as male (M ) or female (F ). • Education (E ): the highest level of education or training successfully completed, recorded as up to high school (high ) or university degree (uni ). • Occupation (O ): whether the individual is an employee (emp ) or a selfemployed (self ) worker. • Residence (R ): the size of the city the individual lives in, recorded as either small (small ) or big (big ). • Travel (T ): the means of transport favoured by the individual, recorded either as car (car ), train (train ) or other (other ). 1

2

Bayesian Networks: With Examples in R

In the scope of this survey, each variable falls into one of three groups. Age and Sex are demographic indicators. In other words, they are intrinsic characteristics of the individual; they may result in different patterns of behaviour but are not influenced by the individual himself. On the other hand, the opposite is true for Education, Occupation and Residence. These variables are socioeconomic indicators and describe the individual’s position in society. Therefore, they provide a rough description of the individual’s expected lifestyle; for example, they may characterise his spending habits and his work schedule. The last variable, Travel, is the target of the survey, the quantity of interest whose behaviour is under investigation.

1.2

Graphical Representation

The nature of the variables recorded in the survey, and more in general of the three categories they belong to, suggests how they may be related with each other. Some of these relationships will be direct, while others will be mediated by one or more variables (indirect). Both kinds of relationships can be represented effectively and intuitively by means of a directed graph, which is one of the two fundamental entities characterising a BN. Each node in the graph corresponds to one of the variables in the survey. In fact, they are usually referred to interchangeably in the literature. Therefore, the graph produced from this example will contain six nodes, labelled after the variables (A , S , E , O , R and T ). Direct dependence relationships are represented as arcs between pairs of variables (e.g., A → E means that E depends on A ). The node at the tail of the arc is called the parent, while that at the head (where the arrow is) is called the child. Indirect dependence relationships are not explicitly represented. However, they can be read from the graph as sequences of arcs leading from one variable to the other through one or more mediating variables (e.g., the combination of A → E and E → R means that R depends on A through E ). Such sequences of arcs are said to form a path leading from one variable to the other; these two variables must be distinct. Paths of the form A → . . . → A , which are known as cycles, are not allowed in the graph. For this reason, the graphs used in BNs are called directed acyclic graphs (DAGs). Note, however, that some caution must be exercised in interpreting both direct and indirect dependencies. The presence of arrows or arcs seems to imply, at an intuitive level, that for each arc one variable should be interpreted as a cause and the other as an effect (e.g., A → E means that A causes E ). This interpretation, which is called causal, is difficult to justify in most situations: for this reason, in general we speak about dependence relationships instead of causal effects. The assumptions required for causal BN modelling will be discussed in Section 6.7.

The Discrete Case: Multinomial Bayesian Networks

3

To create and manipulate DAGs in the context of BNs, we will mainly use the bnlearn package (short for “Bayesian network learning”). library(bnlearn)

As a first step, we create a DAG with one node for each variable in the survey and no arcs. dag