simMsNMix {spAbundance} | R Documentation |
Simulate Multi-Species Repeated Count Data with Imperfect Detection
Description
The function simMsNMix
simulates multi-species count data for simulation studies, power assessments, or function testing. Data can be optionally simulated with a spatial Gaussian Process in the abundance portion of the model, as well as an option to allow for species correlations using a factor modeling approach. Non-spatial random effects can also be included in the detection or abundance portions of the model.
Usage
simMsNMix(J.x, J.y, n.rep, n.rep.max, n.sp, beta, alpha, kappa, mu.RE = list(),
p.RE = list(), offset = 1, sp = FALSE, cov.model,
sigma.sq, phi, nu, family = 'Poisson',
factor.model = FALSE, n.factors, ...)
Arguments
J.x |
a single numeric value indicating the number of sites to simulate count data along the horizontal axis. Total number of sites with simulated data is |
J.y |
a single numeric value indicating the number of sites to simulate count data along the vertical axis. Total number of sites with simulated data is |
n.rep |
a numeric vector of length |
n.rep.max |
a single numeric value indicating the maximum number of replicate surveys. This is an optional argument, with its default value set to |
n.sp |
a single numeric value indicating the number of species to simulate count data. |
beta |
a numeric matrix with |
alpha |
a numeric matrix with |
kappa |
a numeric vector of length |
mu.RE |
a list used to specify the non-spatial random effects included in the abundance portion of the model. The list must have two tags: |
p.RE |
a list used to specify the non-spatial random effects included in the detection portion of the model. The list must have two tags: |
offset |
either a single numeric value or a vector of length |
sp |
a logical value indicating whether to simulate a spatially-explicit model with a Gaussian process. By default set to |
cov.model |
a quoted keyword that specifies the covariance function used to model the spatial dependence structure among the latent abundance values. Supported covariance model key words are: |
sigma.sq |
a numeric vector of length |
phi |
a numeric vector of length |
nu |
a numeric vector of length |
factor.model |
a logical value indicating whether to simulate data following a factor modeling approach that explicitly incoporates species correlations. If |
n.factors |
a single numeric value specifying the number of latent factors to use to simulate the data if |
family |
the distribution to use for the latent abundance process. Currently
supports |
... |
currently no additional arguments |
Value
A list comprised of:
X |
a |
X.p |
a three-dimensional numeric array with dimensions corresponding to sites, repeat visits, and number of detection regression coefficients. This is the design matrix used for the detection portion of the N-mixture model. |
coords |
a |
w |
a |
mu |
a |
N |
a |
p |
a |
y |
a |
X.p.re |
a three-dimensional numeric array containing the levels of any detection random effect included in the model. Only relevant when detection random effects are specified in |
X.re |
a numeric matrix containing the levels of any abundance random effect included in the model. Only relevant when abundance random effects are specified in |
alpha.star |
a numeric matrix where each row contains the simulated detection random effects for each given level of the random effects included in the detection model. Only relevant when detection random effects are included in the model. |
beta.star |
a numeric matrix where each row contains the simulated abundance random effects for each given level of the random effects included in the abundance model. Only relevant when abundance random effects are included in the model. |
Author(s)
Jeffrey W. Doser doserjef@msu.edu,
Examples
J.x <- 8
J.y <- 8
J <- J.x * J.y
n.rep <- sample(2:4, size = J, replace = TRUE)
n.sp <- 10
# Community-level covariate effects
# Abundance
beta.mean <- c(0.2, -0.15)
p.abund <- length(beta.mean)
tau.sq.beta <- c(0.6, 0.3)
# Detection
alpha.mean <- c(0.5, 0.2)
tau.sq.alpha <- c(0.2, 0.3)
p.det <- length(alpha.mean)
mu.RE <- list(levels = c(10, 12),
sigma.sq.mu = c(1.5, 0.3),
beta.indx = list(1, 2))
p.RE <- list(levels = c(15, 10),
sigma.sq.p = c(0.8, 0.5),
alpha.indx = list(1, 2))
# Draw species-level effects from community means.
beta <- matrix(NA, nrow = n.sp, ncol = p.abund)
alpha <- matrix(NA, nrow = n.sp, ncol = p.det)
for (i in 1:p.abund) {
beta[, i] <- rnorm(n.sp, beta.mean[i], sqrt(tau.sq.beta[i]))
}
for (i in 1:p.det) {
alpha[, i] <- rnorm(n.sp, alpha.mean[i], sqrt(tau.sq.alpha[i]))
}
factor.model <- TRUE
n.factors <- 3
# Spatial parameters if desired
phi <- runif(n.factors, 3/1, 3/.1)
sp <- TRUE
family <- 'Poisson'
dat <- simMsNMix(J.x = J.x, J.y = J.y, n.rep = n.rep, n.sp = n.sp, beta = beta,
alpha = alpha, mu.RE = mu.RE, p.RE = p.RE, sp = TRUE,
cov.model = 'exponential', phi = phi, factor.model = factor.model,
n.factors = n.factors, family = family)