Commit 29f9bb95 authored by Stéphane Adjemian (Scylla)'s avatar Stéphane Adjemian (Scylla)
Browse files

Fixed bug related to the mh based approximation of the posterior covariance matrix (used

for the jumping distribution).
parent ded34f99
......@@ -88,7 +88,7 @@ for i=1:npar
eval(['f1 = oo_.posterior_density.shocks_std.' name '(:,2);'])
eval(['oo_.prior_density.shocks_std.' name '(:,1) = x2;'])
eval(['oo_.prior_density.shocks_std.' name '(:,2) = f2;'])
if options_.posterior_mode_estimation
if ~options_.mh_posterior_mode_estimation
eval(['pmod = oo_.posterior_mode.shocks_std.' name ';'])
end
elseif i <= nvx+nvn
......@@ -97,7 +97,7 @@ for i=1:npar
eval(['f1 = oo_.posterior_density.measurement_errors_std.' name '(:,2);'])
eval(['oo_.prior_density.mearsurement_errors_std.' name '(:,1) = x2;'])
eval(['oo_.prior_density.measurement_errors_std.' name '(:,2) = f2;'])
if options_.posterior_mode_estimation
if ~options_.mh_posterior_mode_estimation
eval(['pmod = oo_.posterior_mode.measurement_errors_std.' name ';'])
end
elseif i <= nvx+nvn+ncx
......@@ -109,7 +109,7 @@ for i=1:npar
eval(['f1 = oo_.posterior_density.shocks_corr.' name '(:,2);'])
eval(['oo_.prior_density.shocks_corr.' name '(:,1) = x2;'])
eval(['oo_.prior_density.shocks_corr.' name '(:,2) = f2;'])
if options_.posterior_mode_estimation
if ~options_.mh_posterior_mode_estimation
eval(['pmod = oo_.posterior_mode.shocks_corr.' name ';'])
end
elseif i <= nvx+nvn+ncx+ncn
......@@ -121,7 +121,7 @@ for i=1:npar
eval(['f1 = oo_.posterior_density.measurement_errors_corr.' name '(:,2);'])
eval(['oo_.prior_density.mearsurement_errors_corr.' name '(:,1) = x2;'])
eval(['oo_.prior_density.measurement_errors_corr.' name '(:,2) = f2;'])
if options_.posterior_mode_estimation
if ~options_.mh_posterior_mode_estimation
eval(['pmod = oo_.posterior_mode.measurement_errors_corr.' name ';'])
end
else
......@@ -131,7 +131,7 @@ for i=1:npar
eval(['f1 = oo_.posterior_density.parameters.' name '(:,2);'])
eval(['oo_.prior_density.parameters.' name '(:,1) = x2;'])
eval(['oo_.prior_density.parameters.' name '(:,2) = f2;'])
if options_.posterior_mode_estimation
if ~options_.mh_posterior_mode_estimation
eval(['pmod = oo_.posterior_mode.parameters.' name ';'])
end
end
......@@ -146,7 +146,7 @@ for i=1:npar
set(hh,'color',[0.7 0.7 0.7]);
hold on;
plot(x1,f1,'-k','linewidth',2);
if options_.posterior_mode_estimation
if ~options_.mh_posterior_mode_estimation
plot( [pmod pmod], [0.0 1.1*top0], '--g', 'linewidth', 2);
end
box on;
......
function [posterior_mean,posterior_covariance,posterior_mode,posterior_kernel_at_the_mode] = compute_mh_covariance_matrix()
% function [m0,s0] = compute_mh_covariance_matrix()
% Estimation of the posterior covariance matrix and expectation.
% Estimation of the posterior covariance matrix, posterior mean, posterior mode and evaluation of the posterior kernel at the
% estimated mode, using the draws from a metropolis-hastings. The estimated posterior mode and covariance matrix are saved in
% a file <M_.fname>_mh_mode.mat.
%
% INPUTS
% None.
......@@ -10,12 +10,12 @@ function [posterior_mean,posterior_covariance,posterior_mode,posterior_kernel_at
% o posterior_mean [double] (n*1) vector, posterior expectation of the parameters.
% o posterior_covariance [double] (n*n) matrix, posterior covariance of the parameters (computed from previous metropolis hastings).
% o posterior_mode [double] (n*1) vector, posterior mode of the parameters.
% o posterior_kernel_at_the_mode [double] scalar.
% o posterior_kernel_at_the_mode [double] scalar.
%
% SPECIAL REQUIREMENTS
% None.
% Copyright (C) 2006-2008 Dynare Team
% Copyright (C) 2006-2008, 2010 Dynare Team
%
% This file is part of Dynare.
%
......
This diff is collapsed.
......@@ -176,7 +176,7 @@ options_.moments_varendo = 0;
options_.nk = 1;
options_.noconstant = 0;
options_.nodiagnostic = 0;
options_.posterior_mode_estimation = 1;
options_.mh_posterior_mode_estimation = 0;
options_.prefilter = 0;
options_.presample = 0;
options_.prior_trunc = 1e-10;
......
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