explicit initialization of persistent variables in priordens.m

time-shift
Michel Juillard 2010-02-06 14:43:16 +01:00
parent 2956e87339
commit 84aae713a6
2 changed files with 16 additions and 13 deletions

View File

@ -1,19 +1,20 @@
function logged_prior_density = priordens(x, pshape, p6, p7, p3, p4)
function logged_prior_density = priordens(x, pshape, p6, p7, p3, p4,initialization)
% Computes a prior density for the structural parameters of DSGE models
%
% INPUTS
% x [double] vector with n elements.
% pshape [integer] vector with n elements (bayestopt_.pshape).
% p6: [double] vector with n elements, first parameter of the prior distribution (bayestopt_.p6).
% p7: [double] vector with n elements, second parameter of the prior distribution (bayestopt_.p7).
% p3: [double] vector with n elements, lower bounds.
% p4: [double] vector with n elements, upper bound.
% x [double] vector with n elements.
% pshape [integer] vector with n elements (bayestopt_.pshape).
% p6: [double] vector with n elements, first parameter of the prior distribution (bayestopt_.p6).
% p7: [double] vector with n elements, second parameter of the prior distribution (bayestopt_.p7).
% p3: [double] vector with n elements, lower bounds.
% p4: [double] vector with n elements, upper bound.
% initialization [integer] if 1: initialize persistent variables
%
% OUTPUTS
% logged_prior_density [double] scalar, log of the prior density evaluated at x.
%
% Copyright (C) 2003-2009 Dynare Team
% Copyright (C) 2003-2010 Dynare Team
%
% This file is part of Dynare.
%
@ -30,12 +31,10 @@ function logged_prior_density = priordens(x, pshape, p6, p7, p3, p4)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
persistent pflag
persistent id1 id2 id3 id4 id5 id6
persistent tt1 tt2 tt3 tt4 tt5 tt6
if isempty(pflag)
Number0fParameters = length(pshape);
if nargin > 6 && initialization == 1
% Beta indices.
tt1 = 1;
id1 = find(pshape==1);

View File

@ -18,7 +18,7 @@ function [xparam1, estim_params_, bayestopt_, lb, ub, M_]=set_prior(estim_params
% SPECIAL REQUIREMENTS
% None
% Copyright (C) 2003-2009 Dynare Team
% Copyright (C) 2003-2010 Dynare Team
%
% This file is part of Dynare.
%
@ -261,4 +261,8 @@ if exist([ M_.dname '/prior/definition.mat'])
end
else
save([M_.dname '/prior/definition.mat'],'bayestopt_');
end
end
% initialize persistent variables in priordens()
priordens(xparam1,bayestopt_.pshape,bayestopt_.p6,bayestopt_.p7, ...
bayestopt_.p3,bayestopt_.p4,1);