simMsAbund {spAbundance} | R Documentation |
Simulate Multivariate Data for Testing GLMMs
Description
The function simMsAbund
simulates multivariate data without imperfect detection for simulation studies, power assessments, or function testing related to GLMMs. Data can be optionally simulated with a spatial Gaussian Process in 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 abundance portions of the model.
Usage
simMsAbund(J.x, J.y, n.rep, n.rep.max, n.sp, beta, kappa, tau.sq, mu.RE = list(),
offset = 1, sp = FALSE, cov.model, svc.cols = 1,
sigma.sq, phi, nu, family = 'Poisson',
factor.model = FALSE, n.factors, z, ...)
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 |
kappa |
a numeric vector of length |
tau.sq |
a numeric vector of length |
mu.RE |
a list used to specify the non-spatial random intercepts included in the model. The list must have two tags: |
offset |
either a single numeric value, 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 abundance values. Supported covariance model key words are: |
svc.cols |
a vector indicating the variables whose effects will be
estimated as spatially-varying coefficients. |
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 |
z |
a matrix with |
... |
currently no additional arguments |
Value
A list comprised of:
X |
a three-dimensional numeric design array of covariates with dimensions corresponding to sites, replicates, and number of covariates (including an intercept) for the model. |
coords |
a |
w |
a list of |
mu |
a |
y |
a |
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 |
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
set.seed(408)
J.x <- 8
J.y <- 8
J <- J.x * J.y
n.rep <- sample(3, size = J, replace = TRUE)
n.sp <- 6
# Community-level covariate effects
beta.mean <- c(-2, 0.5)
p.abund <- length(beta.mean)
tau.sq.beta <- c(0.2, 1.2)
# Random effects (two random intercepts)
mu.RE <- list(levels = c(10, 15),
sigma.sq.mu = c(0.43, 0.5))
# Draw species-level effects from community means.
beta <- matrix(NA, nrow = n.sp, ncol = p.abund)
for (i in 1:p.abund) {
beta[, i] <- rnorm(n.sp, beta.mean[i], sqrt(tau.sq.beta[i]))
}
sp <- TRUE
n.factors <- 2
factor.model <- TRUE
phi <- runif(n.factors, 3/1, 3 / .1)
kappa <- runif(n.sp, 0.1, 1)
dat <- simMsAbund(J.x = J.x, J.y = J.y, n.rep = n.rep, n.sp = n.sp, beta = beta,
mu.RE = mu.RE, sp = sp, kappa = kappa, family = 'NB',
factor.model = factor.model, phi = phi,
cov.model = 'spherical', n.factors = n.factors)