Simulate community relative-abundance (count / continuous) data
Source:R/data.R
simulate_ms_count.RdPer-species GLMM with Gaussian community hyperpriors on the coefficients (the
ms_count() / spAbundance msAbund model): g(mu_{s,i}) = X_i beta_s,
beta_s ~ N(beta_comm_mean, diag(beta_comm_sd^2)), y_{s,i} drawn Poisson /
negative-binomial (log link) or Gaussian (identity). No detection.
Arguments
- N
Number of sites.
- n_species
Number of species.
- beta_comm_mean, beta_comm_sd
Community mean and SD of the per-species coefficients (intercept first). Length sets the number of covariates.
- response
One of
"poisson","negbin","gaussian","binomial".- size
Negative-binomial community size (mean of the per-species
log_r);size.log.sdis its across-species SD.- size.log.sd
Across-species SD of
log(size)(negbin only).- sd
Gaussian residual SD.
- trials
Binomial trial count (
response = "binomial"): a scalar (shared across sites and species) or a length-Nper-site vector. Default 10.- seed
Optional RNG seed.
Examples
sim <- simulate_ms_count(N = 50, n_species = 4, seed = 1)
head(sim$y)