Simulate detection/nondetection or count data, respectively, under a community occupancy or abundance model with random species effects for psi or lambda and p (both including effects of one covariate, 'habitat' for psi or lambda and 'wind speed' for p) (introduced in AHM1 - 11.2)
simComm(type = c("det/nondet", "counts"), nsites = 30, nreps = 3, nspecies = 100,
mean.psi = 0.25, sig.lpsi = 1, mu.beta.lpsi = 0, sig.beta.lpsi = 0,
mean.lambda = 2, sig.loglam = 1, mu.beta.loglam = 1, sig.beta.loglam = 1,
mean.p = 0.25, sig.lp = 1, mu.beta.lp = 0, sig.beta.lp = 0, show.plot = TRUE)
A list with the arguments supplied and the following additional elements:
(1) for type = "det/nondet"
(i.e., community occupancy)
length nsites
vector with the habitat covariate
nsites * nreps
matrix with the wind covariate
psi[i, k]
occupancy probability for site i and species k
p[i, j, k]
detection probability for site i, occasion j and species k
z[i, k]
true presence/absence for site i and species k
z.obs[i, k]
observed presence/absence for site i and species k
y.all[i, j, k]
detection/nondetection data for site i, occasion j and species k for all species
y.obs[i, j, k]
detection/nondetection data for site i, occasion j and species k for observed species
detection frequency for all species
detection frequency for observed species
finite sample (or conditional) species richness
observed species richness
true number of species occurring at each site
observed number of species occurring at each site
(2) for type = "counts"
(i.e., community count)
length nsites
vector with the habitat covariate
nsites * nreps
matrix with the wind covariate
lambda[i, k]
expected number of individuals for site i and species k
p[i, j, k]
detection probability for site i, occasion j and species k
N[i, k]
true number present for site i and species k
y.all[i, j, k]
number observed for site i, occasion j and species k for all species
y.obs[i, j, k]
number observed for site i, occasion j and species k for observed species
ymax.obs[i, k]
maximum number observed for site i and species k
finite sample (or conditional) species richness
observed species richness
choose whether you want to simulate detection/nondetection ("det/nondet") data or count data ("counts").
number of sites
number of replicate samples (occasions or repeated measurements)
total number of species in the area that is sampled by these sites (regional species pool)
community mean of occupancy probability over all species in community (probability scale); ignored if type = "counts"
.
community standard deviation of logit(occupancy probability intercept); ignored if type = "counts"
.
community mean of the effects of 'habitat' covariate on occupancy probability; ignored if type = "counts"
.
community standard deviation of the effects of 'habitat' covariate on occupancy probability; ignored if type = "counts"
.
community mean of expected abundance over all species in superpopulation; ignored if type = "det/nondet"
.
community standard deviation of log(lambda intercept); ignored if type = "det/nondet"
.
community mean of the effects of 'habitat' covariate on log(lambda); ignored if type = "det/nondet"
.
community standard deviation of the effects of 'habitat' covariate on expected abundance; ignored if type = "det/nondet"
.
community mean of detection probability over all species in superpopulation (probability scale)
community standard deviation of logit(detection probability intercept)
community mean of the effects of 'wind' covariate on detection probability
community standard deviation of the effects of 'wind' covariate on detection probability
choose whether to show plots or not. Set to FALSE when using function in simulations.
Marc Kéry & Andy Royle, with community occupancy model code partly based on code by Richard Chandler.
Function simulates data from repeated sampling of a metacommunity (or spatially structured community) according to the model of Dorazio & Royle (JASA, 2005) for type = "det/nondet"
(this is the default) or under the model of Yamaura et al. (2012) for type = "counts"
.
Occupancy probability (psi) or expected abundance (lambda) can be made dependent on a continuous site covariate 'habitat', while detection probability can be made dependent an observational covariate 'wind'. Both intercept and slope of the two log-linear or logistic regressions (for occupancy or expected abundance, respectively, and for detection) are simulated as draws from a normal distribution with mean and standard deviation that can be selected using function arguments.
Specifically, the data are simulated under the following linear models:
(1) for type = "det/nondet"
(i.e., community occupancy)
(occupancy (psi) and detection (p) for site i, replicate j and species k) | |
psi[i,k] <- plogis(beta0[k] + beta1[k] * habitat[i] | Occupancy |
p[i,j,k] <- plogis(alpha0[k] + alpha1[k] * wind[i,j] | Detection |
(2) for type = "counts"
(i.e., community count)
(exp. abundance (lambda) and detection (p) for site i, rep. j and species k) | |
lambda[i,k] <- exp(beta0[k] + beta1[k] * habitat[i] | E(N) |
p[i,j,k] <- plogis(alpha0[k] + alpha1[k] * wind[i,j] | Detection |
Species-specific heterogeneity in intercepts and slopes is modeled by up to four independent normal distributions (note: no correlation between the intercepts as in Dorazio et al. (2006) or Kéry & Royle (2008))
(1) for type = "det/nondet"
(i.e., community occupancy)
beta0 ~ dnorm(logit(mean.psi), sig.lpsi) | Mean and SD of normal distribution |
beta1 ~ dnorm(mu.beta.lpsi, sig.beta.lpsi) | |
alpha0 ~ dnorm(logit(mean.p), sig.lp) | |
alpha1 ~ dnorm(mu.beta.lp, sig.beta.lp) |
(2) for type = "counts"
(i.e., community count)
beta0 ~ dnorm(log(mean.lambda), sig.loglam) | Mean and SD of normal distribution |
beta1 ~ dnorm(mu.beta.loglam, sig.beta.loglam) | |
alpha0 ~ dnorm(logit(mean.p), sig.lp) | |
alpha1 ~ dnorm(mu.beta.lp, sig.beta.lp) |
Dorazio, R.M. & Royle, J.A. (2005) Estimating size and composition of biological communities by modeling the occurrence of species. J American Statistical Association, 100, 389-398.
Dorazio, R.M., et al (2006) Estimating species richness and accumulation by modeling species occurrence and detectability. Ecology 87, 842-854.
Kéry, M. & Royle, J.A. (2008) Hierarchical Bayes estimation of species richness and occupancy in spatially replicated surveys. Journal of Applied Ecology 45, 589-598.
Yamaura, Y., et al. (2012) Biodiversity of man-made open habitats in an underused country: a class of multispecies abundance models for count data. Biodiversity and Conservation 21, 1365-1380.
Kéry, M. & Royle, J.A. (2016) Applied Hierarchical Modeling in Ecology AHM1 - 11.2.
# Default arguments:
str(simComm())
# Some possibly interesting settings of the function
data <- simComm(nsites = 267, nspecies = 190, mean.psi = 0.25, sig.lpsi = 2,
mean.p = 0.12, sig.lp = 2) # similar to Swiss MHB
data <- simComm(mean.psi = 1) # all species occur at every site
data <- simComm(mean.p = 1) # no measurement error (perfect detection)
# Effect of spatial sample size (nsites) on species richness in sample (Ntotal.fs)
data <- simComm(nsites=50, nspecies = 200) # 1-3 are usually missed in sample
data <- simComm(nsites=30, nspecies = 200) # 4-6 usually missed
data <- simComm(nsites=10, nspecies = 200) # around 30 typically missed
Run the code above in your browser using DataLab