rglmmtmbglmm

glmmTMB convergence messages


Using glmmTMB I have (so far) found 4 convergence scenarios:

  1. Normal convergence. No warnings and:
model$fit$convergence == 0  
model$fit$message  == "relative convergence (4)"
  1. Convergence to a singular fit:
warning: "model convergence problem; singular convergence (7)"
model$fit$convergence: 1
model$fit$message :  "singular convergence (7)"
  1. Convergence to (possibly ) a singular fit:
warning: "Model convergence problem; non-positive-definite Hessian matrix"
model$fit$convergence: 0
model$fit$message: "relative convergence (4)"
  1. Non-convergence (false convergence):
warning 1: "Model convergence problem; non-positive-definite Hessian matrix." 
warning 2: " Model convergence problem; false convergence (8)"
model$fit$convergence: 1
model$fit$message:  "false convergence (8)"

My problem is that I need to check the status programmatically. So far I have not found how to extract the warnings from the fitted object, so I have been working with the output just model$fit$convergence and model$fit$message, and as you can see, these are identical for 1) and 3) above.

So my questions:

  1. How do I (programatically) definitively determine the convergence status, from the fitted object?
  2. What do the numbers in parenthesis in the message/warnings mean? I see 4, 7 and 8 as you see above. So I'm curious if there are other status' for 1,2,3,5 and 6 and maybe 9+ ? Are there some other convergence statuses that I haven't yet found?

If anyone wants to try this for themselves, then obviously you need data and code which produces these scenarios, so here it is:

# 1. Normal convergence:

set.seed(1)
data <- data.frame(y = rnorm(100), x = rnorm(100), group = rep(1:10, each = 10))
model <- glmmTMB(y ~ x + (1  | group), data = data)
model$fit$convergence # == 0
model$fit$message  # "relative convergence (4)"

# 2. Singular fit

set.seed(3)
data <- data.frame(y = rnorm(100), x = rnorm(100), group = rep(1:10, each = 10))
model <- glmmTMB(y ~ x + (1 + x | group), data = data)
model$fit$convergence # == 1
model$fit$message  # "singular convergence (7)"

# 3. Possibly a singular fit:

set.seed(5)
data <- data.frame(y = rnorm(100), x = rnorm(100), group = rep(1:10, each = 10))
model <- glmmTMB(y ~ x + (1 + x^2 | group), data = data)
model$fit$convergence # == 0
model$fit$message # "relative convergence (4)"

# 4. False Convergence

set.seed(1)
data <- data.frame(y = rnorm(100), x = rnorm(100), group = rep(1:10, each = 10))
data$y1 = data$y < -2
model <- glmmTMB(y1 ~ x + (1 + x | group), family = binomial, data = data)
model$fit$convergence   #  == 1
model$fit$message  # "false convergence (8)"

Solution

  • tl;dr model should be OK if model$fit$convergence == 0 && model$sdr$pdHess is satisfied.

    These warnings come from two different places.


    nlminb does not list the possible convergence codes. Here is a subset of "bad" codes from the PORT documentation:

    7 — singular convergence: x may have too many free components. See §5.
    8 — false convergence: the gradient ∇f(x) may be computed incorrectly, the other stopping tolerances may be too tight, or either f or ∇f may be discontinuous near the current iterate x.
    9 — function evaluation limit: no convergence after IV(MXFCAL) = IV(17) evaluations of f(x).
    10 — iteration limit: no convergence after IV(MXITER) = IV(18) iterations.
    11 — STOPX returned .TRUE.: you supplied a system-dependent STOPX (see §12) routine and hit the BREAK key.
    12–13 — impossible: these are input IV(1) values only. (12 means allocate storage within IV and V and start the algorithm; this is the default IV(1) value supplied by [D]IVSET. 13 means just allocate storage and return. See §4a for an example.)
    14 — storage has been allocated (after a call with IV(1) = 13 — see, for example, §4a below)


    1 From the PORT documentation:

    V(37) is the singular-convergence tolerance. A return with IV(1) = 7 occurs if a more favorable stopping test is not satisfied and if the algorithm thinks

    f (x) − min {f(y) :||D(y-x)|| ≤ V(LMAXS) } < V(SCTOL) .|f(x)|,
    

    where D is given by (4.1). When this test is satisfied, it appears that x has too many degrees of freedom — and you should ponder whether f was properly formulated. Default = max {10^{-10}, MACHEP^{2/3} }.