From dac5a30a97c3a9c702f8ec2004310ab1bab83b3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Karam=C3=A9?= <frederic.karame@univ-lemans.fr> Date: Sat, 25 May 2024 11:34:20 +0200 Subject: [PATCH] online estimation: bug fixes for the coherency of functions calls. --- matlab/estimation/dynare_estimation_1.m | 7 +++++-- matlab/nonlinear-filters/online_auxiliary_filter.m | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/matlab/estimation/dynare_estimation_1.m b/matlab/estimation/dynare_estimation_1.m index a1a0103928..d291f9388d 100644 --- a/matlab/estimation/dynare_estimation_1.m +++ b/matlab/estimation/dynare_estimation_1.m @@ -238,8 +238,11 @@ if ~isequal(options_.mode_compute,0) && ~options_.mh_posterior_mode_estimation & optimizer_vec = [options_.mode_compute;num2cell(options_.additional_optimizer_steps)]; for optim_iter = 1:length(optimizer_vec) current_optimizer = optimizer_vec{optim_iter}; - - [xparam1, fval, ~, hh, options_, Scale, new_rat_hess_info] = dynare_minimize_objective(objective_function,xparam1,current_optimizer,options_,[bounds.lb bounds.ub],bayestopt_.name,bayestopt_,hh,dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,bounds,oo_.dr, oo_.steady_state,oo_.exo_steady_state,oo_.exo_det_steady_state); + if current_optimizer~=11 + [xparam1, fval, ~, hh, options_, Scale, new_rat_hess_info] = dynare_minimize_objective(objective_function,xparam1,current_optimizer,options_,[bounds.lb bounds.ub],bayestopt_.name,bayestopt_,hh,dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,bounds,oo_.dr, oo_.steady_state,oo_.exo_steady_state,oo_.exo_det_steady_state); + else + [xparam1, fval, ~, hh, options_, Scale, new_rat_hess_info] = dynare_minimize_objective(objective_function,xparam1,current_optimizer,options_,[bounds.lb bounds.ub],bayestopt_.name,bayestopt_,hh,dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,bounds,oo_); + end fprintf('\nFinal value of minus the log posterior (or likelihood):%f \n', fval); if isnumeric(current_optimizer) diff --git a/matlab/nonlinear-filters/online_auxiliary_filter.m b/matlab/nonlinear-filters/online_auxiliary_filter.m index 62634eeccf..1c98b2bd38 100644 --- a/matlab/nonlinear-filters/online_auxiliary_filter.m +++ b/matlab/nonlinear-filters/online_auxiliary_filter.m @@ -39,7 +39,7 @@ function [pmean, pmode, pmedian, pstdev, p025, p975, covariance] = online_auxili % along with Dynare. If not, see <https://www.gnu.org/licenses/>. % Set seed for randn(). -options_=set_dynare_seed_local_options(options_,'default'); +options_ = set_dynare_seed_local_options(options_,'default'); pruning = options_.particle.pruning; second_resample = options_.particle.resampling.status.systematic; variance_update = true; @@ -86,7 +86,7 @@ for i=1:number_of_particles info = 12042009; while info candidate = Prior.draw(); - [info, M_, options_, oo_] = solve_model_for_online_filter(false, xparam1, dataset_, options_, M_, estim_params_, bayestopt_, bounds, oo_); + [info, M_, options_, oo_] = solve_model_for_online_filter(false, candidate, dataset_, options_, M_, estim_params_, bayestopt_, bounds, oo_); if ~info xparam(:,i) = candidate(:); end -- GitLab