Description Usage Arguments Details Value See Also Examples
BC is the main function for running BayesComm models.
It is a wrapper function for BCfit; it checks inputs, sets up the model types and specifies a number of default BCfit settings.
| 1 | 
| Y | matrix of species presence/absence data | 
| X | matrix of environmental covariates | 
| model | type of model to run | 
| covlist | optional list of which covariates to assign to each species | 
| condition | matrix of conditioning variables | 
| its | number of iterations for sampling phase | 
| ... | further arguments to pass to  | 
Y must be a matrix with records as rows and species as columns and X a matrix with records as rows and covariates as columns.
model must be one of: "null" (intercept only), "environment" (intercept & covariates), "community" (intercept & community matrix) or "full" (intercept, covariates & community matrix).
covlist must have the same length as the number of species with, each element a vector of column indices for X. covlist defaults to NULL, which includes all covariates for all species.
For more details of arguments for model fitting see BCfit. condition is an optional matrix of conditioning variables.
These are fitted in the same way as X but are not removed in null and community models.
An object of class bayescomm containing the model call and parameter chains which can be viewed and manipulated using window, plot, print and summary.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | # create fake data
n <- 500
nsp <- 4
k <- 3
X <- matrix(c(rep(1, n), rnorm(n * k)), n)  # covariate matrix
# Random covariance matrix
W <- 10 * solve(rWishart(1, nsp + 1, diag(nsp))[ , , 1])
B <- matrix(rnorm(nsp * (k + 1), 0, 1), nsp)  # true covariates
mu <- apply(B, 1, function(b, x) x %*% b, X)  # true mean
e <- matrix(rnorm(n * nsp), n) %*% chol(W)  # true e
z <- mu + e  # true z
Y <- ifelse(z > 0, 1, 0)  # true presence/absence
# run BC (after removing intercept column from design matrix)
m1 <- BC(Y, X[, -1], model = "full", its = 100)
 | 
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.