abund {spAbundance} | R Documentation |
Function for Fitting Univariate Abundance GLMMs
Description
Function for fitting univariate abundance generalized linear (mixed) models
Usage
abund(formula, data, inits, priors, tuning,
n.batch, batch.length, accept.rate = 0.43, family = 'Poisson',
n.omp.threads = 1, verbose = TRUE,
n.report = 100, n.burn = round(.10 * n.batch * batch.length), n.thin = 1,
n.chains = 1, save.fitted = TRUE, ...)
Arguments
formula |
a symbolic description of the model to be fit for the model using R's model syntax. Only right-hand side of formula is specified. See example below. Random intercepts and slopes are allowed using lme4 syntax (Bates et al. 2015). |
data |
a list containing data necessary for model fitting.
Valid tags are |
inits |
a list with each tag corresponding to a parameter name.
Valid tags are |
priors |
a list with each tag corresponding to a parameter name.
Valid tags are |
tuning |
a list with each tag corresponding to a parameter name,
whose value defines the initial variance of the adaptive sampler.
Valid tags are |
n.batch |
the number of MCMC batches in each chain to run for the adaptive MCMC sampler. See Roberts and Rosenthal (2009) for details. |
batch.length |
the length of each MCMC batch in each chain to run for the Adaptive MCMC sampler. See Roberts and Rosenthal (2009) for details. |
accept.rate |
target acceptance rate for Adaptive MCMC. Default is 0.43. See Roberts and Rosenthal (2009) for details. |
family |
the distribution to use for the latent abundance process. Currently
supports |
n.omp.threads |
a positive integer indicating the number of threads
to use for SMP parallel processing. The package must be compiled for
OpenMP support. For most Intel-based machines, we recommend setting
|
verbose |
if |
n.report |
the interval to report MCMC progress. |
n.burn |
the number of samples out of the total |
n.thin |
the thinning interval for collection of MCMC samples. The
thinning occurs after the |
n.chains |
the number of chains to run in sequence. |
save.fitted |
logical value indicating whether or not fitted values and likelihood values
should be saved in the resulting model object. If |
... |
currently no additional arguments |
Value
An object of class abund
that is a list comprised of:
beta.samples |
a |
kappa.samples |
a |
tau.sq.samples |
a |
y.rep.samples |
a two or three-dimensional array of posterior samples for the abundance replicate (fitted) values with dimensions corresponding to MCMC samples, site, and an optional third dimension of replicate. |
mu.samples |
a two or three-dimensional array of posterior samples for the expected abundance samples with dimensions corresponding to MCMC samples, site, and an optional third dimension of replicate. |
sigma.sq.mu.samples |
a |
beta.star.samples |
a |
like.samples |
a |
rhat |
a list of Gelman-Rubin diagnostic values for some of the model parameters. |
ESS |
a list of effective sample sizes for some of the model parameters. |
run.time |
execution time reported using |
The return object will include additional objects used for subsequent prediction and/or model fit evaluation.
Author(s)
Jeffrey W. Doser doserjef@msu.edu,
Andrew O. Finley finleya@msu.edu,
References
Bates, Douglas, Martin Maechler, Ben Bolker, Steve Walker (2015). Fitting Linear Mixed-Effects Models Using lme4. Journal of Statistical Software, 67(1), 1-48. doi:10.18637/jss.v067.i01.
Examples
set.seed(1010)
J.x <- 15
J.y <- 15
J <- J.x * J.y
n.rep <- sample(3, J, replace = TRUE)
beta <- c(0, -1.5, 0.3, -0.8)
p.abund <- length(beta)
mu.RE <- list(levels = c(30),
sigma.sq.mu = c(1.3))
kappa <- 0.5
sp <- FALSE
family <- 'NB'
dat <- simAbund(J.x = J.x, J.y = J.y, n.rep = n.rep, beta = beta,
kappa = kappa, mu.RE = mu.RE, sp = sp, family = 'NB')
y <- dat$y
X <- dat$X
X.re <- dat$X.re
covs <- list(int = X[, , 1],
abund.cov.1 = X[, , 2],
abund.cov.2 = X[, , 3],
abund.cov.3 = X[, , 4],
abund.factor.1 = X.re[, , 1])
data.list <- list(y = y, covs = covs)
# Priors
prior.list <- list(beta.normal = list(mean = 0, var = 100),
kappa.unif = c(0.001, 10))
# Starting values
inits.list <- list(beta = 0, kappa = kappa)
tuning <- list(kappa = 0.2, beta = 0.1, beta.star = 0.2)
n.batch <- 5
batch.length <- 25
n.burn <- 0
n.thin <- 1
n.chains <- 1
out <- abund(formula = ~ abund.cov.1 + abund.cov.2 + abund.cov.3 +
(1 | abund.factor.1),
data = data.list,
n.batch = n.batch,
batch.length = batch.length,
inits = inits.list,
tuning = tuning,
priors = prior.list,
accept.rate = 0.43,
n.omp.threads = 1,
verbose = TRUE,
n.report = 1,
n.burn = n.burn,
n.thin = n.thin,
n.chains = n.chains)
summary(out)