Learn R Programming

sjstats (version 0.17.4)

converge_ok: Convergence test for mixed effects models

Description

converge_ok() provides an alternative convergence test for merMod-objects; is_singular() checks post-fitting convergence warnings. If the model fit is singular, warning about negative eigenvalues of the Hessian can most likely be ignored.

Usage

converge_ok(x, tolerance = 0.001)

is_singular(x, tolerance = 1e-05, ...)

Arguments

x

A merMod-object. For is_singluar(), may also be a glmmTMB-object.

tolerance

Indicates up to which value the convergence result is accepted. The smaller tolerance is, the stricter the test will be.

...

Currently not used.

Value

For converge_ok(), a logical vector, which is TRUE if convergence is fine and FALSE if convergence is suspicious. Additionally, the convergence value is returned as return value's name. is_singluar() returns TRUE if the model fit is singular.

Details

converge_ok() provides an alternative convergence test for merMod-objects, as discussed here and suggested by Ben Bolker in this comment.

If a model is "singular", this means that some dimensions of the variance-covariance matrix have been estimated as exactly zero. is_singular() checks if a model fit is singular, and can be used in case of post-fitting convergence warnings, such as warnings about negative eigenvalues of the Hessian. If the fit is singular (i.e. is_singular() returns TRUE), these warnings can most likely be ignored.

There is no gold-standard about how to deal with singularity and which random-effects specification to choose. Beside using fully Bayesian methods (with informative priors), proposals in a frequentist framework are:

  • avoid fitting overly complex models, such that the variance-covariance matrices can be estimated precisely enough (Matuschek et al. 2017)

  • use some form of model selection to choose a model that balances predictive accuracy and overfitting/type I error (Bates et al. 2015, Matuschek et al. 2017)

  • “keep it maximal”, i.e. fit the most complex model consistent with the experimental design, removing only terms required to allow a non-singular fit (Barr et al. 2013)

References

  • Bates D, Kliegl R, Vasishth S, Baayen H. Parsimonious Mixed Models. arXiv:1506.04967, June 2015.

  • Barr DJ, Levy R, Scheepers C, Tily HJ. Random effects structure for confirmatory hypothesis testing: Keep it maximal. Journal of Memory and Language, 68(3):255-278, April 2013.

  • Matuschek H, Kliegl R, Vasishth S, Baayen H, Bates D. Balancing type I error and power in linear mixed models. Journal of Memory and Language, 94:305-315, 2017.

Examples

Run this code
# NOT RUN {
library(sjmisc)
library(lme4)
data(efc)
# create binary response
efc$hi_qol <- dicho(efc$quol_5)
# prepare group variable
efc$grp = as.factor(efc$e15relat)
# data frame for fitted model
mydf <- data.frame(hi_qol = as.factor(efc$hi_qol),
                   sex = as.factor(efc$c161sex),
                   c12hour = as.numeric(efc$c12hour),
                   neg_c_7 = as.numeric(efc$neg_c_7),
                   grp = efc$grp)
# fit glmer
fit <- glmer(hi_qol ~ sex + c12hour + neg_c_7 + (1|grp),
             data = mydf, family = binomial("logit"))

converge_ok(fit)

# }

Run the code above in your browser using DataLab