Latent abundance N_i ~ Poisson(lambda_i) (or, under
mixture = "negbin", N_i ~ NegBin(mean = lambda_i, size = size) with
variance lambda + lambda^2 / size) with log lambda_i = X_lambda beta_lambda, and replicate counts y_ij ~ Binomial(N_i, p_i) with
logit p_i = X_p beta_p (site-level detection). The returned y is an
N x J integer count matrix suitable for tobs() with abun().
Usage
simulate_abun(
N = 100,
J = 4,
n_abund_covs = 2,
n_det_covs = 1,
beta_lambda = NULL,
beta_p = NULL,
mixture = c("poisson", "negbin", "zip", "zinb"),
size = 2,
omega = 0.3,
seed = NULL
)Arguments
- N
Number of sites (default 100).
- J
Number of replicate visits (default 4).
- n_abund_covs
Number of abundance covariates (default 2).
- n_det_covs
Number of detection covariates (default 1).
- beta_lambda
Abundance coefficients
c(intercept, slopes...)on the log scale. Defaultc(log(3), runif(n_abund_covs, -0.5, 0.5)).- beta_p
Detection coefficients
c(intercept, slopes...)on the logit scale. Defaultc(0, runif(n_det_covs, -0.5, 0.5))(intercept 0 = p 0.5).- mixture
Abundance mixing distribution:
"poisson"(default),"negbin"(negative binomial, overdispersed), or their zero-inflated counterparts"zip"/"zinb"(a structural-zero shareomegaof sites haveN = 0regardless oflambda).- size
Negative-binomial size
r(the"negbin"/"zinb"dispersion; variancelambda + lambda^2 / r). Smallerrmeans more overdispersion; asrgrows large the model approaches Poisson. Default 2. Ignored under Poisson.- omega
Structural-zero probability for
"zip"/"zinb"(the share of sites withN = 0independent oflambda). Default 0.3. Ignored otherwise.- seed
Optional random seed.
Value
A list with y (N x J count matrix), data (covariate data frame),
and truth (the coefficients, per-site lambda, p, latent N, and the
mixture / size used).
Examples
sim <- simulate_abun(N = 50, J = 3, seed = 1)
dim(sim$y)