expand4glmm | R Documentation |
expand4glmm
inflates a TE_obj
object (see make_obj_for_traitenv
), which consists of
trait, environment and abundance data, into a format for glm, glmer and glmmTMB.
expand4glmm(obj, K = 0)
obj |
an object of class TE_obj, usually the output of function |
K |
scalar, 0 for count-like data and the binomial total for data that you like to analyse using logit models (1 for presence-absence). |
With single trait and single environment variable data (ncol(obj$T)== ncol(obj$E)==1), the names
of the trait and environmental variables are changed to trait and env (to allow identical MLM formulas for different data and variables ).
In the multi-variable case,
the original names are kept and all interactions are added.
expand4glmm
is used repeatedly in the model-based permutational max test
using function MLM3_p_max
. In this function, obj
is extended
with list elements trait0
and env0
to allow for the detail needed in the model-based permutational max test. If used in this way, the
internal logical inPermut_r_c
is set to TRUE
.
A data frame. For single trat and enviornmental variable data:
y |
the response; the abuncance values in obj$L |
site |
a factor indicating the site corresponding to each value of y |
species |
a factor indicating the species corresponding to each value of y |
obs |
integer 1 to N, the length of y |
trait |
trait |
env |
environmental variable |
trait.env |
the product |
In the multi-trait environment case: all traits and environmental variables and all pairwise interactions
ter Braak (2019) New robust weighted averaging- and model-based methods for assessing trait-environment relationships. Methods in Ecology and Evolution (https://doi.org/10.1111/2041-210X.13278 )
ter Braak, C.J.F., Peres-Neto, P. & Dray, S. (2017) A critical issue in model-based inference for studying trait-based community assembly and a solution. PeerJ, 5, e2885. https://doi.org/10.7717/peerj.2885
## Not run: data("aravo", package = "ade4") Y <-aravo$spe trait <- scale(aravo$traits$SLA) env <- scale(aravo$env$Snow) obj <- make_obj_for_traitenv(env,Y, trait, cutoff=0) K = 0 # 0 for non-binomial models dat <- expand4glmm(obj, K = K) names(dat) library(glmmTMB) formula.MLM3 <- y ~ poly(env,2) + poly(trait,2) + env : trait + (1 + env|species) + (1 + trait| site) MLM3 <- glmmTMB(formula.MLM3, family = betabinomial, data=dat) summary(MLM3) plot_MLM3(MLM3) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.