View source: R/Bootstrap_test_prmtrc.r
Bootstrap_test_prmtrc | R Documentation |
Bootstrap_test_prmtrc
performs a parametric bootstrap test on trait-environment interaction,
starting from a fitted MLM3 object (or any other MLM object with the trait:env term as last fixed parameter).
Bootstrap_test_prmtrc( MLM3, test_stat = "Wald", nrepet = 19, Binomial_total = 0, nAGQ = 0 )
MLM3 |
the fitted MLM3 object, created by glmer (lme4) or glmmTMB. |
test_stat |
choice of test statistic; 'Wald' (default), 'LRT' or 'both'. The default is quicker. |
nrepet |
number of bootstraps |
Binomial_total |
scalar, 0 for count-like data and the binomial total for logit models (1 for presence-absence). |
nAGQ |
integer scalar (default 0), used only for an object created by glmer |
The code assumes that the parameter for trait-environment interaction (trait:env) is the last fixed parameter in summary(MLM3). First, the formula of the null model is created by deleting the trait:env term from the formula of object MLM3 (the non-null model). Second, the null model (MLM0) is fitted. Three, sampling is from this null model. For each simulated data set, the model is refitted using the formula of the MLM3 object. The code works therefore also for MLM1 and MLM2, although their use is not recommended. See also Box A2 in Appendix A4 and Appendix A1.
A named list,
p_values |
the parametric and bootstrap p-values |
MLM0 |
the fitted null model |
obs |
value of the test statistic(s) |
nrepet |
number of bootstraps |
sim.boot |
values of the test statistic(s) for the nrepet bootstrapped data |
test_stat |
the chosen test statistic(s) |
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, e.g. from the Revisit data data("MLM3") ## or compute the 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_boot <- Bootstrap_test_prmtrc(MLM3, test_stat = "Wald", nrepet = nrepet, Binomial_total = 100) names(res_boot) round(res_boot$p_values,3) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.