1
$\begingroup$

Issue: Do constrained optimization of parameters in nlme::nlme

I'm trying to fit a non-linear mixed effects model using nlme::nlme, which can use 2 optimization schemes: stats::nlminb or stats::nlm.

I want to do constrained optimization, so I choose to use nlminb. In the documentation of nlminb two arguments are needed in order to do so: upper = c(..), lower = c(..).

However, nlme passes only certain control values to nlminb and unfortunately the ones I need are not among them. Below is a small copy/paste from the nlme code, which shows the vector "keep", that defines what arguments to be passed to nlminb.

I would be grateful if someone could answer my questions:

  • Is there a good workaround to this problem?
  • Is there a reason why nlme does not want to have bounded optimization in their package? It seems intentionally left out.

Solutions found online:

I can see other people have this question as well and suggestions like transforming the parameters manually are given. But it would just be very nice if constrained optimization in nlminb could be used with the build in function, since it has the feature implemented... (http://blackwell.math.yorku.ca/georges/pub/lme/0102.html, https://stackoverflow.com/questions/11962492/limits-on-nlme-regression)

Sample from the nlme code line 573 - 583

if (controlvals$opt == "nlminb") { control <- list(trace = controlvals$msVerbose, iter.max = controlvals$msMaxIter) keep <- c("eval.max", "abs.tol", "rel.tol", "x.tol", "xf.tol", "step.min", "step.max", "sing.tol", "scale.init", "diff.g") control <- c(control, controlvals[names(controlvals) %in% keep]) optRes <- nlminb(c(coef(nlmeSt)), function(nlmePars) -logLik(nlmeSt, nlmePars), control = control) ...

$\endgroup$

1 Answer 1

0
$\begingroup$

Unfortunately, it has been 6 years, and still no way to constraint parameters for nlme. Unless there is a way I am unaware of but for now transformations seem to be the only work around.Either that or dropping the random effects and running an nls model.

New contributor
Adam Sharifi is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
$\endgroup$
3
  • $\begingroup$ Or hacking the code? I have a repo here that I could bring up to date and provide a modified version ... it may be worth opening a bug report at R-bugzilla if you're still interested (or I could, if you don't have access and don't feel like requesting it) $\endgroup$
    – Ben Bolker
    Commented Dec 11 at 1:49
  • $\begingroup$ As an aside I’ve been studying nlminb and nlm in a simpler setting of logistic regression. nlminb has excellent performance but nlm doesn’t. fharrell.com/post/mle. My frustration with nlminb is the difficulty of specifying a simple tolerance for the absolute change in the objective function (-2 LL). $\endgroup$ Commented Dec 11 at 11:51
  • $\begingroup$ Thank you both for the updates. I am fairly new to R so your suggestions are very helpful. As Ben suggested, I might just go about modifying the code myself to build my own modified nlme R package that would allow these upper and lower arguments to be passed along to nlminb(). That seems to be the only viable option currently. $\endgroup$ Commented Dec 12 at 17:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.