kaskr / TMB_contrib_R

9 stars 6 forks source link

opt returns NULL if unconverged, and fails randomregression example #13

Open mkapur opened 3 years ago

mkapur commented 3 years ago

I updated to R v4.0.3 and updating my packages to run TMBhelper v1.3.0, and TMB v1.7.18. I am working with a non-converged model, but noticed that when I run TMBhelper::fit_tmb, the unconverged model returns NULL in the $opt spot.

I wanted to test if this was based on its non-convergence, so ran the following after a restart + workspace clear:

library(TMB)
runExample('randomregression') ## loads example obj into env
opt <-TMBhelper::fit_tmb(obj)$opt

which returned, after a few dozen mgc evals:

Error in sqrt(unlist(tmp)) : 
  non-numeric argument to mathematical function

As a workaround I am presently able to get $opt from nlminb() using my unconverged value, but wanted to flag this since it seems to be more than just my own model. I recognize that the above issues might be two separate problems, and the unconverged-model-fail might be a new feature. Thanks for your help.

James-Thorson-NOAA commented 3 years ago

I think results from the issue I reported to TMB (https://github.com/kaskr/adcomp/issues/333), but I'd love some help confirming and diagnosing a solution.