MLM3_p_max | R Documentation |
MLM3_p_max
performs the permutational max test of trait-environment interaction for MLM models,
starting from a fitted MLM3 object.
MLM3_p_max( MLM3, nrepet = 19, Binomial_total = 0, test_stat = "Wald", how_to_permute = list(sites = how(), species = how()), print = 1, nAGQ = 0 )
MLM3 |
the fitted MLM3 object, created by glmer (lme4) or glmmTMB. |
nrepet |
number of bootstraps |
Binomial_total |
scalar, 0 for count-like data and the binomial total for logit models (1 for presence-absence). |
test_stat |
choice of test statistic; 'Wald' (default) or 'LRT'. |
how_to_permute |
a list for two |
print |
integer; print progress every |
nAGQ |
integer scalar (default 0), used only for an object created by glmer |
The code assumes that the interaction parameter is the last fixed parameter in summary(MLM3).
The data used in the max test is extracted using dat4MLM2TE_obj
. This generates an object of class TE_obj
(see
make_obj_for_traitenv
). dat4MLM2TE_obj
is limitted for use with a single trait and single environmental variable,
and so is therefore MLM3_p_max
.
In the model-based permutation tests, either the trait values or the environmental values in the interaction term T*E of the model are permuted to yield
a species- and site-level test, respectively.
Main effects for the permuted trait and environmental variable are added to ensure
that the interaction after permutation has a corresponding main effect.
For further details, see Appendices A4 and A5 of ter Braak (2019).
A named list, among which,
p_values |
four p-values: one parametric p-value (Wald test) and three permutational p-values: site-based and species-based and the maximum of these two values |
obs |
values of the test statistic for sites (first row) and species (second row) |
sim.row |
values of the test statistic for the nrepet data in which the rows of E are permuted |
sim.col |
values of the test statistic for the nrepet data in which the rows of T are permuted |
nrepet |
number of permutations |
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)
expand4glmm
.
## Not run: #use a precomputed MLM3 model for the Revisit data data("MLM3") ## or compute an MLM3 model from the data # data("Revisit") # formula.MLM3 <- y ~ poly(env,2) + poly(trait,2) + env : trait + (1 + env|species) + (1 + trait| site) # MLM3 <- glmmTMB(formula.MLM3, family = betabinomial, data=Revisit) summary(MLM3) res_perm <- MLM3_p_max(MLM3, test_stat = "Wald", nrepet = nrepet, Binomial_total = 100) names(res_perm) round(res_perm$p_values,3) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.