## Introduction

Species extinctions have reached an unprecedented rate (Barnosky *et al*. 2011), making biodiversity loss one of the most severe threats to ecosystems around the world (Reich *et al*. 2012). Often, extinctions stem from anthropogenic habitat loss, over-harvesting and climate change (Pereira *et al*. 2010), and are likely to have profound effects on important ecological services (Worm *et al*. 2006). To forecast extinction risk, we would like to estimate the probability of each and every species becoming extinct in an ecological network. Certain key species traits are likely to influence extinction vulnerability: for example, large body size, high trophic level and low density all increase the probability of extinction (Gaston & Blackburn 1995; Purvis *et al*. 2000; Cardillo *et al*. 2005; Davidson *et al*. 2009 Lee & Jetz 2011). However, species are not isolated, but rather depend on each other for sustenance, forming a complex network of ecological interactions. Therefore, the extinction of a single species could affect other species with which it interacts, directly or indirectly (Ebenman & Jonsson 2005), potentially setting in motion a cascade of secondary extinctions through the community. These secondary extinctions can emerge from either bottom-up effects (consumers losing their resources) or top-down effects (resources responding to the loss of their consumers).

Traditionally, there have been two main approaches to the analysis of secondary extinctions in ecological networks – often called network robustness. The first line of research, originating from studies of other complex networks (Albert, Jeong & Barabási 2000), focuses exclusively on the presence or absence of consumer–resource relationships. Thus, only the qualitative network structure is taken into account. Typically, one removes species, either randomly or systematically, and tests how network robustness varies with network properties such as number of species or connectance (Sole & Montoya, 2001; Dunne, Williams & Martinez 2002; Memmott, Waser & Price 2004; Srinivasan *et al*. 2007). This so-called topological approach has the advantage of requiring only the network structure as an input: for an adjacency matrix *A*, whose rows and columns represent the species, a coefficient signifies that *i* is a prey of *j*. Although this simplicity makes it possible to analyse very large networks, the approach has several limitations. For example, in the topological case, secondary extinctions only occur when a consumer loses all of its resources: the extinction risk does not grow until all resources are lost, at which point the extinction risk equals one. Also, in the topological approach, all species are usually assumed to have the same baseline probability of extinction, whereas in natural systems some species are more vulnerable than others.

An alternative line of research attempts to explicitly model population dynamics, that is, changes in abundances or biomasses over time, for all species in the network (Ebenman, Law & Borrvall 2004; Eklöf & Ebenman 2006; Riede *et al*. 2011; Stouffer & Bascompte 2011). Using dynamical models one can capture, in addition to the purely topological extinctions, other types of extinctions. For example, through the propagation of indirect effects in the network, the primary extinction of a top predator might lead to the secondary extinction of some of its resources [top-down extinctions, for example, Ebenman & Jonsson (2005)]. Additionally, dynamic models often include an extinction threshold, a population density below which the species are considered extinct, in order to account for processes such as demographic stochasticity (Eklöf & Ebenman 2006). As such, a resource present at low values could still be insufficient to support its consumers. However, dynamical models require an extensive set of parameters, making an empirical parameterization of large food webs next to impossible. Typically, this approach has been used mostly to study synthetic webs generated using physiological scaling of species interaction strengths (Binzer *et al*. 2011). Moreover, because dynamical ecological systems are highly nonlinear, slightly different initial conditions can lead to very different outcomes. This makes it necessary to simulate numerous replicates for each parameterization. Finally, even if one were to measure all parameters correctly, this approach is difficult to extend to the study of very large networks due to limited computing power.

A middle-ground approach is to consider the probability that species will be present or absent in a complex system. Such a framework requires relatively few parameters and assumptions, yet it can account for a wide range of extinction types. One recent example of this type of model is the stochastic ecological network occupancy (SENO) model, which takes the topological network structure as well as colonization and extinction rates as input parameters, addressing the changes in species probabilities over space and time (Lafferty & Dunne 2010). Extensive simulations will converge on the actual probability of extinction for each species, but exact solutions (in the absence of top-down effects) can alternatively be found using Bayesian networks (Lafferty & Dunne 2010).

Here, we explore the use of Bayesian networks (Jensen, 1996) to directly calculate the marginal probability of species extinction in a network without requiring simulation. We add considerable flexibility in the assumptions about how consumers respond to the loss of resources.

A Bayesian network is simply a collection of random variables (here species are represented as Bernoulli random variables determining their presence/absence) with arrows describing their conditional dependencies (feeding relationships). As such, the probability of extinction of each species depends on the state of its resources, which in turn depends on the state of their resources. The use of Bayesian networks has several advantages over the more traditional ways of modelling species extinctions. First, in Bayesian networks, one can directly assign to each species a different baseline probability of extinction. This baseline probability is then combined with the network structure to estimate extinction risk. This is useful for conservation, where lists of endangered species (‘Red Lists’) are often available. The main benefit from a modelling standpoint is that we need few parameters and thus few assumptions about the biological interactions.

Bayesian networks can be solved numerically very efficiently – multiple simulation reiterations are not needed, and therefore, computation time is greatly reduced. There is no need for artificial ‘sequences’ of extinctions, since all possible cases are considered simultaneously. Finally, as we show here, many simulation-based approaches are in fact simulating a Bayesian network that can be solved more efficiently. These benefits stress the importance of connecting ecology with the vast literature on graphical models.

Using Bayesian networks, we introduce a flexible method in which all the possible responses of consumers to resource loss can be modelled. To test our Bayesian network method, we parameterize a model based on differential equations that is frequently used to simulate complex food web dynamics (Berlow *et al*. 2009; Binzer *et al*. 2011). We first perform in silico (simulated) extinctions for the full-fledged dynamical model. We then use our method and attempt to predict the observed extinctions. We evaluate the goodness-of-fit for alternative responses of consumers to resource extinction using likelihoods. We find that a sigmoid response, in which consumers’ extinction risk grows sharply after a critical fraction of resources is lost, best accounts for the observed extinctions. Moreover, adding information on resource importance further improves the forecasting ability of our Bayesian network method.