library(mvtnorm)
library(mvabund) ## Load a dataset from the mvabund package
data(spider)
y <- spider$abun
n <- nrow(y); p <- ncol(y);
## Create a boral model JAGS script, where distributions alternative
## between Poisson and negative binomial distributions
## across the rows of y...cool!
make.jagsboralmodel(family = rep(c("poisson","negative.binomial"),length=n),
site.eff = TRUE, X.eff = FALSE, n, p)
## Create a boral model JAGS script, where distributions are all negative
## binomial distributions and covariates will be included.
make.jagsboralmodel(family = "negative.binomial",
site.eff = FALSE, X.eff = TRUE, n, p)
## Simulate some ordinal data and create a JAGS model script
true.lv <- rbind(rmvnorm(10,mean=c(-2,-2)),rmvnorm(10,mean=c(2,2)))
## 20 rows (sites) with two latent variables
true.lv.coefs <- rmvnorm(30,mean = rep(0,3));
## 30 columns (species)
true.lv.coefs[nrow(true.lv.coefs),1] <- -sum(true.lv.coefs[-nrow(true.lv.coefs),1])
## Impose a sum-to-zero constraint on the column effects
true.ordinal.cutoffs <- seq(-2,10,length=10-1)
## Cutoffs for proportional odds regression (must be in increasing order)
sim.y <- create.life(true.lv = true.lv, lv.coefs = true.lv.coefs,
family = "ordinal", cutoffs = true.ordinal.cutoffs)
make.jagsboralmodel(family = "ordinal", X.eff = FALSE, site.eff = FALSE, n=20, p=30)
Run the code above in your browser using DataLab