I see this code snippet suggested in the performance vignette: https://cran.r-project.org/web/packages/lme4/vignettes/lmerperf.html nlopt <- function(par, fn, lower, upper, control) { *.nloptr <<-* res <- nloptr(par, fn, lb = lower, ub = upper, opts = list(algorithm = "NLOPT_LN_BOBYQA", print_level = 1, maxeval = 1000, xtol_abs = 1e-6, ftol_abs = 1e-6)) list(par = res$solution, fval = res$objective, conv = if (res$status > 0) 0 else res$status, message = res$message ) } That's writing an .nloptr object to .GlobalEnv (usually), but there's no mention of why and I don't see any usage of this object anywhere else in the code base: grep -Fr ".nloptr" lme4/R Am I missing something? Mike C
Purpose of .nloptr object?
3 messages · Michael Chirico, Phillip Alday, Ben Bolker
This seems to be the docs getting slightly out of date in some sections (as happens with any big piece of software). The actual nloptwrap function in lme4 (now the default optimizer, IIRC) doesn't include that: https://github.com/lme4/lme4/blob/c3d0c643d444785fad5e554380c028706f14e274/R/utilities.R#L1151-L1169 A wild guess on my part (until Ben Bolker has a few): that code was there to debug writing a wrapper / show how you can further examine the return value from nloptr to get more information and got left in, even once the further debugging/examination was removed from the example. Phillip
On 08/06/2021 14:19, Michael Chirico via R-sig-mixed-models wrote:
I see this code snippet suggested in the performance vignette: https://cran.r-project.org/web/packages/lme4/vignettes/lmerperf.html nlopt <- function(par, fn, lower, upper, control) { *.nloptr <<-* res <- nloptr(par, fn, lb = lower, ub = upper, opts = list(algorithm = "NLOPT_LN_BOBYQA", print_level = 1, maxeval = 1000, xtol_abs = 1e-6, ftol_abs = 1e-6)) list(par = res$solution, fval = res$objective, conv = if (res$status > 0) 0 else res$status, message = res$message ) } That's writing an .nloptr object to .GlobalEnv (usually), but there's no mention of why and I don't see any usage of this object anywhere else in the code base: grep -Fr ".nloptr" lme4/R Am I missing something? Mike C [[alternative HTML version deleted]]
_______________________________________________ R-sig-mixed-models at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
Yes, that's probably it.
I should look into updating that vignette anyway (it would be good to
run the machinery and cache some timings to be included in the text).
cheers
Ben
On 6/8/21 7:47 PM, Phillip Alday wrote:
This seems to be the docs getting slightly out of date in some sections (as happens with any big piece of software). The actual nloptwrap function in lme4 (now the default optimizer, IIRC) doesn't include that: https://github.com/lme4/lme4/blob/c3d0c643d444785fad5e554380c028706f14e274/R/utilities.R#L1151-L1169 A wild guess on my part (until Ben Bolker has a few): that code was there to debug writing a wrapper / show how you can further examine the return value from nloptr to get more information and got left in, even once the further debugging/examination was removed from the example. Phillip On 08/06/2021 14:19, Michael Chirico via R-sig-mixed-models wrote:
I see this code snippet suggested in the performance vignette: https://cran.r-project.org/web/packages/lme4/vignettes/lmerperf.html nlopt <- function(par, fn, lower, upper, control) { *.nloptr <<-* res <- nloptr(par, fn, lb = lower, ub = upper, opts = list(algorithm = "NLOPT_LN_BOBYQA", print_level = 1, maxeval = 1000, xtol_abs = 1e-6, ftol_abs = 1e-6)) list(par = res$solution, fval = res$objective, conv = if (res$status > 0) 0 else res$status, message = res$message ) } That's writing an .nloptr object to .GlobalEnv (usually), but there's no mention of why and I don't see any usage of this object anywhere else in the code base: grep -Fr ".nloptr" lme4/R Am I missing something? Mike C [[alternative HTML version deleted]]
_______________________________________________ R-sig-mixed-models at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
_______________________________________________ R-sig-mixed-models at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models