View source: R/anova.traitglm.R
anova.traitglm | R Documentation |
Returns an analysis of deviance from a fourth corner model, as computed using 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, ..., nBoot=99, resamp="pit.trap", test="LR", block = NULL, show.time="all", bootID=NULL)
object |
A fitted object of class |
... |
Additional |
nBoot |
The number of bootstrap iterations. Default is 99 (NOTE: you should increase this for later runs!) |
resamp,test,bootID |
Arguments as in |
block |
A factor specifying the sampling level to be resampled. Default is resampling sites (which still involves passing a blocking variable to |
show.time |
Whether to display timing information for the resampling procedure: this is advisable, as resampling fourth corner models many times can take a while. The default value |
There are two possible uses of this function, depending whether one 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
).
A list of values as returned by anova.manyglm
, of which the most relevant element is table
(the analysis of deviance table).
The comparison between two or more models by 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.
David I. Warton <David.Warton@unsw.edu.au>
Warton DI, Shipley B & Hastie T (2015) CATS regression - a model-based approach to studying trait-based community assembly, Methods in Ecology and Evolution 6, 389-398.
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.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.