Leo Gürtler
2005-Dec-12 16:26 UTC
[R] convergence error (lme) which depends on the version of nlme (?)
Dear list members, the following hlm was constructed: hlm <- groupedData(laut ~ design | grpzugeh, data = imp.not.I) the grouped data object is located at and can be downloaded: www.anicca-vijja.de/lg/hlm_example.Rdata The following works: library(nlme) summary( fitlme <- lme(hlm) ) with output: ... AIC BIC logLik 425.3768 465.6087 -197.6884 Random effects: Formula: ~design | grpzugeh Structure: General positive-definite StdDev Corr (Intercept) 0.3772478 (Intr) dsgn:8 dsgn:7 designmit:8 0.6776543 0.183 designohne:7 0.6619983 -0.964 0.086 designohne:8 1.0680576 -0.966 0.077 1.000 Residual 1.3468816 Fixed effects: laut ~ design Value Std.Error DF t-value p-value (Intercept) 3.857143 0.2917529 102 13.220579 0.0000 designmit:8 -0.285714 0.4417919 102 -0.646717 0.5193 designohne:7 -0.107143 0.4383878 102 -0.244402 0.8074 designohne:8 0.607143 0.5408713 102 1.122527 0.2643 Correlation: (Intr) dsgnm:8 dsgn:7 designmit:8 -0.451 designohne:7 -0.775 0.363 designohne:8 -0.763 0.304 0.699 Standardized Within-Group Residuals: Min Q1 Med Q3 Max -2.5074669 -0.4530573 0.1755326 0.5837670 2.3700004 Number of Observations: 112 Number of Groups: 7 The following does _not_ work and leads to a convergence error: fitlme1 <- lme(laut ~ design, random = ~ design | grpzugeh, data = hlm) Fehler in lme.formula(laut ~ design, random = ~design | grpzugeh, data = hlm) : iteration limit reached without convergence (9) This was tried with R : Copyright 2005, The R Foundation for Statistical Computing Version 2.2.0 (2005-10-06 r35749) Using another R version (2.1.0, also windows with nlme version built under R 2.1.1) , it works. Thus, what's the problem then? I tried without the random effects, i.e. random = ~ 1 | grpzugeh This works. Comparing both calls on the version R2.1.0 that goes well, the following differences in the output of the random effects can be identified: summary( fitlme <- lme(hlm) ) <--> Random effects: ... Structure: General positive-definite </--> compared to summary(lme(laut ~ design, random = ~ design | grpzugeh, data = hlm)) <--> Random effects: ... Structure: General positive-definite, Log-Cholesky parametrization </--> The estimates of the fixed effects are similar, the S.E.s not. The random effects are different, too. AIC/BIC/logLik are slightly different. Thus my question: 1) Do I have overseen a switch for the structure of the random effects? Is something wrong with the call/ formular? 2) What is the cause of the convergence error which seems to depend on the built of R/nlme? Thank you very much. Best wishes, leo g??rtler -- email: leog at anicca-vijja.de www: http://www.anicca-vijja.de/
Dieter Menne
2005-Dec-13 07:42 UTC
[R] convergence error (lme) which depends on the version of nlme (?)
Leo G伱伡rtler <leog <at> anicca-vijja.de> writes:> > > hlm <- groupedData(laut ~ design | grpzugeh, data = imp.not.I) > > the grouped data object is located at and can be downloaded:....> www.anicca-vijja.de/lg/hlm_example.Rdata...> > > 2) What is the cause of the convergence error which seems to depend on > the built of R/nlme?The optimization engine has in R 2.2.0 changed, with mixed results, see http://finzi.psych.upenn.edu/R/Rhelp02a/archive/64096.html In the short run, setting pnlsTol to a large value than the default worked for me sometimes. In the long run (hope I got Douglas Bates right) you could switch to lme4 which is work in progress, but currently it cannot handle your case. Dieter
Douglas Bates
2005-Dec-13 16:28 UTC
[R] convergence error (lme) which depends on the version of nlme (?)
On 12/12/05, Leo G??rtler <leog at anicca-vijja.de> wrote:> Dear list members, > > the following hlm was constructed: > > hlm <- groupedData(laut ~ design | grpzugeh, data = imp.not.I) > > the grouped data object is located at and can be downloaded: > > www.anicca-vijja.de/lg/hlm_example.Rdata > > The following works: > > library(nlme) > summary( fitlme <- lme(hlm) ) > > with output: > > ... > AIC BIC logLik > 425.3768 465.6087 -197.6884 > > Random effects: > Formula: ~design | grpzugeh > Structure: General positive-definite > StdDev Corr > (Intercept) 0.3772478 (Intr) dsgn:8 dsgn:7 > designmit:8 0.6776543 0.183 > designohne:7 0.6619983 -0.964 0.086 > designohne:8 1.0680576 -0.966 0.077 1.000 > Residual 1.3468816Notice that the estimated variance-covariance matrix for the random effects is singular (a correlation of +1.000). The estimates of the parameters in the model are on the boundary and it is not a proper linear mixed model. The definition of a linear mixed model (or at least my definition) requires that the variance-covariance matrix of the random effects be positive definite and this one is only positive semidefinite.> Fixed effects: laut ~ design > Value Std.Error DF t-value p-value > (Intercept) 3.857143 0.2917529 102 13.220579 0.0000 > designmit:8 -0.285714 0.4417919 102 -0.646717 0.5193 > designohne:7 -0.107143 0.4383878 102 -0.244402 0.8074 > designohne:8 0.607143 0.5408713 102 1.122527 0.2643 > Correlation: > (Intr) dsgnm:8 dsgn:7 > designmit:8 -0.451 > designohne:7 -0.775 0.363 > designohne:8 -0.763 0.304 0.699 > > Standardized Within-Group Residuals: > Min Q1 Med Q3 Max > -2.5074669 -0.4530573 0.1755326 0.5837670 2.3700004 > > Number of Observations: 112 > Number of Groups: 7 > > > The following does _not_ work and leads to a convergence error: > > fitlme1 <- lme(laut ~ design, random = ~ design | grpzugeh, data = hlm) > Fehler in lme.formula(laut ~ design, random = ~design | grpzugeh, data > hlm) : > iteration limit reached without convergence (9) > > This was tried with > > R : Copyright 2005, The R Foundation for Statistical Computing > Version 2.2.0 (2005-10-06 r35749) > > Using another R version (2.1.0, also windows with nlme version built > under R 2.1.1) , it works. Thus, what's the problem then? I tried > without the random effects, i.e. > > random = ~ 1 | grpzugeh > > This works. Comparing both calls on the version R2.1.0 that goes well, > the following differences in the output of the random effects can be > identified: > > summary( fitlme <- lme(hlm) ) > > <--> > Random effects: > ... > Structure: General positive-definite > </--> > compared to > > summary(lme(laut ~ design, random = ~ design | grpzugeh, data = hlm)) > > <--> > Random effects: > ... > Structure: General positive-definite, Log-Cholesky parametrization > </--> > > The estimates of the fixed effects are similar, the S.E.s not. > The random effects are different, too. AIC/BIC/logLik are slightly > different. > > Thus my question: > > 1) Do I have overseen a switch for the structure of the random effects? > Is something wrong with the call/ formular? > 2) What is the cause of the convergence error which seems to depend on > the built of R/nlme? > > > Thank you very much. Best wishes, > > leo g??rtler >As Dieter indicated in his response, the more current function lmer from the lme4 package (actually it's in the Matrix package but it would be in the lme4 package if a certain capability related to packages were available) is preferred to lme. Fitting your model with the control options for verbose output in both the EM and nlminb iterations produces> (fm1 <- lmer(laut ~ design + (design | grpzugeh), hlm, control = list(msV=1,EMv=1)))EM iterations 0 407.611 ( 6.00000 1.50000 1.50000 1.50000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000: -0.409 -1.07 -2.19 -0.969 -0.0472 -0.344 -0.0282 -0.491 -0.163 0.941) 1 402.107 ( 10.4497 1.95422 3.22722 2.22340 0.196761 1.02069 0.00757874 1.13553 0.110538 -0.685820: -0.122 -0.550 -0.567 -0.181 0.0294 -0.112 -0.00789 -0.204 -0.0184 0.361) 2 399.890 ( 14.8865 2.30933 5.18627 2.99207 0.242029 2.06595 -0.0167045 2.18847 0.173349 -1.51318: -0.0497 -0.331 -0.209 0.00812 0.0311 -0.0667 -0.00119 -0.129 0.00942 0.222) 3 398.756 ( 19.0686 2.58783 7.19874 3.76967 0.147926 3.04342 -0.0686073 3.14563 0.190736 -2.40480: -0.0224 -0.217 -0.0877 0.0682 0.0250 -0.0508 0.00304 -0.0968 0.0178 0.166) 4 398.074 ( 23.0243 2.81061 9.22509 4.55494 -0.0495774 3.95755 -0.140106 4.03331 0.174045 -3.33077:-0.00975 -0.150 -0.0362 0.0864 0.0192 -0.0422 0.00605 -0.0784 0.0213 0.134) 5 397.620 ( 26.8048 2.99284 11.2543 5.34938 -0.321835 4.82191 -0.225236 4.87317 0.132590 -4.27703:-0.00344 -0.108 -0.0119 0.0876 0.0145 -0.0360 0.00810 -0.0653 0.0229 0.111) 6 397.297 ( 30.4530 3.14530 13.2827 6.15353 -0.648070 5.64798 -0.319808 5.68021 0.0733009 -5.23609:-0.000236 -0.0797 -8.03e-05 0.0817 0.0110 -0.0310 0.00936 -0.0549 0.0233 0.0935) 7 397.056 ( 34.0009 3.27575 15.3091 6.96705 -1.01331 6.44439 -0.420871 6.46453 0.00126948 -6.20372: 0.00132 -0.0599 0.00554 0.0729 0.00841 -0.0267 0.00998 -0.0465 0.0229 0.0790) 8 396.869 ( 37.4726 3.38984 17.3332 7.78911 -1.40672 7.21745 -0.526327 7.23293 -0.0797758 -7.17737: 0.00200 -0.0458 0.00794 0.0636 0.00652 -0.0230 0.0101 -0.0394 0.0220 0.0669) 9 396.719 ( 40.8855 3.49170 19.3548 8.61870 -1.82039 7.97186 -0.634686 7.99007 -0.167115 -8.15547: 0.00219 -0.0355 0.00866 0.0547 0.00515 -0.0198 0.00992 -0.0334 0.0207 0.0568) 10 396.597 ( 44.2529 3.58443 21.3740 9.45479 -2.24856 8.71109 -0.744889 8.73911 -0.258776 -9.13700: 0.00214 -0.0278 0.00854 0.0466 0.00414 -0.0171 0.00950 -0.0285 0.0193 0.0484) 11 396.496 ( 47.5843 3.67032 23.3909 10.2964 -2.68700 9.43779 -0.856191 9.48223 -0.353339 -10.1213: 0.00197 -0.0221 0.00800 0.0397 0.00341 -0.0147 0.00894 -0.0244 0.0177 0.0414) 12 396.410 ( 50.8871 3.75110 25.4058 11.1428 -3.13263 10.1540 -0.968068 10.2209 -0.449787 -11.1079: 0.00175 -0.0177 0.00731 0.0337 0.00287 -0.0128 0.00831 -0.0209 0.0162 0.0356) 13 396.336 ( 54.1668 3.82804 27.4187 11.9931 -3.58321 10.8612 -1.08016 10.9563 -0.547403 -12.0965: 0.00152 -0.0144 0.00658 0.0287 0.00246 -0.0111 0.00767 -0.0180 0.0147 0.0307) 14 396.273 ( 57.4277 3.90213 29.4298 12.8467 -4.03710 11.5606 -1.19223 11.6890 -0.645684 -13.0868: 0.00130 -0.0119 0.00587 0.0245 0.00216 -0.00974 0.00703 -0.0156 0.0134 0.0267) 15 396.217 ( 60.6728 3.97408 31.4391 13.7032 -4.49313 12.2533 -1.30411 12.4196 -0.744284 -14.0787: 0.00111 -0.00989 0.00523 0.0210 0.00192 -0.00856 0.00642 -0.0136 0.0121 0.0233) 0 396.217: 0.0164819 0.274624 0.0345766 0.601897 -0.0740551 0.201957 0.204699 -0.108941 0.0481838 -0.572859 1 395.396: 5.00000e-10 0.265395 5.00000e-10 0.605834 -0.126945 0.228346 0.201255 -0.0635685 0.0429722 -0.617086 2 395.396: 5.00000e-10 0.265395 5.09510e-10 0.605834 -0.126945 0.228346 0.201255 -0.0635685 0.0429722 -0.617086 3 395.396: 5.01157e-10 0.265395 5.28494e-10 0.605834 -0.126945 0.228346 0.201255 -0.0635685 0.0429722 -0.617086 4 395.396: 5.01157e-10 0.265395 5.28494e-10 0.605834 -0.126945 0.228346 0.201255 -0.0635685 0.0429722 -0.617086 Linear mixed-effects model fit by REML Formula: laut ~ design + (design | grpzugeh) Data: hlm AIC BIC logLik MLdeviance REMLdeviance 425.3957 466.1732 -197.6979 393.5971 395.3957 Random effects: Groups Name Variance Std.Dev. Corr grpzugeh (Intercept) 0.13685 0.36993 designmit:8 0.48167 0.69403 0.244 designohne:7 0.41869 0.64706 -0.971 -0.006 designohne:8 1.09950 1.04857 -0.971 -0.006 1.000 Residual 1.81486 1.34717 # of obs: 112, groups: grpzugeh, 7 Fixed effects: Estimate Std. Error DF t value Pr(>|t|) (Intercept) 3.85714 0.29046 108 13.2795 <2e-16 designmit:8 -0.28571 0.44547 108 -0.6414 0.5226 designohne:7 -0.10714 0.43525 108 -0.2462 0.8060 designohne:8 0.60714 0.53545 108 1.1339 0.2593 Warning message: optim or nlminb returned message false convergence (8) in: "LMEoptimize<-"(`*tmp*`, value = list(maxIter = 200, tolerance 1.49011611938477e-08, which, again, shows the problem with the convergence.