library(mvabund) ## Load a dataset from the mvabund package
data(spider)
y <- spider$abun
## Example 1 - model with 2 latent variables, site effects,
## and no environmental covariates
spider.fit.nb <- boral(y, family = "negative.binomial", num.lv = 2,
site.eff = TRUE, n.burnin = 10, n.iteration = 100,
n.thin = 1, save.model = TRUE, calc.ics = FALSE)
## Example 2 - model with latent variables, no site effects,
## and environmental covariates
## This is quite similar to the manyglm() function in the mvabund package, except:
## the latent variables are permitted provide a method of accounting for
## correlation between species.
spider.fit.nb2 <- boral(y, X = spider$x, family = "negative.binomial", num.lv = 2,
site.eff = FALSE, n.burnin = 10, n.iteration = 100,
n.thin = 1, save.model = TRUE, calc.ics = FALSE)
Run the code above in your browser using DataLab