[R] lme, best model without convergence
Spencer Graves
spencer.graves at pdf.com
Mon May 29 18:04:01 CEST 2006
I'm sorry. My post was in error on that point. I did "rm(fm1.)",
then tried again and got the same error message you got.
Conclusion: Either the 'returnObject' argument doesn't work in the
version(s) of lme that you and I are using or we've flunked another
literacy exam while RTFM. With luck, someone else will read this post
and answer this question for both of us.
If I had time to work on this, I'd make local copies of the code and
walk through them line by line using 'debug' until I figured out how to
solve the problem. I've outlined how to do this in previous posts, and
RSiteSearch("graves debug lme") led me to
"http://finzi.psych.upenn.edu/R/Rhelp02a/archive/72784.html", in case
you want to try that.
Hope this helps,
Spencer Graves
> sessionInfo()
Version 2.3.0 (2006-04-24)
i386-pc-mingw32
attached base packages:
[1] "methods" "stats" "graphics" "grDevices" "utils" "datasets"
[7] "base"
other attached packages:
nlme
"3.1-73"
#########################
> Dear Spencer Graves,
>
> thank you for your reply and the hint to the 'control' argument of the
> lme function.
> Thank you for your self-contained example. Running this example I get
> the verbose output. So I am able to trace the iterations and maybe I am
> able to detect ridges.
> However, I just updated the nlme-package at the Mainz CRAN mirror (on
> R-windows-2.2.1 version), but I do not get the result object from the
> not-converging fit:
>
> > lmeCtlList <-
> + lmeControl(maxIter=2,
> + msMaxIter=3, tolerance=1e-4, niter=4,
> + msTol=1e-5, nlmStepMax=5,
> + ,msVerbose=TRUE
> + ,returnObject=TRUE
> + )
> >
> > fm1. <- lme(distance ~ age, data = Orthodont,
> + control=lmeCtlList) # random is ~ age
> 0 318.310: -0.202572 0.0501133 2.17193
> 1 318.297: -0.202070 0.0662548 2.16740
> 2 318.286: -0.207284 0.0593806 2.15302
> 3 318.257: -0.215916 0.0783917 2.12677
> 3 318.257: -0.215916 0.0783917 2.12677
> Error in lme.formula(distance ~ age, data = Orthodont, control =
> lmeCtlList) :
> iteration limit reached without convergence (9)
> >
> > fm1.
> Error: object "fm1." not found
> >
##########################
lmeControl package:nlme R Documentation
Control Values for lme Fit
Description:
The values supplied in the function call replace the defaults and
a list with all possible arguments is returned. The returned list
is used as the 'control' argument to the 'lme' function.
##################
Note the last sentence. Now consider the following example, combining
modifications of your example with the example from "?lme":
> lmeCtlList <-
+ lmeControl(maxIter=2,
+ msMaxIter=3, tolerance=1e-4, niter=4,
+ msTol=1e-5, nlmStepMax=5,
+ ,msVerbose=TRUE
+ ,returnObject=TRUE
+ )
>
> fm1. <- lme(distance ~ age, data = Orthodont,
+ control=lmeCtlList) # random is ~ age
0 318.310: -0.202572 0.0501133 2.17193
1 318.297: -0.202071 0.0662548 2.16740
2 318.286: -0.207284 0.0593805 2.15302
3 318.257: -0.215916 0.0783916 2.12677
3 318.257: -0.215916 0.0783916 2.12677
Error in lme.formula(distance ~ age, data = Orthodont, control =
lmeCtlList) :
iteration limit reached without convergence (9)
> fm1.
Linear mixed-effects model fit by REML
Data: Orthodont
Log-restricted-likelihood: -221.3183
Fixed: distance ~ age
(Intercept) age
16.7611111 0.6601852
Random effects:
Formula: ~age | Subject
Structure: General positive-definite
StdDev Corr
(Intercept) 2.3270360 (Intr)
age 0.2264279 -0.609
Residual 1.3100396
Number of Observations: 108
Number of Groups: 27
>
Hope this helps.
Spencer Graves
p.s. First thanks for this example. I didn't know until I read your
question that one could actually get lme to return something when it
didn't converge. Second, you might have gotten a quicker reply if you
had included a simple, self-contained example, as suggested in the
posting guide! "www.R-project.org/posting-guide.html". Instead, since I
didn't know the answer, I had to invent one. If your example had been
self contained, you might have gotten an earlier reply from someone who
didn't have the time or inclination to invent an example like I did but
who might have otherwise been able to solve the problem.
Thomas Wutzler wrote:
> Dear R-help list readers,
>
> I am fitting mixed models with the lme function of the nlme package.
> If I get convergence depends on how the method (ML/REM) and which (and
> how much) parameters will depend randomly on the cluster-variable.
>
> How get the bist fit without convergence?
>
>
>
>
> I set the parameters msVerbose and returnObject to TRUE:
>
> lmeControl(maxIter=50000, msMaxIter=200, tolerance=1e-4, niter=50,
> msTol=1e-5, nlmStepMax=500,
> ,msVerbose=TRUE
> ,returnObject=TRUE
> )
>
> However, the lme-functions does not produce verbose output, nor does it
> return the best fit if lme is not converging.
> It returns only an error:
> Error in lme.formula(y ~ lndbh + I(lndbh^2) + lnh + I(lnh^2), random =
> ~lndbh + :
> iteration limit reached without convergence (9)
>
>
>
> Best regards
> Thomas
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
More information about the R-help
mailing list