This function fits a fourth corner model, that is, a model to predict abundance across several taxa (stored in L
) as a function of environmental variables (R
) and traits (Q
). The environment-trait interaction can be understood as the fourth corner, giving the set of coefficients that describe how environmental response across taxa varies as traits vary. A species effect is include in the model (i.e. a different intercept term for each species), so that traits are used to explain patterns in relative abundance across taxa not patterns in absolute abundance.
The actual function used to fit the model is determined by the user through the method
argument. The default is to use manyglm
to fit a GLM, although for predictive modelling, it might be better to use a LASSO penalty as in glm1path
and cv.glm1path
. In glm1path
, the penalty used for BIC calculation is log(dim(L)[1])
, i.e. log(number of sites).
The model is fitted by vectorising L
then constructing a big matrix from repeated values of R
, Q
, their quadratic terms (if required) and interactions. Hence this function will hit memory issues if any of these matrices are large, and can slow down (especially if using cv.glm1path
). If formula
is left unspecified, the design matrix is constructed using all environmental variables and traits specified in R
and Q
, and quadratic terms for any of these variables that are quantitative, and all environment-trait interactions, after standardising these variables. Specifying a one-sided formula
as a function of the variables in R
and Q
would instead give the user control over the precise model that is fitted, and drops the internal standardisations. The arguments composition
and col.intercepts
optionally add terms to the model for row and column total abundance, irrespective of whether a formula
has been specified.
Note: when specifying a formula
, if there are no penalties on coefficients (as for manyglm
), then main effects for R
can be excluded if including row effects (via composition=TRUE
), and main effects for Q
can be excluded if including column effects (via col.intercepts=TRUE
), because those terms are redundant (trying to explain main effects for row/column when these main effects are already in the model). If using penalised likelihood (as in glm1path
and cv.glm1path
) or a random effects model, by all means include main effects as well as row/column effects, and the penalties will sort out which terms to use.
If trait matrix Q
is not specified, default behaviour will fit a different environmental response for each taxon (and the outcome will be very similar to manyglm(L~R)
). This can be understood as a fourth corner model where species identities are used as the species traits (i.e. no attempt is made to explain differences across species).
These functions inherit default behaviour from their fitting functions. e.g. use plot
for a Dunn-Smyth residual plot from a traits model fitted using manyglm
or glm1path
.