Commit be758613 authored by Marco Ratto's avatar Marco Ratto
Browse files

fixed bugs that prevented the computation of the asymptotic Hessian with ML.

parent 25120e54
......@@ -147,7 +147,7 @@ options_ = set_default_option(options_,'datafile','');
options_.mode_compute = 0;
options_.plot_priors = 0;
options_.smoother=1;
[dataset_,dataset_info,xparam1,hh, M_, options_, oo_, estim_params_,bayestopt_]=dynare_estimation_init(M_.endo_names,fname_,1, M_, options_, oo_, estim_params_, bayestopt_);
[dataset_,dataset_info,xparam1,hh, M_, options_, oo_, estim_params_,bayestopt_,bounds]=dynare_estimation_init(M_.endo_names,fname_,1, M_, options_, oo_, estim_params_, bayestopt_);
options_ident = set_default_option(options_ident,'analytic_derivation_mode',options_.analytic_derivation_mode); % if not set by user, inherit default global one
if prior_exist
......@@ -310,7 +310,7 @@ if iload <=0,
disp('Testing current parameter values')
end
[idehess_point, idemoments_point, idemodel_point, idelre_point, derivatives_info_point, info, options_ident] = ...
identification_analysis(params,indx,indexo,options_ident,dataset_, dataset_info, prior_exist, name_tex,1,parameters);
identification_analysis(params,indx,indexo,options_ident,dataset_, dataset_info, prior_exist, name_tex,1,parameters,bounds);
if info(1)~=0,
skipline()
disp('----------- ')
......@@ -353,7 +353,7 @@ if iload <=0,
kk=kk+1;
params = prior_draw();
[idehess_point, idemoments_point, idemodel_point, idelre_point, derivatives_info_point, info, options_ident] = ...
identification_analysis(params,indx,indexo,options_ident,dataset_,dataset_info, prior_exist, name_tex,1,'Random_prior_params');
identification_analysis(params,indx,indexo,options_ident,dataset_,dataset_info, prior_exist, name_tex,1,'Random_prior_params',bounds);
end
end
if info(1)
......@@ -407,7 +407,7 @@ if iload <=0,
params = prior_draw();
end
[dum1, ideJ, ideH, ideGP, dum2 , info, options_MC] = ...
identification_analysis(params,indx,indexo,options_MC,dataset_, dataset_info, prior_exist, name_tex,0);
identification_analysis(params,indx,indexo,options_MC,dataset_, dataset_info, prior_exist, name_tex,0,[],bounds);
if iteration==0 && info(1)==0,
MAX_tau = min(SampleSize,ceil(MaxNumberOfBytes/(size(ideH.siH,1)*nparam)/8));
stoH = zeros([size(ideH.siH,1),nparam,MAX_tau]);
......
function [ide_hess, ide_moments, ide_model, ide_lre, derivatives_info, info, options_ident] = identification_analysis(params,indx,indexo,options_ident,dataset_,dataset_info, prior_exist,name_tex,init,tittxt)
function [ide_hess, ide_moments, ide_model, ide_lre, derivatives_info, info, options_ident] = identification_analysis(params,indx,indexo,options_ident,dataset_,dataset_info, prior_exist,name_tex,init,tittxt,bounds)
% function [ide_hess, ide_moments, ide_model, ide_lre, derivatives_info, info] = identification_analysis(params,indx,indexo,options_ident,data_info, prior_exist,name_tex,init,analyis_type)
% given the parameter vector params, wraps all identification analyses
%
......@@ -122,7 +122,7 @@ if info(1)==0,
ide_strength_J=NaN(1,nparam);
ide_strength_J_prior=NaN(1,nparam);
if init, %~isempty(indok),
normaliz = abs(params);
normaliz = NaN(1,nparam);
if prior_exist,
if ~isempty(estim_params_.var_exo),
normaliz1 = estim_params_.var_exo(:,7)'; % normalize with prior standard deviation
......@@ -155,12 +155,12 @@ if info(1)==0,
info = stoch_simul(char(options_.varobs));
dataset_ = dseries(oo_.endo_simul(options_.varobs_id,100+1:end)',dates('1Q1'), options_.varobs);
derivatives_info.no_DLIK=1;
bounds = prior_bounds(bayestopt_, options_.prior_trunc);
%bounds = prior_bounds(bayestopt_, options_.prior_trunc);
[fval,info,cost_flag,DLIK,AHess,ys,trend_coeff,M_,options_,bayestopt_,oo_] = dsge_likelihood(params',dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,bounds,oo_,derivatives_info);
% fval = DsgeLikelihood(xparam1,data_info,options_,M_,estim_params_,bayestopt_,oo_);
options_.analytic_derivation = analytic_derivation;
AHess=-AHess;
if min(eig(AHess))<0,
if min(eig(AHess))<-1.e-10,
error('identification_analysis: Analytic Hessian is not positive semi-definite!')
end
% chol(AHess);
......@@ -241,7 +241,7 @@ if info(1)==0,
end
ide_strength_J(indok) = (1./(normaliz(indok)'./abs(params(indok)')));
ide_strength_J_prior(indok) = (1./(normaliz(indok)'./normaliz1(indok)'));
ide_strength_J(params==0)=ide_strength_J_prior(params==0);
ide_strength_J(params==0)=1./normaliz(params==0)';
deltaM_prior = deltaM.*abs(normaliz1');
deltaM = deltaM.*abs(params');
deltaM(params==0)=deltaM_prior(params==0);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment