Description Usage Arguments Details Value References Examples
View source: R/check_singularity.R
Check mixed models for boundary fits.
1  check_singularity(x, tolerance = 1e05, ...)

x 
A mixed model. 
tolerance 
Indicates up to which value the convergence result is
accepted. The larger 
... 
Currently not used. 
If a model is "singular", this means that some dimensions of the
variancecovariance matrix have been estimated as exactly zero. This
often occurs for mixed models with complex random effects structures.
“While singular models are statistically well defined (it is
theoretically sensible for the true maximum likelihood estimate to
correspond to a singular fit), there are real concerns that (1) singular
fits correspond to overfitted models that may have poor power; (2) chances
of numerical problems and misconvergence are higher for singular models
(e.g. it may be computationally difficult to compute profile confidence
intervals for such models); (3) standard inferential procedures such as
Wald statistics and likelihood ratio tests may be inappropriate.”
(lme4 Reference Manual)
There is no goldstandard about how to deal with singularity and which
randomeffects 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 variancecovariance 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 nonsingular fit (Barr et al. 2013)
Note the different meaning between singularity and convergence: singularity indicates an issue with the "true" best estimate, i.e. whether the maximum likelihood estimation for the variancecovariance matrix of the random effects is positive definite or only semidefinite. Convergence is a question of whether we can assume that the numerical optimization has worked correctly or not.
TRUE
if the model fit is singular.
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):255278, 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:305315, 2017.
lme4 Reference Manual, https://cran.rproject.org/package=lme4
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18  if (require("lme4")) {
data(sleepstudy)
set.seed(123)
sleepstudy$mygrp < sample(1:5, size = 180, replace = TRUE)
sleepstudy$mysubgrp < NA
for (i in 1:5) {
filter_group < sleepstudy$mygrp == i
sleepstudy$mysubgrp[filter_group] <
sample(1:30, size = sum(filter_group), replace = TRUE)
}
model < lmer(
Reaction ~ Days + (1  mygrp / mysubgrp) + (1  Subject),
data = sleepstudy
)
check_singularity(model)
}

Loading required package: lme4
Loading required package: Matrix
[1] FALSE
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.