as.eicm {eicm}R Documentation

Define a parameterized EICM model

Description

Constructs a EICM model object from given coefficients and data. Useful for simulating "true" models, otherwise only used internally.

Usage

as.eicm(
  env.coefs,
  sp.coefs = NULL,
  latent = NULL,
  options = NULL,
  occurrences = NULL,
  env = NULL,
  traits = NULL,
  intercept = TRUE,
  regularization = NULL
)

Arguments

env.coefs

the environmental coefficient matrix: a species x variable matrix (including intercept).

sp.coefs

the species interaction coefficient matrix: a species x species matrix, with zero diagonal.

latent

the values for the latent variables in each sample: a sample x latent variable matrix.

options

a eicm.options object defining options for fitting. Usually not needed, use forbidden, mask.sp and exclude.prevalence instead.

occurrences

a binary (0/1) sample x species matrix, possibly including NAs.

env

an optional sample x environmental variable matrix, for the known environmental predictors.

traits

an optional species x trait matrix. Currently, it is only used for excluding species interactions a priori.

intercept

logical specifying whether to add a column for the species-level intercepts.

regularization

a two-element numeric vector defining the regularization lambdas used for environmental coefficients and for species interactions respectively. See details.

Details

regularization is only used for storing the regularization lambdas used in model fitting. It is ignored in simulation.

Value

A eicm object that can be used for prediction.

Note

This function is only useful for simulation purposes. If you want to predict values from a fitted model, a eicm object is already provided for the fitted model.

See Also

predict.eicm

Examples

# Generate some coefficients
nenv <- 2
nsp <- 20
nsamples <- 200

env <- matrix(rnorm(nenv * nsamples), ncol=nenv, nrow=nsamples)
env.coefs <- matrix(runif((nenv + 1) * nsp, -4, 4), nrow=nsp)
sp.coefs <- matrix(0, nrow=nsp, ncol=nsp)
sp.coefs[3, 5] <- 3
sp.coefs[4, 8] <- 2

# Define a true model (including environmental data)
truemodel <- as.eicm(env=env, env.coefs=env.coefs, sp.coefs=sp.coefs)

# We can now realize it
predict(truemodel)

[Package eicm version 1.0.3 Index]