Use new wrapper for optimization algorithms when maximizing the prior density.

time-shift
Stéphane Adjemian (Charybdis) 2015-02-23 18:26:34 +01:00
parent bd39ff34f6
commit fac1d206ab
2 changed files with 8 additions and 13 deletions

View File

@ -1,5 +1,5 @@
function [xparams,lpd,hessian] = ...
maximize_prior_density(iparams, prior_shape, prior_hyperparameter_1, prior_hyperparameter_2, prior_inf_bound, prior_sup_bound,DynareOptions,DynareModel,EstimatedParams,DynareResults)
maximize_prior_density(iparams, prior_shape, prior_hyperparameter_1, prior_hyperparameter_2, prior_inf_bound, prior_sup_bound,DynareOptions,DynareModel,BayesInfo,EstimatedParams,DynareResults)
% Maximizes the logged prior density using Chris Sims' optimization routine.
%
% INPUTS
@ -15,7 +15,7 @@ function [xparams,lpd,hessian] = ...
% lpd [double] scalar, value of the logged prior density at the mode.
% hessian [double] matrix, Hessian matrix at the prior mode.
% Copyright (C) 2009-2012 Dynare Team
% Copyright (C) 2009-2015 Dynare Team
%
% This file is part of Dynare.
%
@ -32,15 +32,10 @@ function [xparams,lpd,hessian] = ...
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
number_of_estimated_parameters = length(iparams);
H0 = 1e-4*eye(number_of_estimated_parameters);
crit = 1e-7;
nit = 1000;
gradient_method = 2;
gradient_epsilon = 1e-6;
[lpd,xparams,grad,hessian,itct,fcount,retcodehat] = ...
csminwel1('minus_logged_prior_density',iparams,H0,[],crit,nit,gradient_method, gradient_epsilon, ...
prior_shape, prior_hyperparameter_1, prior_hyperparameter_2, prior_inf_bound, prior_sup_bound,DynareOptions,DynareModel,EstimatedParams,DynareResults);
[xparams, lpd, exitflag, hessian]=dynare_minimize_objective('minus_logged_prior_density', ...
iparams, DynareOptions.mode_compute, DynareOptions, [prior_inf_bound, prior_sup_bound], ...
BayesInfo.name, BayesInfo, [], ...
prior_shape, prior_hyperparameter_1, prior_hyperparameter_2, prior_inf_bound, prior_sup_bound, ...
DynareOptions,DynareModel,EstimatedParams,DynareResults);
lpd = -lpd;

View File

@ -46,7 +46,7 @@ function [opt_par_values,fval,exitflag,hessian_mat,options_,Scale]=dynare_minimi
%% set bounds and parameter names if not already set
n_params=size(start_par_value,1);
if isempty(bounds)
if minimizer_algorithm==10
if minimizer_algorithm==10
error('Algorithm 10 (simpsa) requires upper and lower bounds')
else
bounds=[-Inf(n_params,1) Inf(n_params,1)];