[R] Notification of false convergence with lmer()

Ben Bolker bolker at ufl.edu
Fri Dec 11 23:35:53 CET 2009


jjh <jjharden <at> gmail.com> writes:

> 
> 
> I am running the lmer() command in a for loop and occasionally a particular
> iteration is producing the false convergence warning. I would like to be
> able to mark these iterations with a dummy variable, but I can't find any
> other notification besides the warning message, which, in a for loop, only
> is printed after the loop is finished (which does not allow me to see which
> iteration it happened on). Is there any way I can mark which iteration in
> the loop produces the false convergence?
> 
> Thank you.


Something like this might help: you could set it to return
NA or something on the warning.

  You might want to direct future questions along these lines
to r-sig-mixed-models at lists.r-project.org ... 

## wrap glmer to make warnings into errors
lmer2 <- function(...,action=c("stop","code")) {
  action <- match.args(action)
  op <- options(warn=2)
  on.exit(options(op))
  x <- try(lmer(...),silent=TRUE)
  if (inherits(x,"try-error")) {
    if (action=="stop") {
      stop(x,unclass(x))
    } else if (action=="code") {
      stop("stub: code response not implemented yet")
    }
  } ## otherwise OK -- fall through
  x
}




More information about the R-help mailing list