diff --git a/matlab/GetOneDraw.m b/matlab/GetOneDraw.m index 1f3572745673e56d4c440333bd65c624fdc81550..82d4c088fa04f0b195c98f5aa89c389a096b7d13 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 2da320f4cba90e55ab71aac07ae136ffb8df55d8..eed16d9314ad2e4ee7a69a519da67831460554c4 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 378d2237fb0e0112d2aa5d26bc4c39ae8f184f69..7e77a6ae8490fa4e6302d4ec03de0c6608b91aa3 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 11e0f87312ddd84213e7852f2b6fb253527639e8..9e49f8d3685d140c73d57ff6444c188ef6e92fa9 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 87ffe449f1cd83cbc09abd6177930c9137a1fa89..9e525709b288607775566dcbee96665bea5ae87e 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 <http://www.gnu.org/licenses/>. % Initialization. -prior_draw(1); +prior_draw(bayestopt_, options_.prior_trunc); PriorDirectoryName = CheckPath('prior/draws',M_.dname); work = ~drsave; iteration = 0;