[R-sig-ME] Lmer-model fails to converge
Douglas Bates
bates at stat.wisc.edu
Thu Sep 4 20:17:51 CEST 2008
On Thu, Sep 4, 2008 at 10:06 AM, Ivar Herfindal
<ivar.herfindal at bio.ntnu.no> wrote:
> Dear Mixed-list
>
> I am trying to fit a mixed linear model with the lmer-function in the
> lme4-packages. After fitting the model, I get this warning:
> Warning message:
> In mer_finalize(ans) : iteration limit reached without convergence (9)
>
> By searching the R-archive, I found some sort of solution posted by Douglas
> Bates (http://finzi.psych.upenn.edu/R/Rhelp02a/archive/138008.html) which
> will provide a greater number of iterations. I therefore tried:
> (newmodel <- .Call("mer_optimize", mylmermodel, PACKAGE = "lme4"))
> The "FALSE" argument in Douglas Bates suggestion caused an error message,
> but it works fine without, and the model do now converge. However, I cannot
> figure out how to get the model from the last part of the iterations. That
> is, the .Call("mer_optimize"...) only print the verbose from the fitting
> process, but does not give an mer-object that I can evaluate and extract
> random and fixed effects from. Does anyone know if this "horrible hack"
> (Bates' own words) can give a mer-object or can I only use it to evaluate
> how far my initial model was from convergence? I am sorry that I cannot
> provide any example from my own data (the dataset is too large to attach),
> but I assume that any solution should be independent of the model or data.
Ah, you are working with a very recent version of the lme4 package. I
will commit another version of the lme4 package later this afternoon
with the ability to specify
lmer(..., control = list(maxIter = 500))
to increase the number of function evaluations.
However, that "horrible hack" that I described previously would have
updated the value of mylmermodel to the new parameter values so you
actually have the refitted model. That is part of the horrible aspect
- this is not supposed to happen in an R function. An R function
should not change the value of its arguments but this one does. The
reason is efficiency - if the arguments were being copied to the
result at every iteration most of the time would be spent copying the
structure representing the model. Especially with very large data
sets like yours, things would slow down to a crawl. So some of those
C functions called with .Call, like "mer_optimize" here, do things
that they shouldn't.
> Cheers
>
> Ivar
>
> SessionInfo
> sessionInfo()
> R version 2.7.2 (2008-08-25)
> i386-pc-mingw32
>
> locale:
> LC_COLLATE=Norwegian (Bokmål)_Norway.1252;LC_CTYPE=Norwegian
> (Bokmål)_Norway.1252;LC_MONETARY=Norwegian
> (Bokmål)_Norway.1252;LC_NUMERIC=C;LC_TIME=Norwegian (Bokmål)_Norway.1252
>
> attached base packages:
> [1] stats graphics grDevices utils datasets methods base
> other attached packages:
> [1] mgcv_1.4-1 splancs_2.01-24 sp_0.9-26
> lme4_0.999375-26 Matrix_0.999375-13 lattice_0.17-13
> loaded via a namespace (and not attached):
> [1] grid_2.7.2
>>
>
>
>
More information about the R-sig-mixed-models
mailing list