diff --git a/matlab/dyn_second_order_solver.m b/matlab/dyn_second_order_solver.m index f4f1f8519..dd2d2bfb8 100644 --- a/matlab/dyn_second_order_solver.m +++ b/matlab/dyn_second_order_solver.m @@ -1,7 +1,7 @@ -function dr = dyn_second_order_solver(jacobia,hessian,dr,M_,threads_ABC,threads_BC) +function dr = dyn_second_order_solver(jacobia,hessian_mat,dr,M_,threads_ABC,threads_BC) %@info: -%! @deftypefn {Function File} {@var{dr} =} dyn_second_order_solver (@var{jacobia},@var{hessian},@var{dr},@var{M_},@var{threads_ABC},@var{threads_BC}) +%! @deftypefn {Function File} {@var{dr} =} dyn_second_order_solver (@var{jacobia},@var{hessian_mat},@var{dr},@var{M_},@var{threads_ABC},@var{threads_BC}) %! @anchor{dyn_second_order_solver} %! @sp 1 %! Computes the second order reduced form of the DSGE model @@ -11,7 +11,7 @@ function dr = dyn_second_order_solver(jacobia,hessian,dr,M_,threads_ABC,threads_ %! @table @ @var %! @item jacobia %! Matrix containing the Jacobian of the model -%! @item hessian +%! @item hessian_mat %! Matrix containing the second order derivatives of the model %! @item dr %! Matlab's structure describing the reduced form solution of the model. @@ -73,7 +73,7 @@ function dr = dyn_second_order_solver(jacobia,hessian,dr,M_,threads_ABC,threads_ kk1 = reshape([1:nk^2],nk,nk); kk1 = kk1(kk,kk); % reordering second order derivatives - hessian = hessian(:,kk1(:)); + hessian_mat = hessian_mat(:,kk1(:)); zx = zeros(np,np); zu=zeros(np,M_.exo_nbr); @@ -91,7 +91,7 @@ function dr = dyn_second_order_solver(jacobia,hessian,dr,M_,threads_ABC,threads_ zu=[zu; eye(M_.exo_nbr);zeros(M_.exo_det_nbr,M_.exo_nbr)]; [nrzx,nczx] = size(zx); - [rhs, err] = sparse_hessian_times_B_kronecker_C(hessian,zx,threads_BC); + [rhs, err] = sparse_hessian_times_B_kronecker_C(hessian_mat,zx,threads_BC); mexErrCheck('sparse_hessian_times_B_kronecker_C', err); rhs = -rhs; @@ -118,7 +118,7 @@ function dr = dyn_second_order_solver(jacobia,hessian,dr,M_,threads_ABC,threads_ %ghxu %rhs hu = dr.ghu(nstatic+1:nstatic+nspred,:); - [rhs, err] = sparse_hessian_times_B_kronecker_C(hessian,zx,zu,threads_BC); + [rhs, err] = sparse_hessian_times_B_kronecker_C(hessian_mat,zx,zu,threads_BC); mexErrCheck('sparse_hessian_times_B_kronecker_C', err); hu1 = [hu;zeros(np-nspred,M_.exo_nbr)]; @@ -136,7 +136,7 @@ function dr = dyn_second_order_solver(jacobia,hessian,dr,M_,threads_ABC,threads_ %ghuu %rhs - [rhs, err] = sparse_hessian_times_B_kronecker_C(hessian,zu,threads_BC); + [rhs, err] = sparse_hessian_times_B_kronecker_C(hessian_mat,zu,threads_BC); mexErrCheck('sparse_hessian_times_B_kronecker_C', err); [B1, err] = A_times_B_kronecker_C(B*dr.ghxx,hu1,threads_ABC); @@ -164,7 +164,7 @@ function dr = dyn_second_order_solver(jacobia,hessian,dr,M_,threads_ABC,threads_ hxx = dr.ghxx(nstatic+[1:nspred],:); [junk,k2a,k2] = find(M_.lead_lag_incidence(M_.maximum_endo_lag+2,order_var)); k3 = nnz(M_.lead_lag_incidence(1:M_.maximum_endo_lag+1,:))+(1:M_.nsfwrd)'; - [B1, err] = sparse_hessian_times_B_kronecker_C(hessian(:,kh(k3,k3)),gu(k2a,:),threads_BC); + [B1, err] = sparse_hessian_times_B_kronecker_C(hessian_mat(:,kh(k3,k3)),gu(k2a,:),threads_BC); mexErrCheck('sparse_hessian_times_B_kronecker_C', err); RHS = RHS + jacobia(:,k2)*guu(k2a,:)+B1; diff --git a/matlab/maximize_prior_density.m b/matlab/maximize_prior_density.m index 131e0422d..72df861a4 100644 --- a/matlab/maximize_prior_density.m +++ b/matlab/maximize_prior_density.m @@ -1,4 +1,4 @@ -function [xparams,lpd,hessian] = ... +function [xparams,lpd,hessian_mat] = ... 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. % @@ -13,7 +13,7 @@ function [xparams,lpd,hessian] = ... % OUTPUTS % xparams [double] vector, prior mode. % lpd [double] scalar, value of the logged prior density at the mode. -% hessian [double] matrix, Hessian matrix at the prior mode. +% hessian_mat [double] matrix, Hessian matrix at the prior mode. % Copyright (C) 2009-2015 Dynare Team % @@ -32,7 +32,7 @@ function [xparams,lpd,hessian] = ... % You should have received a copy of the GNU General Public License % along with Dynare. If not, see . -[xparams, lpd, exitflag, hessian]=dynare_minimize_objective('minus_logged_prior_density', ... +[xparams, lpd, exitflag, hessian_mat]=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, ... diff --git a/matlab/mode_check.m b/matlab/mode_check.m index 180ba3592..0f50ca523 100644 --- a/matlab/mode_check.m +++ b/matlab/mode_check.m @@ -1,8 +1,8 @@ -function mode_check(fun,x,hessian,DynareDataset,DatasetInfo,DynareOptions,Model,EstimatedParameters,BayesInfo,BoundsInfo,DynareResults) +function mode_check(fun,x,hessian_mat,DynareDataset,DatasetInfo,DynareOptions,Model,EstimatedParameters,BayesInfo,BoundsInfo,DynareResults) % Checks the estimated ML mode or Posterior mode. %@info: -%! @deftypefn {Function File} mode_check (@var{fun}, @var{x}, @var{hessian}, @var{DynareDataset}, @var{DynareOptions}, @var{Model}, @var{EstimatedParameters}, @var{BayesInfo}, @var{DynareResults}) +%! @deftypefn {Function File} mode_check (@var{fun}, @var{x}, @var{hessian_mat}, @var{DynareDataset}, @var{DynareOptions}, @var{Model}, @var{EstimatedParameters}, @var{BayesInfo}, @var{DynareResults}) %! @anchor{mode_check} %! @sp 1 %! Checks the estimated ML mode or Posterior mode by plotting sections of the likelihood/posterior kernel. @@ -58,13 +58,13 @@ function mode_check(fun,x,hessian,DynareDataset,DatasetInfo,DynareOptions,Model, % along with Dynare. If not, see . TeX = DynareOptions.TeX; -if ~isempty(hessian); - [ s_min, k ] = min(diag(hessian)); +if ~isempty(hessian_mat); + [ s_min, k ] = min(diag(hessian_mat)); end fval = feval(fun,x,DynareDataset,DatasetInfo,DynareOptions,Model,EstimatedParameters,BayesInfo,BoundsInfo,DynareResults); -if ~isempty(hessian); +if ~isempty(hessian_mat); skipline() disp('MODE CHECK') skipline() diff --git a/matlab/optimize_prior.m b/matlab/optimize_prior.m index a3595d0f6..d5b5e0ac1 100644 --- a/matlab/optimize_prior.m +++ b/matlab/optimize_prior.m @@ -51,7 +51,7 @@ objective_function_penalty_base = minus_logged_prior_density(xinit, BayesInfo.ps BayesInfo.p4,DynareOptions,ModelInfo,EstimationInfo,DynareResults); % Maximization of the prior density -[xparams, lpd, hessian] = ... +[xparams, lpd, hessian_mat] = ... maximize_prior_density(xinit, BayesInfo.pshape, ... BayesInfo.p6, ... BayesInfo.p7, ...