adcomp
adcomp copied to clipboard
Automatic detection of numerical overflow?
Hi all,
I have a model where I'm reasonably sure that I've diagnosed the following problem. Namely, this model (and others I've seen) given a certain configuration would end up with the final gradient from nlminb optimization going to absurdly high values (10^10 and such). In my experience, this occurs when the inner-optimization fails for some proposals near the final value (i.e. the inner optimizer throws a warning message about not converging during some proposals during Nelder-Mead explorations, but where this doesn't happen during the call to the gradient, which appears to crash nlminb). The problem went away when I changed the model to be less prone to numerical overflow (i.e., by simplifying slightly, such that instead of exponentiating a predicted value, calculating the likelihood, and then taking the log of the likelihood, I could calculate the log-likelihood directly).
So this leads to several questions:
- Is there any way to directly check whether I have a numerical overflow, i.e., a function to call on the objective function to detect these instances?
- Is it possible to build numerical overflow detection into the MakeADFun function call? This issue can sometimes be subtle (given unbounded exploration of random effects), so I recommend a generic warning message by default.
I welcome any thoughts, jim
Hi Jim,
Regarding 1) you can trap overflow in the debugger (gdb) if you are using linux:
http://folk.uib.no/hsk021/tmbdoc/group__Errors.html
(section Floating point execption)
Unfortunately gdb only work under linux with the current TMB setup. It is highly recommended to have access to a linux server with TMB installed solely for the purpose of being able to run the debugger.
Hans