From 27622a29da9163d707d750f03bef951f4ae4f6af Mon Sep 17 00:00:00 2001 From: Johannes Pfeifer Date: Sat, 6 Jun 2015 17:40:37 +0200 Subject: [PATCH] Fix initialization of parameter bounds for ML case in stab_map_.m --- matlab/gsa/prior_draw_gsa.m | 19 +++++++++++++++---- matlab/gsa/stab_map_.m | 2 +- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/matlab/gsa/prior_draw_gsa.m b/matlab/gsa/prior_draw_gsa.m index 9c6b2cb16..5dc30b79f 100644 --- a/matlab/gsa/prior_draw_gsa.m +++ b/matlab/gsa/prior_draw_gsa.m @@ -42,7 +42,7 @@ function pdraw = prior_draw_gsa(init,rdraw) % You should have received a copy of the GNU General Public License % along with Dynare. If not, see . -global bayestopt_ options_ +global bayestopt_ options_ estim_params_ M_ persistent npar pshape p6 p7 p3 p4 lbcum ubcum if init @@ -55,7 +55,18 @@ if init pdraw = zeros(npar,1); lbcum = zeros(npar,1); ubcum = ones(npar,1); - bounds = prior_bounds(bayestopt_,options_); + [junk1,junk2,junk3,lb,ub,junk4] = set_prior(estim_params_,M_,options_); %Prepare bounds + if ~isempty(bayestopt_) && any(bayestopt_.pshape > 0) + % Set prior bounds + bounds = prior_bounds(bayestopt_,options_); + bounds.lb = max(bounds.lb,lb); + bounds.ub = min(bounds.ub,ub); + else % estimated parameters but no declared priors + % No priors are declared so Dynare will estimate the model by + % maximum likelihood with inequality constraints for the parameters. + bounds.lb = lb; + bounds.ub = ub; + end % set bounds for cumulative probabilities for i = 1:npar switch pshape(i) @@ -63,8 +74,8 @@ if init p4(i) = min(p4(i),bounds.ub(i)); p3(i) = max(p3(i),bounds.lb(i)); case 3% Gaussian prior. - lbcum(i) = 0.5 * erfc(-(bounds.lb(i)-p6(i))/p7(i) ./ sqrt(2));; - ubcum(i) = 0.5 * erfc(-(bounds.ub(i)-p6(i))/p7(i) ./ sqrt(2));; + lbcum(i) = 0.5 * erfc(-(bounds.lb(i)-p6(i))/p7(i) ./ sqrt(2)); + ubcum(i) = 0.5 * erfc(-(bounds.ub(i)-p6(i))/p7(i) ./ sqrt(2)); case 2% Gamma prior. lbcum(i) = gamcdf(bounds.lb(i)-p3(i),p6(i),p7(i)); ubcum(i) = gamcdf(bounds.ub(i)-p3(i),p6(i),p7(i)); diff --git a/matlab/gsa/stab_map_.m b/matlab/gsa/stab_map_.m index 7803998a8..7be2d9f66 100644 --- a/matlab/gsa/stab_map_.m +++ b/matlab/gsa/stab_map_.m @@ -162,7 +162,7 @@ if fload==0, end end % try -% dummy=prior_draw_gsa(1); + dummy=prior_draw_gsa(1); %initialize persistent variables % catch % if pprior, % if opt_gsa.prior_range==0;