# NOT RUN {
## NOTE: The values below MUST NOT be used in a real application;
## they are only used here to make the examples run quick!!!
example_mcmc_control <- list(n.burnin = 10, n.iteration = 100,
n.thin = 1)
library(mvabund) ## Load a dataset from the mvabund package
data(spider)
y <- spider$abun
n <- nrow(y)
p <- ncol(y)
spiderfit_nb <- boral(y, family = "negative.binomial", lv.control = list(num.lv = 2),
row.eff = "fixed", save.model = TRUE, calc.ics = TRUE,
mcmc.control = example_mcmc_control)
## Extract MCMC samples
fit_mcmc <- get.mcmcsamples(spiderfit_nb)
## WATCH OUT! The following takes a very long time to run!
get.more.measures(y, family = "negative.binomial",
num.lv = spiderfit_nb$num.lv, fit.mcmc = fit_mcmc,
row.eff = "fixed", row.ids = spiderfit_nb$row.ids)
## Illustrating what happens in a case where these criteria will
## not be calculated.
data(antTraits)
y <- antTraits$abun
X <- as.matrix(scale(antTraits$env))
## Include only traits 1, 2, and 5
traits <- as.matrix(antTraits$traits[,c(1,2,5)])
example_which_traits <- vector("list",ncol(X)+1)
for(i in 1:length(example_which_traits))
example_which_traits[[i]] <- 1:ncol(traits)
fit_traits <- boral(y, X = X, traits = traits, lv.control = list(num.lv = 2),
which.traits = example_which_traits, family = "negative.binomial",
save.model = TRUE, mcmc.control = example_mcmc_control)
## Extract MCMC samples
fit_mcmc <- get.mcmcsamples(fit_traits)
get.more.measures(y, X = X, family = "negative.binomial",
num.lv = fit.traits$num.lv, fit.mcmc = fit_mcmc)
# }
Run the code above in your browser using DataLab