From 217de5084c7800d39c640ea0169b3b74b6c7f95b Mon Sep 17 00:00:00 2001 From: Johannes Pfeifer Date: Wed, 2 Feb 2022 16:20:12 +0100 Subject: [PATCH] check_posterior_sampler_options: make global variable an input Does not properly work for scale_file-option as caller has variable not global --- matlab/check_posterior_sampler_options.m | 12 +++++++----- matlab/dynare_estimation_1.m | 2 +- matlab/dynare_estimation_init.m | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/matlab/check_posterior_sampler_options.m b/matlab/check_posterior_sampler_options.m index 2f7a80b82..3d8548693 100644 --- a/matlab/check_posterior_sampler_options.m +++ b/matlab/check_posterior_sampler_options.m @@ -1,19 +1,23 @@ -function [posterior_sampler_options, options_] = check_posterior_sampler_options(posterior_sampler_options, options_, bounds) +function [posterior_sampler_options, options_, bayestopt_] = check_posterior_sampler_options(posterior_sampler_options, options_, bounds, bayestopt_) -% function [posterior_sampler_options, options_] = check_posterior_sampler_options(posterior_sampler_options, options_, bounds) +% function [posterior_sampler_options, options_, bayestopt_] = check_posterior_sampler_options(posterior_sampler_options, options_, bounds, bayestopt_) % initialization of posterior samplers % % INPUTS % posterior_sampler_options: posterior sampler options % options_: structure storing the options +% bounds: structure containing prior bounds +% bayestopt_: structure storing information about priors % OUTPUTS % posterior_sampler_options: checked posterior sampler options +% options_: structure storing the options +% bayestopt_: structure storing information about priors % % SPECIAL REQUIREMENTS % none -% Copyright (C) 2015-2017 Dynare Team +% Copyright (C) 2015-2022 Dynare Team % % This file is part of Dynare. % @@ -86,7 +90,6 @@ if init % will overwrite jscale from set_prior.m if exist(options_list{i,2},'file') || exist([options_list{i,2},'.mat'],'file') tmp = load(options_list{i,2},'Scale'); - global bayestopt_ bayestopt_.mh_jscale = tmp.Scale; options_.mh_jscale = tmp.Scale; bayestopt_.jscale = ones(size(bounds.lb,1),1)*tmp.Scale; @@ -152,7 +155,6 @@ if init % will overwrite jscale from set_prior.m if exist(options_list{i,2},'file') || exist([options_list{i,2},'.mat'],'file') tmp = load(options_list{i,2},'Scale'); - global bayestopt_ bayestopt_.mh_jscale = tmp.Scale; options_.mh_jscale = tmp.Scale; bayestopt_.jscale = ones(size(bounds.lb,1),1)*tmp.Scale; diff --git a/matlab/dynare_estimation_1.m b/matlab/dynare_estimation_1.m index 20f16b473..7488fe21a 100644 --- a/matlab/dynare_estimation_1.m +++ b/matlab/dynare_estimation_1.m @@ -465,7 +465,7 @@ if (any(bayestopt_.pshape >0 ) && options_.mh_replic) || ... if options_.mh_replic || options_.load_mh_file posterior_sampler_options = options_.posterior_sampler_options.current_options; posterior_sampler_options.invhess = invhess; - [posterior_sampler_options, options_] = check_posterior_sampler_options(posterior_sampler_options, options_); + [posterior_sampler_options, options_, bayestopt_] = check_posterior_sampler_options(posterior_sampler_options, options_, bounds, bayestopt_); % store current options in global options_.posterior_sampler_options.current_options = posterior_sampler_options; if options_.mh_replic diff --git a/matlab/dynare_estimation_init.m b/matlab/dynare_estimation_init.m index 5f0af2dbd..d2e8f099e 100644 --- a/matlab/dynare_estimation_init.m +++ b/matlab/dynare_estimation_init.m @@ -649,7 +649,7 @@ if options_.load_results_after_load_mh end if options_.mh_replic || options_.load_mh_file - [current_options, options_] = check_posterior_sampler_options([], options_, bounds); + [current_options, options_, bayestopt_] = check_posterior_sampler_options([], options_, bounds, bayestopt_); options_.posterior_sampler_options.current_options = current_options; end