Dear Michel,
I think the code is OK without your changes, but indeed I changed the behaviour of the code w.r.t. stable version.
Let me try to explain:
1) indeed the 6th input argument in newrat triggers how the hessian is computed in the final step.
However, I realized that this is not the optimal way to go, so in dynare_minimize_objective this is better forced to be zero. The point is that with argument 0 (or 1) the best way to compute outer product gradient is with univarite kalman filter, since it maximizes the number of density points used in outer product. However, when as usual multivariate filter is used for estimation, this would imply to change kalman_algo from within optimizer which is not a good thing to do. So, it is best to force zero in optimization. This implies in practice no extra computation in newrat. Then, in dynare_estimation_1.m, the need for that piece of code you mention at point 2). If newratflag = 0 and univariate filter was already used, nothing is done, and no further hessian computation is performed. If multivariate filter was used, then outer product gradient is re-done using univariate algorithm. Then, it seems also OK for me to trigger there full hessian computation with mr_hessian using newratflag=2 [although I must say I never do that].
2) as discussed in point 1), newratflag is indeed an option that triggers how the hessian in newrat is computed in place of the standard dynare one, but it needs to be used in
./matlab/dynare_estimation_1. lines 262-288
and not in
./matlab/optimization/dynare_minimize_objective.m
essentially linked to univariate kalman filter use in outer product gradient
3) I think re-setting analytic_derivative can be useful for subsequent computation, in order not to change options_ w.r.t. the user had set in the estimation() command.
thanks a lot best Marco