Allow to retrieve logposterior values for MH runs,

not only parameter values.

git-svn-id: https://www.dynare.org/svn/dynare/dynare_v4@731 ac1d8469-bf42-47a9-8791-bf33cf982152
time-shift
ratto 2006-05-04 08:52:43 +00:00
parent 72ea3ac220
commit 90c2ca6e62
3 changed files with 18 additions and 7 deletions

View File

@ -7,14 +7,24 @@ iline = FirstLine;
linee = 1;
DirectoryName = CheckPath('metropolis');
Draws = zeros(NumberOfDraws*nblck,1);
logpo = zeros(NumberOfDraws*nblck,1);
ipost=0;
if column<0,
column=1;
ipost=1;
end
for file = FirstMhFile:TotalNumberOfMhFile
for blck = 1:nblck
load([DirectoryName '/' M_.fname '_mh' int2str(file) '_blck' int2str(blck)],'x2')
load([DirectoryName '/' M_.fname '_mh' int2str(file) '_blck' int2str(blck)],'x2','logpo2')
NumberOfLines = size(x2(iline:end,:),1);
Draws(linee:linee+NumberOfLines-1) = x2(iline:end,column);
logpo(linee:linee+NumberOfLines-1) = logpo2(iline:end);
linee = linee+NumberOfLines;
end
iline = 1;
end
if ipost,
Draws=logpo;
end

View File

@ -1,9 +1,9 @@
function xparams = GetOneDraw(type)
function [xparams, logpost] = GetOneDraw(type)
% stephane.adjemian@ens.fr [09-25-2005]
switch type
case 'posterior'
xparams = metropolis_draw(0);
[xparams, logpost] = metropolis_draw(0);
case 'prior'
xparams = prior_draw(0);
end

View File

@ -1,4 +1,4 @@
function xparams=metropolis_draw(init)
function [xparams, logpost]=metropolis_draw(init)
global options_ estim_params_ M_
persistent mh_nblck NumberOfDraws fname FirstLine FirstMhFile MAX_nruns
@ -35,5 +35,6 @@ function xparams=metropolis_draw(init)
MhLine = DrawNumber-(MhFilNumber-FirstMhFile-1)*MAX_nruns;
end
load( [ fname '_mh' int2str(MhFilNumber) '_blck' int2str(ChainNumber) '.mat' ],'x2');
xparams = x2(MhLine,:);
load( [ fname '_mh' int2str(MhFilNumber) '_blck' int2str(ChainNumber) '.mat' ],'x2','logpo2');
xparams = x2(MhLine,:);
logpost= logpo2(MhLine);