various bugs

git-svn-id: https://www.dynare.org/svn/dynare/dynare_v4@666 ac1d8469-bf42-47a9-8791-bf33cf982152
time-shift
adjemian 2006-03-10 13:04:50 +00:00
parent 5f4511ef16
commit 3a4db43a83
4 changed files with 36 additions and 18 deletions

View File

@ -1,4 +1,4 @@
function PosteriorIRF()
function PosteriorIRF(type)
% stephane.adjemian@ens.fr [09-25-2005]
global options_ estim_params_ oo_ M_
nvx = estim_params_.nvx;
@ -11,16 +11,32 @@ offset = npar-np;
%%
MaxNumberOfPlotPerFigure = 9;% The square root must be an integer!
nn = sqrt(MaxNumberOfPlotPerFigure);
%%
MhDirectoryName = CheckPath('Output');
DirectoryName = CheckPath('Output');
if strcmpi(type,'posterior')
MhDirectoryName = CheckPath('metropolis');
else
MhDirectoryName = CheckPath('prior');
end
MAX_nirfs = ceil(options_.MaxNumberOfBytes/(options_.irf*length(oo_.steady_state)*M_.exo_nbr)/8)+50;
%%
if strcmpi(type,'posterior')
load([ MhDirectoryName '/' M_.fname '_mh_history'])
TotalNumberOfMhDraws = sum(record.MhDraws(:,1));
NumberOfDraws = TotalNumberOfMhDraws-floor(options_.mh_drop*TotalNumberOfMhDraws);
else% type = 'prior'
NumberOfDraws = 500;
end
B = min([round(.5*NumberOfDraws),500]);
%%
irun = 0;
ifil = 1;
h = waitbar(0,'Bayesian IRFs...');
if strcmpi(type,'posterior')
h = waitbar(0,'Bayesian (posterior) IRFs...');
else
h = waitbar(0,'Bayesian (prior) IRFs...');
end
if B >= MAX_nirfs
stock_irf = zeros(options_.irf,M_.endo_nbr,M_.exo_nbr,MAX_nirfs);
else
@ -28,7 +44,7 @@ else
end
for b=1:B
irun = irun+1;
deep = GetOneDraw('posterior');
deep = GetOneDraw(type);
set_parameters(deep);
dr = resol(oo_.steady_state,0);
SS(M_.exo_names_orig_ord,M_.exo_names_orig_ord) = M_.Sigma_e+1e-14*eye(M_.exo_nbr);

View File

@ -665,8 +665,9 @@ if (any(bayestopt_.pshape >0 ) & options_.mh_replic) | ...
%%
GetPosteriorParametersStatistics;
PlotPosteriorDistributions;
metropolis_draw(1);% Initialization.
if options_.bayesian_irf
PosteriorIRF;
PosteriorIRF('posterior');
end
return

View File

@ -1,6 +1,6 @@
function xparam=metropolis_draw(init)
global options_ estim_params_
persistent mh_nblck NumberofDraws fname FirstLine FirstMhFile MAX_nruns
function xparams=metropolis_draw(init)
global options_ estim_params_ M_
persistent mh_nblck NumberOfDraws fname FirstLine FirstMhFile MAX_nruns
if init
nvx = estim_params_.nvx;
@ -14,12 +14,12 @@ function xparam=metropolis_draw(init)
load([ fname '_mh_history']);
FirstMhFile = record.KeepedDraws.FirstMhFile;
FirstLine = record.KeepedDraws.FirstLine;
TotalNumberOfMhFiles = sum(record.MhDraws(:,2)); LastMhFile = TotalNumberOfMhFiles;
TotalNumberOfMhFiles = sum(record.MhDraws(:,2));
LastMhFile = TotalNumberOfMhFiles;
TotalNumberOfMhDraws = sum(record.MhDraws(:,1));
NumberOfDraws = TotalNumberOfMhDraws-floor(options_.mh_drop* ...
TotalNumberOfMhDraws);
NumberOfDraws = TotalNumberOfMhDraws-floor(options_.mh_drop*TotalNumberOfMhDraws);
MAX_nruns = ceil(options_.MaxNumberOfBytes/(npar+2)/8);
mh_nblck = options_.nblck;
mh_nblck = options_.mh_nblck;
return
end

View File

@ -5,8 +5,9 @@ function set_parameters(xparam1)
ncx = estim_params_.ncx;
np = estim_params_.np;
Sigma_e = M_.Sigma_e;
if nvx
offset = nvx;
var_exo = estim_params_.var_exo;
for i=1:nvx
k = var_exo(i,1);
@ -27,7 +28,7 @@ function set_parameters(xparam1)
if np
offset = offset+estim_params_.ncx+estim_params_.ncn;
M_.params(estim_params_.param_vals(:,1)) = deep(offset+1:end);
M_.params(estim_params_.param_vals(:,1)) = xparam1(offset+1:end);
end
M_.Sigma_e = Sigma_e;
M_.Sigma_e = Sigma_e;