Dear all,
I just put together some example code that shows how to use R package
spOccupancy to fit community occupancy models to an example
data set contained in the AHMbook package; happy to share
here.
In it, we use a data set with 145 species observed in at least one of 266 1km2 quadrats in the Swiss breeding bird survey MHB in the year
2014. We then use spOccupancy function
msPGOcc() to fit two community occupancy models to this data
set. The first model is a Null model which for each species just contains an intercept for occupancy and detection, respectively, and where the sets of 145 occupancy and detection parameters are each assumed to be drawn from their own Normal distribution with
estimated hyperparameters. The latter represent the community in the model, and the values of the hyperparameters characterize the community in terms of its mean and its species-to-species variance. In the second model we add as species-specific random effects
the effects of elevation and forest cover into the occupancy part of the model, and of date and survey duration in the detection part of the model.
These are the very powerful community models discussed in the latter parts of Chapter 11 in the AHM1 book (without data augmentation).
spOccupancy now allows us to fit them within 20 minuters rather
than 10 hours, as needed when fitting them with JAGS. In addition, we get posterior samples for the z (= species by site presence/absence) matrix. Thus, you could stick the posterior samples of z into any community ecology software such as many functions in
package vegan and thereby obtain (1) measures of richness
and community composition that are corrected for imperfect detection and (2) a whole posterior distribution for each quantity that
vegan gives you.
Best regards --- Marc