diff --git a/matlab/DsgeVarLikelihood.m b/matlab/DsgeVarLikelihood.m index 840842cef..c00c4e92c 100644 --- a/matlab/DsgeVarLikelihood.m +++ b/matlab/DsgeVarLikelihood.m @@ -35,7 +35,9 @@ function [fval,grad,hess,exit_flag,info,PHI,SIGMAu,iXX,prior] = DsgeVarLikelihoo % along with Dynare. If not, see . % 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); diff --git a/matlab/dsge_likelihood.m b/matlab/dsge_likelihood.m index 3629c9e50..245eb66fd 100644 --- a/matlab/dsge_likelihood.m +++ b/matlab/dsge_likelihood.m @@ -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(:)];