simTBinom {spOccupancy} | R Documentation |
Simulate Multi-Season Single-Species Binomial Data
Description
The function simTBinom
simulates multi-season single-species binomial data for simulation studies, power assessments, or function testing. Data can be optionally simulated with a spatial Gaussian Process in the model. Non-spatial random intercepts can also be included in the model.
Usage
simTBinom(J.x, J.y, n.time, weights, beta, sp.only = 0,
trend = TRUE, psi.RE = list(), sp = FALSE,
cov.model, sigma.sq, phi, nu, svc.cols = 1,
ar1 = FALSE, rho, sigma.sq.t, x.positive = FALSE, ...)
Arguments
J.x |
a single numeric value indicating the number of sites to simulate 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 data along the vertical axis. Total number of sites with simulated data is |
n.time |
a single numeric value indicating the number of primary time periods (denoted T) over which sampling occurs. |
weights |
a numeric matrix with rows corresponding to sites and columns corresponding to primary time periods that indicates the number of Bernoulli trials at each of the site/time period combinations. |
beta |
a numeric vector containing the intercept and regression coefficient parameters for the model. |
sp.only |
a numeric vector specifying which occurrence covariates should only vary over space and not over time. The numbers in the vector correspond to the elements in the vector of regression coefficients ( |
trend |
a logical value. If |
psi.RE |
a list used to specify the non-spatial random intercepts included in the model. The list must have two tags: |
sp |
a logical value indicating whether to simulate a spatially-explicit occupancy model with a Gaussian process. By default set to |
svc.cols |
a vector indicating the variables whose effects will be
estimated as spatially-varying coefficients. |
cov.model |
a quoted keyword that specifies the covariance function used to model the spatial dependence structure among the latent occurrence values. Supported covariance model key words are: |
sigma.sq |
a numeric value indicating the spatial variance parameter. Ignored when |
phi |
a numeric value indicating the spatial decay parameter. Ignored when |
nu |
a numeric value indicating the spatial smoothness parameter. Only used when |
ar1 |
a logical value indicating whether to simulate a temporal random effect with an AR(1) process. By default, set to |
rho |
a numeric value indicating the AR(1) temporal correlation parameter. Ignored when |
sigma.sq.t |
a numeric value indicating the AR(1) temporal variance parameter. Ignored when |
x.positive |
a logical value indicating whether the simulated covariates should be simulated as random standard normal covariates ( |
... |
currently no additional arguments |
Value
A list comprised of:
X |
a |
coords |
a |
w |
a matrix of the spatial random effect values for each site. The number of columns is determined by the |
psi |
a |
z |
a |
X.w |
a three dimensional array containing the covariate effects (including an intercept) whose effects are assumed to be spatially-varying. Dimensions correspond to sites, primary time periods, and covariate. |
X.re |
a numeric matrix containing the levels of any unstructured random effect included in the model. Only relevant when random effects are specified in |
beta.star |
a numeric vector that contains the simulated random effects for each given level of the random effects included in the model. Only relevant when random effects are included in the model. |
Author(s)
Jeffrey W. Doser doserjef@msu.edu,
Andrew O. Finley finleya@msu.edu
Examples
set.seed(1000)
# Sites
J.x <- 15
J.y <- 15
J <- J.x * J.y
# Years sampled
n.time <- sample(10, J, replace = TRUE)
# Binomial weights
weights <- matrix(NA, J, max(n.time))
for (j in 1:J) {
weights[j, 1:n.time[j]] <- sample(5, n.time[j], replace = TRUE)
}
# Occurrence --------------------------
beta <- c(-2, -0.5, -0.2, 0.75)
p.occ <- length(beta)
trend <- TRUE
sp.only <- 0
psi.RE <- list()
# Spatial parameters ------------------
sp <- TRUE
svc.cols <- c(1, 2, 3)
p.svc <- length(svc.cols)
cov.model <- "exponential"
sigma.sq <- runif(p.svc, 0.1, 1)
phi <- runif(p.svc, 3/1, 3/0.2)
# Temporal parameters -----------------
ar1 <- TRUE
rho <- 0.8
sigma.sq.t <- 1
dat <- simTBinom(J.x = J.x, J.y = J.y, n.time = n.time, weights = weights, beta = beta,
psi.RE = psi.RE, sp.only = sp.only, trend = trend,
sp = sp, svc.cols = svc.cols,
cov.model = cov.model, sigma.sq = sigma.sq, phi = phi,
rho = rho, sigma.sq.t = sigma.sq.t, ar1 = TRUE, x.positive = FALSE)