[R] lme convergence
Michael Jerosch-Herold
jeroschh at ohsu.edu
Fri Jun 30 18:36:41 CEST 2006
It looks like in the call to lme
fm1 <- lme(distance ~ age, data = Orthodont,
+ control=lmeControl(msMaxIter=1))
you did not specify any random effects. Why not try:
fm1 <- lme(distance ~ age, random= ~1| groupID, data = Orthodont,
+ control=lmeControl(msMaxIter=1))
where groupID is some factor that can be used to stratify the data.
Also, the "Othodont" data set is used in Pinheiro & Bates book, and you may want to consult
that book to see the models they use in connection with that data set. For the Orthodont data set
the groupID would most likely be the subject ID ("Subject" variable).
So a possible model would be:
> fm1 <- lme(distance ~ age, random= ~1|Subject, data=Orthodont)
> summary(fm1)
Linear mixed-effects model fit by REML
Data: Orthodont
AIC BIC logLik
455.0025 465.6563 -223.5013
Random effects:
Formula: ~1 | Subject
(Intercept) Residual
StdDev: 2.114724 1.431592
Fixed effects: distance ~ age
Value Std.Error DF t-value p-value
(Intercept) 16.761111 0.8023952 80 20.88885 0
age 0.660185 0.0616059 80 10.71626 0
Correlation:
(Intr)
age -0.845
Standardized Within-Group Residuals:
Min Q1 Med Q3 Max
-3.66453932 -0.53507984 -0.01289591 0.48742859 3.72178465
Number of Observations: 108
Number of Groups: 27
So this runs fine.
As, I said this data set and its analysis is discussed extensively in Pinheiro and Bates book
Michael Jerosch-Herold
>>> "Spencer Graves" <spencer.graves at pdf.com> 06/29/06 7:08 PM >>>
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 at jhmi.edu
> Webpage: http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html
> --------------------------------------------------------------------------
>
>> -----Original Message-----
>> From: r-help-bounces at stat.math.ethz.ch [mailto:r-help-
>> bounces at 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 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
>
> ______________________________________________
> 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