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 -- Marco Ratto, Financial and Economic Analysis Joint Research Centre The European Commission, TP 361, 21027 ISPRA(VA), ITALY Tel: +39 0332 78 3794 Fax: +39 0332 78 5752, marco.ratto@jrc.ec.europa.eu <marco.ratto@jrc.ec.europa.eu> http://www.macfinrobods.eu/ On 9/20/2015 2:44 PM, Michel Juillard wrote:
Dear Marco,
I'm trying to remove global variable objective_function_penalty_base that is used by mode_compute 4 and 5.
Doing that, I remarked things that I don't understand concerning mode_compute 5 in master:
1) in ./matlab/optimization/dynare_minimize_objective.m, newrat() is called on line 247 with the 6th input argument set to zero. My guess is that it should be newflagrat, otherwise I don't understand what newflgrat is used for. In any case, the current behavior and results seem different from what we had in the stable version
2) looking at the code in ./matlab/optimization/newrat.m, I understand that the final value of the hessian is computed at the end of this function according to user's options. I don't understand the reason for the code in ./matlab/dynare_estimation_1. lines 262-288
3) Is it necessary for newrat() to reset options_.analytic_derivation and have ./matlab/dynare_estimation_1.m lines 241-242?
My impression is that we have changed the code without fully understanding how newrat.m is working.
Best