BIRDIE ABU: Model fitting
v05-birdie-abu-model-fitting.Rmd
Introduction
The species abundance module (ABU) of the BIRDIE pipeline has four main steps: data preparation, model fitting, model diagnostics and model summary. See the BIRDIE: basics and BIRDIE: species abundance vignettes for general details about BIRDIE and about the ABU module, respectively. In this vignette, we will go through the different tasks that are performed during the first step of the ABU module: data preparation.
The main function used for model fitting is
ppl_fit_ssm_model()
. This is a ppl_
function,
and therefore it doesn’t do much processing itself (see BIRDIE:
basics if this is confusing), but it does call the right functions
to do the work. The output of ppl_fit_ssm_model()
is always
a model fit but it will change depending on the package we have selected
in the configPipeline()
function. At moment, there is only
one option, and it is to fit a state-space model using JAGS (with the
package jagsUI
).
In the following section, we explain the process of fitting a model
using jagsUI
.
Fitting a model using the jagsUI
package
At the moment there is only the option of fitting a state-space model
using the jagsUI
package and therefore it is the main
ppl_fit_ssm_model()
that takes care of this (i.e., there is
no package specific function for fitting the model - although we might
want to change this).
We use the jagsUI::jags.basic()
function, which outputs
raw mcmc
samples. These outputs use less memory than the
default jagsUI
processed outputs that compute some
additional elements, such posterior means and standard deviations.
We do compute those additional elements when we need them, using the
custom function processJAGSoutput()
, which is very similar
to the internal jagsUI:::processoutput()
. It has just been
slightly modified to remove some calculations that we don’t need and
make computations a bit lighter. This function and all other that are
design to work with JAGS are stored in the R/utils-jags.R
file.
Latest model specification
State-space models are used to describe and understand dynamic systems that may not be perfectly observed. Within this framework, we consider waterbird abundance to be a process that evolves over time, and which we observe during visits to CWAC sites. However, counts conducted by observers are distorted by imperfect detection that translates into counting errors. By counting repeatedly over time, and assuming that abundance evolves smoothly over time compared to observation error, we can disentangle these two processes.
We consider that the log of the observed counts () at sampling occasion (generally there were two sampling occasions per year, one in mid-summer and one in mid-winter), at any given site, arise from a normal distribution, such that
where is the latent (unobserved) log abundance of waterbirds present at a site on sampling occasion and is the corresponding variance of the observers counting error, also in the log scale. Therefore, counts depend both on the number of waterbirds present on site, and on errors in the counts of these birds.
To model changes in waterbird abundance between the two-seasons of year , we define to be the summer abundance and the winter abundance. Note that, although we currently consider only one count per season, there could potentially be multiple counts in a single year and season. However, the underlying true abundance is considered to stay constant in any given year and season (for clarity, note also that while sampling occasions were indexed by , years are indexed by ). Thus, the expected (log) abundance for any given count can be written as
where ‘summer’ is an indicator variable that takes on the value 1 in summer and 0 in winter, and ‘winter’ is the opposite. We then define abundance dynamics as:
where corresponds to the change in summer abundance from year to year , and is the difference between summer and winter abundance, both in the log scale. If exponentiated, these parameters can be interpreted as the rate of change in the population and the winter-to-summer ratio of the population, respectively.
We impose relatively smooth changes in abundance by defining autocorrelation in and terms over time. In addition, we define a mean reverting process whereby the populations at a certain site tend to revert to a site-specific mean or “preferred” abundance in summer and in winter. This specification is important to prevent estimated populations to explode in periods with missing data. These mean abundances may change occasionally, as we will see below.
We then define the expected change in summer population (the winter population evolves similarly) as We define certain persistence in population trends such that where and lies between zero and one, and controls how quickly the population reverts back to the mean.
Finally, we define a jump process, whereby population can present sudden changes in abundance that do not conform to the general temporal pattern. These changes are frequent in waterbird populations and, although possibly associated the conditions at the sites, it is challenging to understand the drivers behind them. We define
where and . We make be a small probability (with its prior) and large relative to to favour few, large jumps rather than frequent small ones.
These jumps in the population may stick for some time, meaning that they affect the mean abundance of the sites. Therefore, once a jump in a population is observed, the new level becomes the mean and we need a new jump to go back to the original mean. In this way we ensure that deviating from the mean and coming back to it are captured as two separate jumps and not necessarily as a jump and a mean reversion. Therefore,
In order to capture population jumps in the changes represented by we set
Note that this is for reporting purposes only, which is important because we don’t want jumps to be considered in the update step for (see expression above for _{t+1}).
The model for the winter population is similar to the summer one
represents the expected change in winter population on year , and the actual change is given by
where and lies between zero and one, and controls how quickly the population reverts back to the mean.
There can also be jumps in the winter populations given by
where and . We make be a small probability (with its prior) and large relative to .
These jumps may also stick to the population as
And they are incorporated into for reporting purposes, such that