penalty is now passed as a field of bayestopt_ (or BayesInfo)

time-shift
Michel Juillard 2012-08-02 22:23:29 +02:00
parent 169ab6c28c
commit 6b3bd9dd0b
2 changed files with 4 additions and 30 deletions

View File

@ -35,7 +35,9 @@ function [fval,grad,hess,exit_flag,info,PHI,SIGMAu,iXX,prior] = DsgeVarLikelihoo
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
% Declaration of the persistent variables.
persistent penalty dsge_prior_weight_idx
persistent dsge_prior_weight_idx
penalty = BayesInfo.penalty;
grad=[];
hess=[];
@ -46,16 +48,6 @@ SIGMAu = [];
iXX = [];
prior = [];
% Initialization of the penalty
if ~nargin || isempty(penalty)
penalty = 1e8;
if ~nargin, return, end
end
if nargin==1
penalty = xparam1;
return
end
% Initialization of of the index for parameter dsge_prior_weight in Model.params.
if isempty(dsge_prior_weight_idx)
dsge_prior_weight_idx = strmatch('dsge_prior_weight',Model.param_names);

View File

@ -130,22 +130,7 @@ function [fval,DLIK,Hess,exit_flag,ys,trend_coeff,info,Model,DynareOptions,Bayes
% AUTHOR(S) stephane DOT adjemian AT univ DASH lemans DOT FR
% Declaration of the penalty as a persistent variable.
% Persistent variable 'penalty' is used to compute an endogenous penalty to
% the value 'fval' when various conditions are encountered. These conditions
% set also 'exit_flag' equal to 0 instead of 1. It is only when
% dsge_likelihood() is called by an optimizer called by
% dynare_estimation_1() that 'exit_flag' is ignored and penalized 'fval' is
% actually used.
% In that case, 'penalty' is properly initialized, at the very end of the
% present function, by a call to dsge_likelihood() made in
% initial_estimation_checks(). If a condition triggers exit_flag ==
% 0, initial_estimation_checks() triggers an error.
% In summary, an initial call to the present function, without triggering
% any condition, guarantees that 'penalty' is properly initialized when needed.
persistent penalty
penalty = BayesInfo.penalty;
% Initialization of the returned variables and others...
fval = [];
@ -771,9 +756,6 @@ end
% Update DynareOptions.kalman_algo.
DynareOptions.kalman_algo = kalman_algo;
% Update the penalty.
penalty = fval;
if analytic_derivation==0 && nargout==2,
lik=lik(start:end,:);
DLIK=[-lnprior; lik(:)];