Re: [R] lme convergence

From: Dimitris Rizopoulos <dimitris.rizopoulos_at_med.kuleuven.be>
Date: Fri 30 Jun 2006 - 17:03:45 EST

I think the following part of lme.formula

if (numIter > controlvals$maxIter) {

    stop("Maximum number of iterations reached without convergence.") }

should be something like

if (numIter > controlvals$maxIter) {

    if (controlvals$returnObject) {

        warning("Maximum number of iterations reached without convergence.")

        break
    } else {

        stop("Maximum number of iterations reached without convergence.")

    }
}

Best,
Dimitris



Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium

Tel: +32/(0)16/336899
Fax: +32/(0)16/337015
Web: http://med.kuleuven.be/biostat/
     http://www.student.kuleuven.be/~m0390867/dimitris.htm


> Does anyone know how to obtain the 'returnObject' from an 'lme'
> run
> that fails to converge? An argument of this name is described on
> the
> 'lmeControl' help page as, "a logical value indicating whether the
> fitted object should be returned when the maximum number of
> iterations
> is reached without convergence of the algorithm. Default is
> 'FALSE'."

>

> Unfortunately, I've so far been unable to get it to work, as
> witnessed by the following modification of an example from the
> '?lme'
> help page:
>

> > library(nlme)
> > fm1 <- lme(distance ~ age, data = Orthodont,
> + control=lmeControl(msMaxIter=1))
> Error in lme.formula(distance ~ age, data = Orthodont, control =
> lmeControl(msMaxIter = 1)) :
> iteration limit reached without convergence (9)
> > fm1
> Error: object "fm1" not found
> > fm1 <- lme(distance ~ age, data = Orthodont,
> + control=lmeControl(msMaxIter=1,
> + returnObject=TRUE))
> Error in lme.formula(distance ~ age, data = Orthodont, control =
> lmeControl(msMaxIter = 1, :
> iteration limit reached without convergence (9)
> > fm1
> Error: object "fm1" not found
>

> I might be able to fix the problem myself, working through the
> 'lme'
> code line by line, e.g., using 'debug'. However, I'm not ready to
> do
> that just now.
>

> Best Wishes,
> Spencer Graves
>

> Ravi Varadhan wrote:
>> Use "try" to capture error messages without breaking the loop.
>> ?try
>>
>> --------------------------------------------------------------------------
>> Ravi Varadhan, Ph.D.
>> Assistant Professor,  The Center on Aging and Health
>> Division of Geriatric Medicine and Gerontology
>> Johns Hopkins University
>> Ph: (410) 502-2619
>> Fax: (410) 614-9625
>> Email:  rvaradhan@jhmi.edu
>> Webpage: 
>> http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html
>> --------------------------------------------------------------------------
>>
>>> -----Original Message-----
>>> From: r-help-bounces@stat.math.ethz.ch [mailto:r-help-
>>> bounces@stat.math.ethz.ch] On Behalf Of Pryseley Assam
>>> Sent: Wednesday, June 28, 2006 12:18 PM
>>> To: R-Users
>>> Subject: [R] lme convergence
>>>
>>> Dear R-Users,
>>>
>>>   Is it possible to get the covariance matrix from an lme model 
>>> that did
>>> not converge ?
>>>
>>>   I am doing a simulation which entails fitting linear mixed 
>>> models, using
>>> a "for loop".
>>>   Within each loop, i generate a new data set and analyze it using 
>>> a mixed
>>> model.  The loop stops When the "lme function" does not converge 
>>> for a
>>> simulated dataset. I want to inquire if there is a method to 
>>> suppress the
>>> error message from the lme function, or better still, a way of 
>>> going about
>>> this issue of the loop ending once the lme function does not 
>>> converge.
>>>
>>>   Thanks in advance,
>>>   Pryseley
>>>
>>>
>>> ---------------------------------
>>>
>>>
>>> [[alternative HTML version deleted]]
>>>
>>> ______________________________________________
>>> R-help@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
>>
>> ______________________________________________
>> R-help@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
>

> ______________________________________________
> R-help@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
>

Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm



R-help@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 Received on Fri Jun 30 23:00:54 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Mon 03 Jul 2006 - 18:15:01 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.