1 Introduction

Abundance in animal communities is of great interest in ecology, particularly in the areas of conservation and wildlife management (Witmer 2005; Nichols and MacKenzie 2004). Count data is an attractive option for estimating abundance due to the relative affordability with which it may be collected and the reduced risk of harm to both animals and humans when compared to more direct data collection methods (Verdade et al. 2013). However, count data for animal abundance has a tendency to suffer from imperfect detection (i.e., the recorded information is usually imperfect in the sense that it does not represent the total abundance). Furthermore, when the detection probability is small, there is a tendency towards the underestimation of abundance. Due to the characteristics of these data, traditional modelling techniques, such as generalised linear models (McCullagh and Nelder 1989), cannot be applied directly to the data, as they do not accommodate imperfect detection.

N-mixture models (Royle 2004) constitute a class of models which may be used to estimate abundance from count data. These models assume that the population under analysis is closed, i.e., it is constant in terms of births, deaths, and migration. The counts at each site and time are considered independent and identically distributed (i.i.d) random variables that follow a Binomial distribution. In the original N-mixture model, the detection probability is estimated using the data, without the specification of any prior distribution with fixed parameters. The population size at each site is treated as a random effect, with an assumed probability distribution. The distributions that are typically considered for the population size at each site are the Poisson and Negative Binomial, although any other non-negative discrete distribution could also be considered.

The ability to estimate correlations between species abundances allows us to relax any assumption of independent species abundances. This is the aim of the multi-species N-mixture (MNM) models presented in this paper—a new class of models which estimate abundance for multiple species simultaneously while accounting for imperfect detection, and estimate inter-species correlations, which are intended to allow for inferences about the relationships between different species.

The remainder of the paper is organised as follows. In Sect. 3, we introduce our novel modelling framework to estimate abundance and inter-species correlations in animal communities based on spatio-temporal count data. We also describe the model formulation, estimation procedure, and the computation of the inter-species correlations. In Sect. 4, we present the data obtained from the North American Breeding Bird Survey (NABBS) (Pardieck et al. 2020), which will be used to illustrate our modelling approach. Later, in Sect. 5, we compare results of model fit on the NABBS data to obtain the best fit. Finally, in Sect. 6, we present a general discussion.

2 Related works

Several multi-species modelling frameworks have been developed previously which allow for the analysis of occurrence-data (Dorazio and Royle 2005; Yamaura et al. 2011) or count-data (Yamaura et al. 2012; Golding et al. 2017; Gomez et al. 2017) of multiple species.

Dorazio and Royle (2005) developed a model for estimating the size of a biological community by modelling the probability of detection as a Binomial random variable, and the probability of occurrence as a Bernoulli random variable. They allow rates of detection and occurrence to vary among species, and not every species is assumed to be present at every location. However, the aim of their model is to determine the number of species, not the number of individuals of each species, as is the aim of N-mixture models.

Yamaura et al. (2011) developed a multi-species model that estimates the animal abundance from occurrence-data. This is an extension of the single-species model developed by Royle and Nichols (2003), in which binary detection/non-detection data is linked to abundance. Yamaura et al. (2012) extended this model to count data. The assumption behind these models is that the abundances or detection probabilities of species in the community might be linked by species-level or functional group-level characteristics. However, inter-species abundance correlations are not explored within these models.

Gomez et al. (2017) developed a multi-species N-mixture model whose aim was to allow for the estimation of abundance of rare species by borrowing strength from other species in the community. This was done by assuming detection probabilities are drawn at random from a Beta distribution. Another multi-species N-mixture model was developed by Golding et al. (2017), which used the dependent double-observer method to create a multi-species dependent double-observer abundance model. This allowed them to address an issue of false-positive errors in detection. The focus of both Gomez et al. (2017) and Golding et al. (2017) was an improvement in detection probability. None of the preceding multi-species models allow us to make inferences as to the relationships within an ecological community, as we propose to do with our multi-species N-mixture model.

Moral et al. (2018) developed an extension to the single-species N-mixture model, which allowed for the estimation of abundances of two species, and the correlations between these abundances. However, this model only examines two species, and is therefore not as complete as the model we propose here, which allows us to examine whole communities.

Dorazio and Connor (2014) developed a multi-species N-mixture model which allowed for abundances of species with similar traits to be correlated. However, to guarantee positive definite correlations, they only allow for positive correlations through the use of a distance metric d coupled with a spatial autocorrelation structure of the type \(e^{-\frac{d}{\phi }}\). The framework we present here is more complete in that we guarantee positive definiteness of the correlation matrix via an elegant prior setup. We also explore ways of incorporating zero-inflation and open population dynamics, which is not something attempted by Dorazio and Connor (2014).

Finally, Niku et al. (2019) describe generalised linear latent variable models—a modelling technique which allows for obtaining correlation matrices in an elegant manner. However, these models do not allow for the incorporation of imperfect detection.

3 Methods

The models developed in the following Section are a multi-species extension to the original N-mixture model of Royle (2004), which allows for accurate estimation of both the latent abundances and inter-species correlations, while accounting for imperfect detection and relaxing the closure assumption.

3.1 Multi-species N-mixture model (MNM Model)

Consider a study which sees count data \(Y_{its}\) collected, where \(Y_{its}\) is the number of individuals observed for S different species (\(s=1,\ldots ,S\)) from R sites (\(i=1,\ldots ,R\)). Consider also that these samples are taken from each site on T occasions (\(t=1,\ldots ,T\)). The true abundance at site i for species s is given by \(N_{is}\). We observe \(N_{is}\) with detection probability \(p_{its}\), and it is assumed that species populations are closed with respect to births, deaths and migration (i.e., that the population sizes do not change due to any of these factors, akin to the N-mixture model proposed by Royle (2004)). Our model assumes that \(N_{is}\) follows a Poisson distribution, and may be written as:

$$\begin{aligned} Y_{its} \mid N_{is}, p_{its}&\sim \text {Binomial}(N_{is}, p_{its}),\\ N_{is} \mid \lambda _{is}&\sim \text {Poisson}(\lambda _{is}), \\ \text{ logit }(p_{its})&= {{\textbf {z}}}^{\top }_{it} {{\textbf {b}}}_{s}, \\ \text{ log }(\lambda _{is})&= a_{is} + {{\textbf {x}}}^{\top }_{i}\varvec{\beta }_{s}, \\ {\textbf{a}}_{i} \mid \varvec{\mu }_{a}, \varvec{\Sigma }_{a}&\sim \text{ MVN }(\varvec{\mu }_{a}, \varvec{\Sigma }_{a}), \end{aligned}$$

where \({{\textbf {a}}}_{i} = (a_{i1}, \ldots , a_{iS})^{\top }\). The Poisson rate parameter \(\lambda _{is}\) represents the mean abundance at site i, and \({\textbf{a}}_{i}\) is an S-dimensional vector that contains the random effects \(a_{is}\) that allow us to estimate inter-species correlations. In the above model, covariates may be incorporated in the detection probability and the abundance, with \({\textbf{z}}^\top _{it}\) the it-th row of the design matrix \({\textbf{Z}}\) of dimension \(RT \times q_p\), \(b_{s}\) the \(q_{p} \times 1\) parameter vector for the probability of detection, \({\textbf{x}}^\top _{i}\) the i-th row of the design matrix \({\textbf{X}}\) of dimension \(R \times q_{\lambda }\), and \(\varvec{\beta }\) the \(q_{\lambda } \times 1\) parameter vector for the abundance. Here, \(q_{p}\) and \(q_{\lambda }\) represent the number of covariates associated with the detection probability and the abundance, respectively. Note that different covariate effects may be estimated per species, and other species-level random effects may also be included.

3.2 Hurdle–Poisson model (MNM-Hurdle model)

In this Section, we develop a further extension of the multi-species N-mixture model, appropriate for scenarios in which the number of zero-counts exceeds those expected under a Poisson distribution. We now allow the counts to follow a Hurdle-Poisson distribution, with \(\lambda _{is}\) defined as in the MNM Model, and \(\theta \) the probability of obtaining a zero-count.

The Hurdle-Poisson distribution consists of two separate processes. The first is a Bernoulli process, which determines whether a site is occupied (count is non-zero) or unoccupied (count is zero). If the count is non-zero, a second random variable with a zero-truncated Poisson distribution determines the value of the count, i.e.,

$$\begin{aligned} \text {Occupancy}_{is}&\sim \text {Bernoulli}(1-\theta ), \\ \text {Count}_{is}&\sim \text {Zero Truncated Poisson}(\lambda _{is}). \end{aligned}$$

We then define the latent abundances \(N_{is}\) as

$$\begin{aligned} N_{is} = \left. {\left\{ \begin{array}{ll} 0 &{} \text {if } \text {Occupancy}_{is} = 0 \\ \text {Count}_{is} &{} \text {if } \text {Occupancy}_{is} = 1 \end{array}\right. } \right. , \end{aligned}$$

which yields

$$\begin{aligned} N_{is}\sim \text {Hurdle-Poisson}(\lambda _{is},\theta ). \end{aligned}$$

If the Bernoulli process is equal to 0, then the site is unoccupied and \(N_{is}\) is equal to 0. However, if the Bernoulli process is equal to 1, then the hurdle is crossed, and the value of \(N_{is}\) is determined by the zero-truncated Poisson process. Similar to the MNM model, populations are assumed to be closed.

We assume a single probability of obtaining a zero count \(\theta \). However, \(\theta \) may also be allowed to vary by site and/or species, and may depend on covariates through a logit link. All other parameters are distributed as described in the MNM model in Sect. 3.1.

3.3 Autoregressive model (MNM-AR model)

In order to model populations over multiple years, a further extension to the multi-species N-mixture model is proposed, which allows us to relax the assumption that species populations are closed with respect to births, deaths and migration. We do this through the inclusion of an autoregressive term in the abundance parameter.

The study design now consists of data collected over K years (\(k=1,\ldots ,K\)) for S species at R locations, each with T sampling occasions. The observed abundance (Y) and actual abundance (N) are now allowed to vary by year:

$$\begin{aligned} Y_{itks}&\sim \text {Binomial}(N_{iks}, p_{s}),\\ N_{iks}&\sim \text {Poisson}(\lambda _{iks}). \end{aligned}$$

If \(k=1\), then \(\lambda _{i1s}\) is defined as before:

$$\begin{aligned} \text {log}(\lambda _{i1s}) = a_{is} + {{\textbf {x}}}^{\top }_{i}\varvec{\beta }_{s}. \end{aligned}$$

However, for \(k>1\), we allow \(\lambda _{iks}\) to depend on the latent abundance at year \(k-1\):

$$\begin{aligned} \text {log}(\lambda _{iks}) = a_{is} + {{\textbf {x}}}^{\top }_{i}\varvec{\beta }_{s} + \phi _{s}\text {log}(N_{i(k-1)s}+1). \end{aligned}$$

The term \(\text {log}(N_{i(k-1)s}+1)\) is used here rather than the simpler \(N_{i(k-1)s}\) to avoid the rapid increase in sampled \(\lambda \) values when N values are large (Fokianos and Tjøstheim 2011).

3.4 Hurdle-autoregressive model (MNM-Hurdle-AR model)

A straightforward combination of the MNM-Hurdle model and the MNM-AR model produces the MNM-Hurdle-AR model. This model accommodates excess zeros while also accounting for an autoregressive structure in the data. The zero-inflation is introduced as in the MNM-Hurdle model, i.e.,

$$\begin{aligned} Y_{itks}&\sim \text {Binomial}(N_{iks}, p_{s}), \\ N_{iks}&\sim \text {Hurdle-Poisson}(\lambda _{iks}, \theta ), \end{aligned}$$

where

$$\begin{aligned} \text {log}(\lambda _{iks}) = \left. {\left\{ \begin{array}{ll} a_{is} + {{\textbf {x}}}^{\top }_{i}\varvec{\beta }_{s}, &{} \text {for } k = 1 \\ a_{is} + {{\textbf {x}}}^{\top }_{i}\varvec{\beta }_{s} + \phi _{s}\text {log}(N_{i(k-1)s}+1), &{} \text {for } k>1 \end{array}\right. } \right. . \end{aligned}$$

3.5 Model estimation

The models described in this paper are implemented using a Bayesian framework. Each of the above models were implemented in R (R Core Team 2020a) through the probabilistic programming software JAGS (Plummer et al., 2003; Plummer, 2017) using four chains with 50,000 iterations each, of which the first 10,000 were discarded as burn-in, and a thinning of five to reduce autocorrelation in the MCMC samples. Parameter convergence was determined using the potential scale reduction factor (\({\hat{R}}\)), a diagnostic criteria proposed by Gelman and Rubin (1992). An \({\hat{R}}\) value that is very close to one is an indication that the four chains have mixed well. If the \({\hat{R}}\) value was less than 1.05, the chains were considered to have mixed properly, and the posterior estimates of the parameters were considered reliable.

Prior distributions were assigned as follows: \(\varvec{\mu }_{a}\), the vector of means of the random effect \({\textbf{a}}\), was assigned a multivariate Normal prior with a diagonal variance-covariance matrix \(\varvec{\Sigma }_{0}\) and mean vector \(\varvec{\mu }_{0}\). \(\varvec{\Sigma }_{a}\), the variance-covariance matrix of \({\textbf{a}}\) was assigned an inverse-Wishart prior with a diagonal scale matrix \(\varvec{\Omega }\), and \(S+1\) degrees of freedom v which results in a Uniform(-1,1) prior on the correlations (Plummer 2017):

$$\begin{aligned} \varvec{\mu }_{a}&\sim \text {Normal}_{s}(\varvec{\mu }_{0},\varvec{\Sigma }_{0}), \\ \varvec{\Sigma }_{a}&\sim \text {Inverse-Wishart}(\varvec{\Omega }, v). \end{aligned}$$

An inverse-Wishart distribution is specified as the prior for the covariance matrix of the random effect \({{\textbf {a}}}\). Criticisms of the inverse-Wishart prior include the dependency imposed between correlations and variances, and the fact that there is a single degree of freedom parameter which determines the uncertainty for all variance parameters. It is demonstrated by Alvarez et al. (2014) that when the variance is small relative to the mean, the correlation is biased towards zero, and the variance is biased towards larger values, though when working with count data, typically variances are large relative to the mean. Despite these issues, the inverse-Wishart distribution is a prior distribution commonly assigned to a covariance matrix in Bayesian analysis due to its conjugacy with the Normal distribution, and for these models the inverse-Wishart distribution provides a good solution due to its guarantee of providing a positive definite covariance matrix.

In the Hurdle and Hurdle-AR models, \(\theta \) is assigned a Beta prior with the value of both shape parameters equal to one, which is equivalent to a vague uniform prior:

$$\begin{aligned} \theta \sim \text {Beta}(1, 1). \end{aligned}$$

In the AR and Hurdle-AR models, \(\phi \) is assigned a Multivariate Normal prior, with hyperpriors \(\varvec{\mu _{\phi }}\) and diagonal matrix \(\varvec{\Sigma _{\phi }}\):

$$\begin{aligned} \varvec{\phi _{s}}&\sim \text {MVN}(\varvec{\mu _{\phi }}, \varvec{\Sigma _{\phi }}), \end{aligned}$$

Extensive simulation studies were carried out to examine the accuracy of parameter estimates; see Appendix B for more details.

3.6 Inter-species correlations

The presence of the multivariate normal random effect \({{\textbf {a}}}\) in the abundance provides a link between species’ abundances. The correlation matrix for the random effect, \(\varvec{\Sigma }_{a}\), may be estimated directly from the Bayesian model. In this sense, the inter-species correlations for the latent abundances \(N_{s}\) and \(N_{s'}\), for all \(s \ne s'\), are calculated for each model as:

$$\begin{aligned} \rho (N_{s}, N_{s'})= \frac{\text {Cov}(N_{s}, N_{s'})}{\sqrt{(\text {Var}(N_{s}))(\text {Var}(N_{s'}))}}. \end{aligned}$$

The derivation of \(\text {Cov}(N_{s}, N_{s'})\) can be found in Appendix A.

The inter-species correlations for the MNM model and Hurdle model are assumed not to vary by year, so these models have a single analytic correlation matrix. However, in the AR and Hurdle-AR model, we assume latent abundances change by year, which requires the computation of K analytic correlation matrices. Note that the MNM and AR models required the use of properties of conditional variance and covariance to determine analytic correlations. In the Hurdle and Hurdle-AR models, the properties of conditional variance and covariance were merged with second-order Taylor approximations to make their computation feasible.

4 Case study: North American Breeding Bird Survey

In this section, we describe the application of the multi-species N-mixture models to a real world case study, to examine bird populations using data collected as part of the North American Breeding Bird Survey (NABBS).

The North American Breeding Bird Survey (Pardieck et al. 2020) was first conducted in 1966, and now provides data annually on more than 400 bird species across 3700 routes in the United States and Canada. Each of these routes is approximately 24.5 miles long and is composed of 50 stops, approximately 0.5 miles apart. At each stop, every bird seen or heard within a 0.25-mile radius is recorded. For the sake of our models, each of these routes is considered a site, and each of the 50 stops along a route is a sampling occasion.

We examine data collected in Alaska in the 10-year period 2010–2019. There are 94 routes in Alaska (Fig. 1) at which data was collected during this time, and each of these routes are composed of 50 sampling locations, totalling 4700 observations per bird species.

Fig. 1
figure 1

Location of sites in Alaska marked in red, with the Alexander Archipelago—the location of the Alaskan Bald Eagle population—outlined in black

Bald Eagle populations in Alaska are estimated at between 8000 and 30,000 birds, accounting for roughly half of the global population (Hodges 2011; Hansen 1987; King et al. 1972). For this reason, Bald Eagles were chosen as a species of interest. Several other species were chosen; these included waterbirds such as geese, swans and snipes which were chosen for their relationships with Bald Eagles, as Bald Eagles are known to prey on waterbirds such as ducks, geese and grebes when fish are in short supply (Dunstan and Harper 1975; Todd et al. 1982; McEwan and Hirth 1980). Additionally, a selection of species with inland habitats, such as thrushes and swallows, were examined. In total, 10 species were selected for analysis, of the 233 total species present in Alaska within the 10-year period. The full list of species selected and the frequency with which they were observed is given in Table 1.

The models described in Sect. 3 were fitted to the NABBS data. Each was fitted three times, varying the dimension of the detection probability. Initially, detection probability was allowed to vary by site, species and year. Subsequently, models were fitted in which detection probability varies only by site and species, and then by species alone.

Table 1 Number of routes each species appears at by year, out of a total 94 routes

Initially, the models were fitted without covariates, and results were compared using their Bayesian Information Criterion (BIC) (Delattre et al. 2014) values. Subsequently, latitude, longitude and their interaction term latitude \(\times \) longitude were included in the linear predictors for the abundance parameters, and models were again compared using BIC values. All covariates were scaled to have zero-mean and unit variance.

Initial examination of this data revealed that \(93.2\%\) of observations (438,040 of a total of 470,000 observations) consisted of zero counts. This suggested that a model with a hurdle component might provide an appropriate framework for this data. Furthermore, this data was collected over the course of a decade. For this reason, we might expect that an autoregressive term may be useful to incorporate the time dependence.

Each model was fitted using four chains with 50,000 iterations each, of which the first 10,000 were discarded as burn-in, using a thinning value of five. All prior distributions were assigned as described in Sect. 3.5.

5 Results

Initially, the models were fitted without covariates and were compared using BIC values. The result of this comparison was that the Hurdle-AR model, in which detection probability varies by species (Hurdle-AR(C)), provided the best fit for the NABBS data. However, the addition of a response surface for latitude and longitude in the linear predictors for the abundance parameters results in the Hurdle model in which detection probability varies by species (Hurdle(C)) producing the lowest BIC value. This suggests that, within the range of models produced, this model provides the best fit for our data. The variance which was initially explained by the addition of the autoregressive term is now explained by the latitude and longitude covariates, which render the autoregressive component unnecessary. The result of this comparison is given in Table 2.

Table 2 Number of estimated parameters and BIC values comparing model fits on NABBS data

The latent inter-species correlations are given in Fig. 2, while the derivation of analytic correlations, which vary by site and year, are given in Appendix A. The latent correlations are obtained after the probability of detection and other covariates are taken into account. They may be interpreted as an interaction strength metric, which allows for the study of the influence of one species’ abundance on the others (Berlow et al. 2004; Moral et al. 2018).

Fig. 2
figure 2

Estimated latent inter-species correlation matrix, produced by the Hurdle(C) model fitted to the NABBS data, including covariates in the linear predictor for the abundance parameter

6 Discussion

We have proposed a multi-species extension to the N-mixture model, which allows for the estimation of inter-species abundance correlations through the addition of a random variable in the abundance. Results of simulation studies (see Appendix B) reveal that this model performs well under a range of scenarios, with abundances and detection probabilities that range from low to high. For this reason, we believe that this approach represents an attractive framework for examining multi-species abundances.

Issues with parameter convergence were encountered when fitting the Hurdle and Hurdle-AR models. When zero-inflation and abundance are large, and detection probability is small, issues with convergence occurred in up to 20\(\%\) of parameters. While this convergence issue does not appear to negatively affect the relative biases of parameter estimates (as can be seen in Appendix B, Tables 3 and 4), coverage probability for detection probability p and random effect mean \(\mu _{a}\) is negatively impacted (Appendix D). In the same models, we see larger coverage for N. This is to be expected, and is due to zero counts being perfectly predicted.

Previous works have demonstrated that N-mixture models can sometimes suffer from issues with identifiability (Dennis et al. 2015) wherein probability of detection estimates are very close to zero and abundance estimates are infinite. To address this issue, we have performed extensive simulation studies, detailed in Appendix B, in which we assess the estimates of abundance and detection probability for a large range of sample sizes, detection probabilities, abundance sizes, and in the case of the Hurdle and Hurdle-AR models, zero-count probabilities. The result was a simulation study which demonstrated no evidence that this modelling framework suffers from these identifiability issues.

The models presented here all use the Poisson distribution to model the latent abundances. However, any other count distribution might instead be used, for example, the Negative Binomial. Our calculations for the analytic correlations, however, reflect only the use of the Poisson distribution.

Case study results reveal that the difference in BIC values between the model with the lowest BIC value (Hurdle(C) with covariates) and the model with the second-lowest BIC value (Hurdle-AR(C) without covariates) is 223. This sizeable difference in BIC values suggests that the Hurdle(C) model with covariates provides a better fit than the Hurdle-AR(C) model without covariates.

Case study detection probability values range from 0.047 (Tree Swallow) to 0.564 (Swainson’s Thrush). Estimates of the maximum latent abundance N per species are provided in Appendix C, which reveals that while N-mixture models occasionally suffer from identifiability issues as described above, this does not appear to be an issue for this case study.

The estimates for Bald Eagle abundance produced by this model are plotted by site and year in Fig. 3. Of the 94 possible sites in Alaska, the Bald Eagle population is concentrated at 18 sites at the southeastern coast, along a 300-mile stretch of islands called the Alexander Archipelago. Examination of this figure suggested a possible increase in Bald Eagle abundance in this area between 2010 and 2019. The mean abundance was calculated per year (Fig. 4), and a one-sided Mann-Kendall test (Mann 1945; Kendall 1948) for an increasing trend in time series data was performed. The result of this was a Kendall’s \(\tau \) value of 0.6 and a p-value of 0.0082, indicating that it was appropriate to reject the null hypothesis that no increasing trend exists. We can therefore conclude that Bald Eagle abundances increased in the area of the Alexander Archipelago in the decade between 2010 and 2019.

Fig. 3
figure 3

Estimated Bald Eagle abundances at sites in the Alexander Archipelago, produced by the Hurdle(C) model fitted to the NABBS data

Fig. 4
figure 4

Annual mean abundance for Bald Eagles in the Alexander Archipelago, estimated by the Hurdle(C) model fitted to the NABBS data. The light-blue ribbon represents the 95% credible interval for the mean

In the models that contain an autoregressive component, we obtain separate \(\text {Corr}(N_{s}, N_{s'})\) per year. As a feature of model formulation, the correlation between two species does not change sign from year to year. We can accommodate a change in sign by allowing for an unstructured covariance matrix of the autocorrelation coefficient \(\varvec{\Sigma _{\phi }}\), and this particular extension is subject of ongoing work. Furthermore, the models presented in this paper assume that sites are independent of one another. A further extension we are currently working on is the incorporation of spatial dependence.