Learn R Programming

JWileymisc (version 0.3.1)

compareLMER: Compare two lmer models

Description

This function provides fit statistics and effect sizes for model comparisons. The models must be nested.

Usage

compareLMER(m1, m2)

Arguments

m1

A model estimated by lmer.

m2

A model estimated by lmer.

Value

a data table with the fit indices for each model and comparing models to each other.

References

For estimating the marginal and conditional R-squared values, see: Nakagawa, S. and Schielzeth, H. (2013). A general and simple method for obtaining R2 from generalized linear mixed-effects models. Methods in Ecology and Evolution, 4(2), 133-142. as well as: Johnson, P. C. (2014). Extension of Nakagawa & Schielzeth's R2GLMM to random slopes models. Methods in Ecology and Evolution, 5(9), 944-946.

Examples

Run this code
# NOT RUN {
# }
# NOT RUN {
data(aces_daily)
m1 <- lme4::lmer(NegAff ~ STRESS + (1 + STRESS | UserID),
  data = aces_daily)
m2 <- lme4::lmer(NegAff ~ STRESS + (1 | UserID),
  data = aces_daily)

compareLMER(m1, m2)

rm(m1, m2)
# }

Run the code above in your browser using DataLab