simComm {AHMbook}  R Documentation 
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)
type 
choose whether you want to simulate detection/nondetection ("det/nondet") data or count data ("counts"). 
nsites 
number of sites 
nreps 
number of replicate samples (occasions or repeated measurements) 
nspecies 
total number of species in the area that is sampled by these sites (regional species pool) 
mean.psi 
community mean of occupancy probability over all species in community (probability scale); ignored if 
sig.lpsi 
community standard deviation of logit(occupancy probability intercept); ignored if 
mu.beta.lpsi 
community mean of the effects of 'habitat' covariate on occupancy probability; ignored if 
sig.beta.lpsi 
community standard deviation of the effects of 'habitat' covariate on occupancy probability; ignored if 
mean.lambda 
community mean of expected abundance over all species in superpopulation; ignored if 
sig.loglam 
community standard deviation of log(lambda intercept); ignored if 
mu.beta.loglam 
community mean of the effects of 'habitat' covariate on log(lambda); ignored if 
sig.beta.loglam 
community standard deviation of the effects of 'habitat' covariate on expected abundance; ignored if 
mean.p 
community mean of detection probability over all species in superpopulation (probability scale) 
sig.lp 
community standard deviation of logit(detection probability intercept) 
mu.beta.lp 
community mean of the effects of 'wind' covariate on detection probability 
sig.beta.lp 
community standard deviation of the effects of 'wind' covariate on detection probability 
show.plot 
choose whether to show plots or not. Set to FALSE when using function in simulations. 
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 loglinear 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 
Speciesspecific heterogeneity in intercepts and slopes is modelled 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) 
A list with the arguments supplied and the following additional elements:
(1) for type = "det/nondet"
(i.e., community occupancy)
psi 

p 

z 

z.obs 

y.all 

y.obs 

y.sum.all 
detection frequency for all species 
y.sum.obs 
detection frequency for observed species 
Ntotal.fs 
finite sample (or conditional) species richness 
Ntotal.obs 
observed species richness 
S.true 
true number of species occurring at each site 
S.obs 
observed number of species occurring at each site 
(2) for type = "counts"
(i.e., community count)
lambda 

p 

N 

y.all 

y.obs 

ymax.obs 

Ntotal.fs 
finite sample (or conditional) species richness 
Ntotal.obs 
observed species richness 
Marc Kéry & Andy Royle, with community occupancy model code partly based on code by Richard Chandler.
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, 389398.
Dorazio, R.M., et al (2006) Estimating species richness and accumulation by modeling species occurrence and detectability. Ecology 87, 842854.
Kéry, M. & Royle, J.A. (2008) Hierarchical Bayes estimation of species richness and occupancy in spatialy replicated surveys. J. Appl. Ecol. 45, 589598.
Yamaura, Y., et al. (2012) Biodiversity of manmade open habitats in an underused country: a class of multispecies abundance models for count data. Biodiversity and Conservation 21, 13651380.
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) # 13 are usually missed in sample data < simComm(nsites=30, nspecies = 200) # 46 usually missed data < simComm(nsites=10, nspecies = 200) # around 30 typically missed