Simulate species mix data for model fitting.
species_mix.simulate(
archetype_formula,
species_formula,
data,
offset = NULL,
nArchetypes = 3,
alpha = NULL,
beta = NULL,
gamma = NULL,
logTheta = NULL,
powers = NULL,
size = NULL,
family = "bernoulli"
)formula to simulate species_mix data, needs to have the format: cbind(spp1,spp2,spp3,...,sppN)~1 + x1 + x2
formula to simulate species_mix species-specific responses, e.g: ~1
a matrix of variables to simulate data from.
used to offset sampling effort for abundance data (log link function).
number of groups to simulate.
coefficients for each species archetype. vector S long.
coefficients for each species archetype. Matrix of G x number of parameters. Each row is a different species archetype.
coefficients for each species archetype. Matrix of S x number of parameters. Each row is a different species archetype.
coefficients for the dispersion variables for negative.binomial and gaussian distributions - should be number of species long and on the natural log scale.
Is the power parameter for Tweedie distribution.
Is for the binomial model and this represents the number of binomial trials per site, can be fixed or vary.
Which statistical distribution to simulate data for. 'bernoulli','binomial', 'gaussian', 'ippm', 'negative.binomial' and 'poisson'.
# \donttest{
archetype_formula <- stats::as.formula(paste0('cbind(',paste(paste0('spp',
1:20),collapse = ','),")~1+x1+x2"))
species_formula <- stats::as.formula(~1)
beta <- matrix(c(-3.6,0.5,
-0.9,1.0,
0.9,-2.9,
2.2,5.4),
4,2,byrow=TRUE)
dat <- data.frame(y=rep(1,100),
x1=stats::runif(100,0,2.5),
x2=stats::rnorm(100,0,2.5))
simulated_data <- species_mix.simulate(archetype_formula,species_formula,
data=dat, nArchetypes = 4, beta=beta,
family="bernoulli")
#> Random alpha from normal (-1,0.5) distribution
# }