This material with R-code and R package TraitEnvMLMWA is part of the paper "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 ". This is the version 8, a minor update. See readme.txt. The abstract of the paper is:
1. Statistical analysis of trait-environment association is challenging owing to the lack of a common observation unit: Community weighted mean regression (CWMr) uses site points, multilevel models focus on species points, and the fourth-corner correlation uses all species-site combinations. This situation invites the development of new methods capable of using all observation-levels. To this end, new multilevel and weighted averaging-based regression methods are proposed.
2. Compared to existing methods, the new multilevel method, called MLM3, has additional site-related random effects; they represent the unknowns in the environment that interact with the trait. The new weighted averaging method combines site-level CWMr with a species-level regression of Species Niche Centroids on to the trait. Because species can vary enormously in frequency and abundance giving diversity variation among sites, the regressions are weighted by Hill's effective number (N2) of occurrences of each species and the N2-diversity of a site, and are subsequently combined in a sequential test procedure known as the max test.
3. Using the test statistics of these new methods, the permutation-based max test provides strong statistical evidence for trait-environment association in a plant community dataset, where existing methods show weak evidence. In simulations, the existing multilevel model showed bias and type I error inflation, whereas MLM3 did not. Out of the weighted averaging-based regression methods, the N2-weighted version best controlled the type I error rate. MLM3 was superior to the weighted averaging-based methods with up to 30% more power.