diff --git a/matlab/GetOneDraw.m b/matlab/GetOneDraw.m index 1f3572745..82d4c088f 100644 --- a/matlab/GetOneDraw.m +++ b/matlab/GetOneDraw.m @@ -34,7 +34,7 @@ switch type case 'posterior' [xparams, logpost] = metropolis_draw(0); case 'prior' - xparams = prior_draw(0); + xparams = prior_draw(); if nargout>1 logpost = evaluate_posterior_kernel(xparams'); end diff --git a/matlab/dynare_identification.m b/matlab/dynare_identification.m index 2da320f4c..eed16d931 100644 --- a/matlab/dynare_identification.m +++ b/matlab/dynare_identification.m @@ -149,9 +149,9 @@ options_ident.analytic_derivation_mode = options_.analytic_derivation_mode; if prior_exist if any(bayestopt_.pshape > 0) if options_ident.prior_range - prior_draw(1,1); + prior_draw(bayestopt_, options_.prior_trunc, true); else - prior_draw(1); + prior_draw(bayestopt_, options_.prior_trunc, false); end else options_ident.prior_mc=1; diff --git a/matlab/execute_prior_posterior_function.m b/matlab/execute_prior_posterior_function.m index 378d2237f..7e77a6ae8 100644 --- a/matlab/execute_prior_posterior_function.m +++ b/matlab/execute_prior_posterior_function.m @@ -62,7 +62,7 @@ if strcmpi(type,'posterior') n_draws=options_.sub_draws; prior = false; elseif strcmpi(type,'prior') - prior_draw(1); + prior_draw(bayestopt_, options_.prior_trunc); else error('EXECUTE_POSTERIOR_FUNCTION: Unknown type!') end diff --git a/matlab/prior_draw.m b/matlab/prior_draw.m index 11e0f8731..9e49f8d36 100644 --- a/matlab/prior_draw.m +++ b/matlab/prior_draw.m @@ -1,4 +1,4 @@ -function pdraw = prior_draw(init,uniform) % --*-- Unitary tests --*-- +function pdraw = prior_draw(BayesInfo, prior_trunc, uniform) % --*-- Unitary tests --*-- % This function generate one draw from the joint prior distribution and % allows sampling uniformly from the prior support (uniform==1 when called with init==1) @@ -47,19 +47,19 @@ persistent p6 p7 p3 p4 lb ub persistent uniform_index gaussian_index gamma_index beta_index inverse_gamma_1_index inverse_gamma_2_index weibull_index persistent uniform_draws gaussian_draws gamma_draws beta_draws inverse_gamma_1_draws inverse_gamma_2_draws weibull_draws -if nargin>0 && init - p6 = evalin('base', 'bayestopt_.p6'); - p7 = evalin('base', 'bayestopt_.p7'); - p3 = evalin('base', 'bayestopt_.p3'); - p4 = evalin('base', 'bayestopt_.p4'); - bounds = evalin('base', 'prior_bounds(bayestopt_, options_.prior_trunc)'); +if nargin>0 + p6 = BayesInfo.p6; + p7 = BayesInfo.p7; + p3 = BayesInfo.p3; + p4 = BayesInfo.p4; + bounds = prior_bounds(BayesInfo, prior_trunc); lb = bounds.lb; ub = bounds.ub; number_of_estimated_parameters = length(p6); - if nargin>1 && uniform + if nargin>2 && uniform prior_shape = repmat(5,number_of_estimated_parameters,1); else - prior_shape = evalin('base', 'bayestopt_.pshape'); + prior_shape = BayesInfo.pshape; end beta_index = find(prior_shape==1); if isempty(beta_index) diff --git a/matlab/prior_sampler.m b/matlab/prior_sampler.m index 87ffe449f..9e525709b 100644 --- a/matlab/prior_sampler.m +++ b/matlab/prior_sampler.m @@ -31,7 +31,7 @@ function results = prior_sampler(drsave,M_,bayestopt_,options_,oo_,estim_params_ % along with Dynare. If not, see . % Initialization. -prior_draw(1); +prior_draw(bayestopt_, options_.prior_trunc); PriorDirectoryName = CheckPath('prior/draws',M_.dname); work = ~drsave; iteration = 0;