Learn R Programming

sjstats (version 0.10.2)

converge_ok: Convergence test for mixed effects models

Description

This function provides an alternative convergence test for merMod-objects.

Usage

converge_ok(x, tolerance = 0.001)

Arguments

x

A merMod-object.

tolerance

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

Value

Logical vector, TRUE if convergence is fine, FALSE if convergence is suspicious. Additionally, the convergence value is returned as return value's name.

Details

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

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