simMsDS {spAbundance} | R Documentation |
Simulate Multi-Species Distance Sampling Data
Description
The function simMsDS
simulates multi-species distance sampling 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
simMsDS(J.x, J.y, n.bins, bin.width, n.sp, beta, alpha,
det.func, transect = 'line', 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.bins |
a single numeric value indicating the number of distance bins from which to generate data. |
bin.width |
a vector of length |
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 |
det.func |
the detection model used to describe how detection probability varies
with distance. In other software, this is often referred to as the key function. Currently
supports two functions: half normal ( |
transect |
the type of transect. Currently supports line transects ( |
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 |
coords |
a |
w |
a |
mu |
a |
N |
a |
p |
a |
y |
a |
X.p.re |
a numeric matrix 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 <- 10
J.y <- 10
J <- J.x * J.y
# Number of distance bins from which to simulate data.
n.bins <- 5
# Length of each bin. This should be of length n.bins
bin.width <- c(.10, .10, .20, .3, .1)
# Number of species
n.sp <- 5
# Community-level abundance coefficients
beta.mean <- c(-1, 0.2, 0.3, -0.2)
p.abund <- length(beta.mean)
tau.sq.beta <- c(0.2, 0.3, 0.5, 0.4)
# Detection coefficients
alpha.mean <- c(-1.0, -0.3)
p.det <- length(alpha.mean)
tau.sq.alpha <- c(0.1, 0.2)
# Detection decay function
det.func <- 'halfnormal'
mu.RE <- list()
p.RE <- list()
# 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]))
}
sp <- FALSE
family <- 'NB'
kappa <- runif(n.sp, 0.3, 3)
offset <- pi * .8^2
transect <- 'line'
factor.model <- FALSE
dat <- simMsDS(J.x = J.x, J.y = J.y, n.bins = n.bins, bin.width = bin.width,
n.sp = n.sp, beta = beta, alpha = alpha, det.func = det.func, kappa = kappa,
mu.RE = mu.RE, p.RE = p.RE, sp = sp, cov.model = cov.model,
sigma.sq = sigma.sq, phi = phi, nu = nu, family = family,
offset = offset, transect = transect, factor.model = factor.model)