Hi Marco,
I am trying to factorize the mode-finding code to make it reusable in
other parts of Dynare. But I am having a hard time with newrat in
master. The reason is that newrat is the only optimizer that
endogenously changes other options used inside of the objective
function. I would really like to get rid of this behavior as it makes
the generic passing of input arguments to objective functions
impossible. One always needs to make sure that the updated options is
passed.
To be specific, the problem in master derives from the fact that the
analytic Hessian requires options_.kalman_algo to be either 2 or 4. If
this is not the case, newrat sets one of these values. My proposal to
remedy this would be to only allow using newrat without
options_.analytic_derivation when kalman_algo=2 or kalman_algo=4. That
is, when not using analytical derivatives the user must at least specify
a Kalman algo that allows for analytical derivatives. Such a check would
make changing the options redundant. Or do you envision cases where
people want an analytical Hessian based univariate filters while wanting
to compute the likelihood in mode-finding based numerical derivatives
derived from the multivariate Kalman filter.
An additional issue that popped up: currently, newrat with
analytical_derivation seems to be broken for most Kalman algorithms.
Thus, I cannot test the features/changes I propose. I created a pull
request with a unit test for these issues. I attach the files you need
to trace out the errors.
Best,
Johannes