Learn R Programming

coenocliner (version 0.2-3)

simJamil: Simulate species abundance data following Jamil & ter Braak (2013)

Description

Simulate species probability of occurrence data according to the method used by Tahira Jamil and Cajo ter Braak in their recent paper Generalized linear mixed models can detect unimodal species-environment relationships.

Usage

simJamil(
  n,
  m,
  x,
  gl = 4,
  randx = TRUE,
  tol = 0.5,
  tau = gl/2,
  randm = TRUE,
  expectation = FALSE
)

Arguments

n

numeric; the number of samples/sites.

m

numeric, the number of species/variables.

x

numeric; values for the environmental gradient. Can be missing, in which case suitable values are generated. See Details.

gl

numeric; gradient length in arbitrary units. The default is 4 units with gradient values ranging from -2 to 2.

randx

logical; should locations along the gradient (x) be located randomly or equally-spaced?

tol

numeric; the species tolerances. Can be a vector of length m, hence allowing for varying tolerances along the gradient x.

tau

numeric; constant that ensures some of the optima are located beyond the observed gradient end points.

randm

logical; should species optima along the gradient be located randomly or equally-spaced?

expectation

logical; if TRUE the binomial probabilities \(p_{ij}\) from the response curve are returned directly. If FALSE, the default, random draws from a Bernoulli distribution with probability \(p_{ij}\) are made.

Value

a matrix of n rows and m columns containing the simulated species abundance data.

References

Jamil and ter Braak (2013) Generalized linear mixed models can detect unimodal species-environment relationships. PeerJ 1:e95; DOI 10.7717/peerj.95.

Examples

Run this code
# NOT RUN {
set.seed(42)
N <- 100   # Number of locations on gradient (samples)
glen <- 4  # Gradient length
grad <- sort(runif(N, -glen/2, glen/2)) # sample locations
M <- 10    # Number of species
sim <- simJamil(n = N, m = M, x = grad, gl = glen, randx = FALSE,
                randm = FALSE, expectation = TRUE)
## visualise the response curves
matplot(grad, sim, type = "l", lty = "solid")

## simulate binomial responses from those response curves
sim <- simJamil(n = N, m = M, x = grad, gl = glen, randx = FALSE,
                randm = FALSE)

# }

Run the code above in your browser using DataLab