Reputation: 31
I am trying to find a best model fitting on my data using library(nlme)
and lme
function in R. Here is my model when the slope is fixed:
FixedRopeLength <- lme(EnergyCost~ RopeLength,
data = data,
random=~1|Subject, method = "ML")
summary(FixedRopeLength)
To see whether a random slope provides a better model than a fixed slope, I let the slope to vary across Subject as follows:
RandomRopeLength <- lme(EnergyCost~RopeLength,
data = data,
random=~RopeLength|Subject, method = "ML")
summary(RandomRopeLength)
However, I got this error:
Error in lme.formula(EnergyCost ~ RopeLength, data = data, random = ~RopeLength | : nlminb problem, convergence error code = 1
message = iteration limit reached without convergence (10)
Any solution??
Upvotes: 1
Views: 12217
Reputation: 31
Thank you so much for your help. Your code worked. I only needed to justify your code based on lme function. Here is the code which can be used for aforementioned error:
RandomRopeLength <- lme(EnergyCost~RopeLength,
data = data,
random=~RopeLength|Subject, method = "ML",
control =list(msMaxIter = 1000, msMaxEval = 1000))
summary(RandomRopeLength)
Upvotes: 2
Reputation: 226162
?lme
shows that there is a control
argument, which redirects you to ?lmerControl
, which gives you
msMaxIter: maximum number of iterations for the optimization step inside the ‘lme’ optimization. Default is ‘50’.
and
msMaxEval: maximum number of evaluations of the objective function permitted for nlminb. Default is ‘200’.
These correspond to eval.max
and iter.max
from ?nlminb
. Since I'm not sure which of these is the problem, I would re-run the model with
control = lmeControl(msMaxIter = 1000, msMaxEval = 1000)
However, I'll warn you that once you have a problem that experiences numerical problems with the default parameter settings, adjusting the parameter settings may just lead to other problems farther down the line ...
Upvotes: 5