[R] lme convergence failure within a loop

Sam Nicol scnicol at alaska.edu
Thu Jun 23 00:58:34 CEST 2011


Hi R-users,

I'm attempting to fit a number of mixed models, all with the same 
structure, across a spatial grid with data points collected at various 
time points within each grid cell. I'm trying to use a 'for' loop to try 
the model fit on each grid cell. In some cells lme does not converge, 
giving me the error:

Error message: In lme.formula(logarea ~ year + summ_d, data = grid2, 
random = ~year +  :
   nlminb problem, convergence error code = 1
   message = iteration limit reached without convergence (9)

When I get the error, the program aborts, and my loop stops.

I'm not too worried about the error, as a generic mixed model structure 
may not be the best fit for every cell. I expect the optimization to 
fail in some places. I want to be able to detect when the algorithm has 
failed to converge automatically, so that I can continue my loop and 
record the places where the model does fit. I've used the lmeControl 
method with returnObject=TRUE options to allow me to continue looping, 
however I want to be able to flag the places where the convergence 
failed so that I can reject these gridcells and not mistakenly claim 
that the model fits at these points. Is there a way to do this?

My example code shows the relevant lines of code-- what I'm hoping for 
is a way to determine that the convergence failed and record this as a 
boolean value, or something similar.

Thanks,

Sam Nicol


-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: example_code.r
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20110622/a98379d0/attachment.pl>


More information about the R-help mailing list