Last chance! 50% off unlimited learning
Sale ends in
traitglm
, typically to test for an environment-by-trait interaction. Slowly! This function works via anova.manyglm
, which uses row-resampling for inference, and it only applies to traitglm
objects that have been fitted using the (default) manyglm
function.## S3 method for class 'traitglm':
anova(object, \dots, nBoot=99, resamp="pit.trap", test="LR",
block = NULL, show.time="all", bootID=NULL)
traitglm
and class manyglm
.traitglm
objects, fitted using the formula
argument.anova.manyglm
, to control resampling method (resamp
), test statistic (test
) and whether or not a matrix of bootstrap resamples is manually entered (boot
anova.manyglm
, to keep all rows of the original abundance data together in resamples)."all"
shows all timing information, "total"
shows only the oanova.manyglm
, of which the most relevant element is table
(the analysis of deviance table).anova.traitglm
will only be valid if they are fitted to the same dataset. This may be a problem if there are missing values and R's default of na.action = na.omit
is used.traitglm
object is specified or multiple objects.
If one traitglm
object is specified, the anova.traitglm
function returns a table summarising the statistical significance of the fourth corner terms in a model, that is, the interaction between environment and traits in predicting abundance across taxa and sites. All environment-by-trait interaction terms from the model are simultaneously tested.
If two or more nested traitglm
objects are specified, and each has been fitted using a formula
argument to the same set of datasets, then sequential test statistics (and P values) are returned for each additional model fit.
All traitglm
models must be fitted using the manyglm
function, which is its default behaviour, in order to access the anova.manyglm
, which does most of the work. See anova.manyglm
for details on how resampling is done, and options for arguments controlling the test statistic (via test
) and the resampling method (via resamp
). Because traitglm
models are fitted by first vectorising the data into a univariate model, arguments such as p.uni
and cor.type
are redundant.
traitglm
fits a single model to abundances across all sites and taxa at the same time, meaning the vector of abundances is typically pretty long, and the design matrix explaining how abundance varies across taxa and sites is typically pretty large. So resampling can take yonks. Hence the default number of resamples has been set at nBoot=99
, but please consider increasing this once you have a sense for how long it will take to run (scales roughly linearly with nBoot
).anova.manyglm
,traitglm
data(antTraits)
# we'll fit a small fourth corner model, to a subset of the antTraits data.
# first select only species present in at least 25% of plots:
abSum = apply(antTraits$abund>0,2,mean)
ab = antTraits$abund[,abSum>0.25]
tr = antTraits$traits[abSum>0.25,]
# now fit the fourth corner model, only as a function of a couple of traits and env variables:
ft=traitglm(ab,antTraits$env[,1:3],data.frame(tr$Weber,tr$Femur))
anova(ft,nBoot=39)
# Note you should refit with more bootstrap samples (e.g. 999), should take <2 minutes to run
# for an example using anova.traitglm for multiple fits, uncomment the following lines:
# ft2=traitglm(antTraits$abund,antTraits$env[,3:4],antTraits$traits[,c(1,3)],
# formula=~1,composition=TRUE) #no fourth corner terms
# ft3=traitglm(antTraits$abund,antTraits$env[,3:4],antTraits$traits[,c(1,3)],
# formula=~Shrub.cover:Femur.length+Shrub.cover:Pilosity,composition=TRUE) #shrub interactions
# ft4=traitglm(antTraits$abund,antTraits$env[,3:4],antTraits$traits[,c(1,3)],
# formula=~Shrub.cover:Femur.length+Shrub.cover:Pilosity+Volume.lying.CWD:Femur.length+
# Volume.lying.CWD:Pilosity, composition=TRUE) #all interactions only
# anova(ft2,ft3,ft4) # Shrub interactions not significant but CWD interactions are.
Run the code above in your browser using DataLab