Alternative optimization algorithms for lmer

喜欢而已 提交于 2021-02-08 06:17:19

问题


The function lmer in the lme4 package uses by default bobyqa from the minqa package as optimization algorithm.

According to the following post https://stat.ethz.ch/pipermail/r-sig-mixed-models/2013q1/020075.html, it is possible to use also the other optimization algorirthms in the minqa package

How can one use uobyqa or newuoa as optimization algorithm for lmer?

library(lme4)
fm1 <- lmer(Reaction ~ Days + (Days | Subject), sleepstudy, control=lmerControl(optimizer="bobyqa"))

回答1:


You can't use newuoa nor uobyqa because neither allows for constraints on the parameters. From ?lmerControl (emphasis added)

Any minimizing function that allows box constraints can be used provided that it

(1) takes input parameters ‘fn’ (function to be optimized), ‘par’ (starting parameter values), ‘lower’ (lower bounds) and ‘control’ (control parameters, passed through from the ‘control’ argument) and

(2) returns a list with (at least) elements ‘par’ (best-fit parameters), ‘fval’ (best-fit function value), ‘conv’ (convergence code, equal to zero for successful convergence) and (optionally) ‘message’ (informational message, or explanation of convergence failure).

The b at the beginning of "bobyqa" stands for "bound" (as in constrained), I assume the u in the other algorithms similarly stands for "unconstrained". You can check out this file for some machinery to (re)fit the same model with a bunch of different optimizers:

allFit <- system.file("utils", "allFit.R", package="lme4")
file.show(allFit)

The list of all optimizers I currently know about that allow box constraints and don't require an explicit gradient function to be specified (required for most of the bound-constrained optimizers in the optimx package), as shown in the file above, is

  • BOBYQA (minqa and nloptr package implementations)
  • Nelder-Mead (lme4, nloptr, and dfoptim package implementations)
  • nlminb from base R (from the Bell Labs PORT library)
  • L-BFGS-B from base R, via optimx (Broyden-Fletcher-Goldfarb-Shanno, via Nash)

In addition to these, which are built in to allFit.R, you can use the COBYLA or subplex optimizers from nloptr: see ?nloptwrap. There's another implementation of subplex in the subplex package: there may be a few others I've missed.



来源:https://stackoverflow.com/questions/25142457/alternative-optimization-algorithms-for-lmer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!