[R-sig-ME] catch non-convergence in lmer as variable

Ben Bolker bolker at ufl.edu
Fri Jun 5 13:26:48 CEST 2009


  Hmm.  I don't know about type -- I generally use
if (inherits(fitmodel,"try-error"))

   do you have an extra space at the end of "try-error"
in your type variable?

   I was using

glmer2 <- function(...) {
  op <- options(warn=2)
  on.exit(options(op))
  x <- try(glmer(...),silent=TRUE)
  if (inherits(x,"try-error")) {
    stop(x,unclass(x))
  }
  x
}

Ursa Reja wrote:
> Dear R-users,
> 
> I am doing simulations with lmer function. For every simulation I extract
> estimates,...into a database, but I also want to have a variable that would
> indicate whether simulated data converged properly or not. (I get warnings,
> for ex. singular convergence, false convergence,...but the estimates are
> given anyway).
> 
> I tried to cope with the problem so that I change warnings to error (warn=2)
> and use function try, like below:
> 
> ok <- function(x,type= "try-error ") class(x)!=type
> 
> options(warn=2)
> 
> fitmodel <- try(lmer(modelformula,data))
> 
> but
> 
> ok(fitmodel)
> 
> gives me TRUE even if I get a warning!
> 
> 
> Thank you!
> 
> 
> Ursa Reja
> 
> 
> 
> 
> ######~~~~~~~~~~   extract deviances  ~~~~~~~~~~######
> 
> 
> 
> ##if(ok(fitmodel)&ok(fitmodel1)&ok(fitmodel2)&ok(fitmodel3))
> 
> ##if(ok(fitmodel))
> 
> ##{
> 
> 	[[alternative HTML version deleted]]
> 
> _______________________________________________
> R-sig-mixed-models at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models


-- 
Ben Bolker
Associate professor, Biology Dep't, Univ. of Florida
bolker at ufl.edu / www.zoology.ufl.edu/bolker
GPG key: www.zoology.ufl.edu/bolker/benbolker-publickey.asc




More information about the R-sig-mixed-models mailing list