simcom: Function to simulate community occupancy data

Description Usage Arguments Details Value Examples

Description

Function to simulate community occupancy data with random species effects for psi and p (both including effects of one covariate, 'gradient' for psi and 'date' for p)

Usage

1
2
3
4
simcom(nsite = 50, nrep = 3, nspec = 100, mean.psi = 0.5,
  sig.lpsi = 1, mu.FTfilter.lpsi = 0, mu.beta.lpsi = 0,
  sig.beta.lpsi = 0, mean.p = 0.8, sig.lp = 1, mu.FTfilter.lp = 0,
  mu.beta.lp = 0, sig.beta.lp = 0)

Arguments

nsite

Number of sites in the meta-community.

nrep

Number of replicate samples of the meta-community.

nspec

Total number of species in the area that is sampled by these sites (i.e. the regional species pool).

mean.psi

Community mean of occupancy probability over all species in community (probability scale).

sig.lpsi

Community standard deviation of qlogis(occupancy probability intercept).

mu.FTfilter.lpsi

Effect of functional trait on occupancy probability (i.e. environmental filtering).

mu.beta.lpsi

Community mean of the effects of 'gradient'covariate on occupancy probability.

sig.beta.lpsi

Community standard deviation of the effects of 'gradient' covariate on occupancy probability.

mean.p

Community mean of detection probability over all species in superpopulation (probability scale).

sig.lp

Community standard deviation of qlogis(detection probability intercept).

mu.FTfilter.lp

Effect of functional trait on detection probability (i.e. detection filtering).

mu.beta.lp

Community mean of the effects of 'date' covariate on detection probability.

sig.beta.lp

Community standard deviation of the effects of 'date'covariate on detection probability.

Details

Function simulates data from repeated sampling of a metacommunity according 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 'gradient', while detection probability can be made dependent an observational covariate 'date'. Both intercept and slope of the two log- 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.

Value

To be written

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# Simulate community data
set.seed(1234)
dat <- simcom(mu.FTfilter.lp = 1.5, mu.FTfilter.lpsi = -0.5)

# Calculate community mean value of trait expression (CM)
commat_obs <- apply(dat$y, c(1,2), max)
CM_obs <- apply(commat_obs, 1, function(x) mean(dat$traitmat[x==1]))
CM_true <- apply(dat$z_true, 1, function(x) mean(dat$traitmat[x==1]))

# Plot CM along gradient
plot(dat$gradient, CM_obs, pch = 16, cex = 0.7, ylim = c(-1.5, 1.5))
points(dat$gradient, CM_true, cex = 0.7, col = "orange")
abline(h=0)
abline(h=mean(dat$traitmat), lty = 2)

# Effect of detection filtering along gradient
plot(dat$gradient, CM_obs - CM_true, pch = 16, cex = 0.7)
abline(h=0)

# Plot detection probability of a species and its trait expression
plot(dat$traitmat, dat$P, pch = 16, cex = 0.7, ylim = c(0,1),
  xlab = "Expression of functional trait", ylab = "")
mtext("Detection probability", 2, line = 3)
mtext("(at average gradient)", 2, line = 2.4, cex = 0.8)

TobiasRoth/detectionfilter documentation built on May 24, 2019, 2:07 a.m.