Closed perrydv closed 5 months ago
@perrydv I agree that last.best makes sense as a default. That's fine to do. The new updates I've done won't be impacted by that. I've just given the user more control to choose other options which just is done by some functions that update that default option.
Do not merge. I will attempt to combine this branch with AGHQ_updated
.
I am closing this PR because this work is being brought in through #1455.
We have been having issues from the quality of inner optimization in Laplace approximation.
This PR includes changes to
nimOptim
and tobuildLaplace
.For
nimOptim
:A new system for having compiled
nimOptim
call back to R to run an arbitrary optimizer, whose function, gradient, and/or hessian call back into compiled C++. The system usesnimOptimMethod(<method name>, <method function>)
to register a method. Support fornlminb
is provided using this system. Minor changes to documentation include bits inhelp(nimOptim)
and also the User Manual. Both describe this new feature only briefly and state that is it subject to change in future versions.This does change
nimOptim
so that it accepts anhe
(Hessian calculator) function, making it less similar to R'soptim
.Uncompiled
nimOptim
will also allowmethod
to be outside of the usualoptim
choices and if found package up appropriate functions to call an optimizer registered vianimOptimMethod
.test-optim
was updated to includenlminb
andmy_nlminb
(same but entered as if a user was doing it) in the list of samplers for all tests. A small amount of new testing was added.For
Laplace
:nlminb
was set as default for both inner and outer optimization.test-ADlaplace
was updated, primarily to tweak tolerances where needed. It was observed that some tolerances could be reduced, but I did not systematically check and do so. Other tolerances needed to be loosened. I primarily interpreted this as noise, because values checked were still close enough to be comfortable and there could be "accidents" of one method or another landing more precisely on an arg max. OTOH a few tolerances were newly uncomfortably large (e.g. 0.05 for values of order 1.0) and these were on standard errors. I determined one case (crossed random effects LME) where a fine-scale walk over the llh max was not as smooth as needed for good finite different Hessians. I tried changing to the "last.best" mode of initialization for inner optimizations, and that helped substantially.I wonder if we should change default for
innerOptimStart
to "last.best". But I have not modified it because I know @paul-vdb is working separately on this.