2023-09-14 08:51:04 +02:00
|
|
|
function Draws = GetAllPosteriorDraws(dname, fname, column, FirstMhFile, FirstLine, TotalNumberOfMhFile, NumberOfDraws, nblcks, blck)
|
|
|
|
% function Draws = GetAllPosteriorDraws(dname, fname, column, FirstMhFile, FirstLine, TotalNumberOfMhFile, NumberOfDraws, nblcks, blck)
|
2009-12-16 18:17:34 +01:00
|
|
|
% Gets all posterior draws
|
|
|
|
%
|
|
|
|
% INPUTS
|
2023-09-14 08:51:04 +02:00
|
|
|
% dname: name of directory with results
|
|
|
|
% fname: name of mod file
|
2023-07-13 18:01:02 +02:00
|
|
|
% column: column of desired parameter in draw matrix
|
2017-05-16 15:10:20 +02:00
|
|
|
% FirstMhFile: first mh file
|
2009-12-16 18:17:34 +01:00
|
|
|
% FirstLine: first line
|
2017-05-16 15:10:20 +02:00
|
|
|
% TotalNumberOfMhFile: total number of mh file
|
2009-12-16 18:17:34 +01:00
|
|
|
% NumberOfDraws: number of draws
|
2023-07-13 18:01:02 +02:00
|
|
|
% nblcks: total number of blocks
|
|
|
|
% blck: desired block to read
|
|
|
|
%
|
2009-12-16 18:17:34 +01:00
|
|
|
% OUTPUTS
|
|
|
|
% Draws: draws from posterior distribution
|
2017-05-16 15:10:20 +02:00
|
|
|
%
|
2009-12-16 18:17:34 +01:00
|
|
|
% SPECIAL REQUIREMENTS
|
|
|
|
% none
|
|
|
|
|
2023-07-13 18:01:02 +02:00
|
|
|
% Copyright © 2005-2023 Dynare Team
|
2009-12-16 18:17:34 +01:00
|
|
|
%
|
|
|
|
% This file is part of Dynare.
|
|
|
|
%
|
|
|
|
% Dynare is free software: you can redistribute it and/or modify
|
|
|
|
% it under the terms of the GNU General Public License as published by
|
|
|
|
% the Free Software Foundation, either version 3 of the License, or
|
|
|
|
% (at your option) any later version.
|
|
|
|
%
|
|
|
|
% Dynare is distributed in the hope that it will be useful,
|
|
|
|
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
% GNU General Public License for more details.
|
|
|
|
%
|
|
|
|
% You should have received a copy of the GNU General Public License
|
2021-06-09 17:33:48 +02:00
|
|
|
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
2009-12-16 18:17:34 +01:00
|
|
|
|
|
|
|
iline = FirstLine;
|
|
|
|
linee = 1;
|
2023-09-14 08:51:04 +02:00
|
|
|
DirectoryName = CheckPath('metropolis',dname);
|
2009-12-16 18:17:34 +01:00
|
|
|
|
2023-09-14 08:51:04 +02:00
|
|
|
if nblcks>1 && nargin<9
|
2023-07-13 18:01:02 +02:00
|
|
|
Draws = zeros(NumberOfDraws*nblcks,1);
|
2009-12-16 18:17:34 +01:00
|
|
|
iline0=iline;
|
|
|
|
if column>0
|
2023-07-13 18:01:02 +02:00
|
|
|
for blck = 1:nblcks
|
2009-12-16 18:17:34 +01:00
|
|
|
iline=iline0;
|
|
|
|
for file = FirstMhFile:TotalNumberOfMhFile
|
2023-09-14 08:51:04 +02:00
|
|
|
load([DirectoryName '/' fname '_mh' int2str(file) '_blck' int2str(blck)],'x2')
|
2009-12-16 18:17:34 +01:00
|
|
|
NumberOfLines = size(x2(iline:end,:),1);
|
|
|
|
Draws(linee:linee+NumberOfLines-1) = x2(iline:end,column);
|
|
|
|
linee = linee+NumberOfLines;
|
|
|
|
iline = 1;
|
|
|
|
end
|
|
|
|
end
|
2017-05-16 15:10:20 +02:00
|
|
|
else
|
2023-07-13 18:01:02 +02:00
|
|
|
for blck = 1:nblcks
|
2009-12-16 18:17:34 +01:00
|
|
|
iline=iline0;
|
|
|
|
for file = FirstMhFile:TotalNumberOfMhFile
|
2023-09-14 08:51:04 +02:00
|
|
|
load([DirectoryName '/' fname '_mh' int2str(file) '_blck' int2str(blck)],'logpo2')
|
2009-12-16 18:17:34 +01:00
|
|
|
NumberOfLines = size(logpo2(iline:end),1);
|
|
|
|
Draws(linee:linee+NumberOfLines-1) = logpo2(iline:end);
|
|
|
|
linee = linee+NumberOfLines;
|
|
|
|
iline = 1;
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
else
|
2023-07-13 18:01:02 +02:00
|
|
|
if nblcks==1
|
2009-12-16 18:17:34 +01:00
|
|
|
blck=1;
|
|
|
|
end
|
|
|
|
if column>0
|
|
|
|
for file = FirstMhFile:TotalNumberOfMhFile
|
2023-09-14 08:51:04 +02:00
|
|
|
load([DirectoryName '/' fname '_mh' int2str(file) '_blck' int2str(blck)],'x2')
|
2009-12-16 18:17:34 +01:00
|
|
|
NumberOfLines = size(x2(iline:end,:),1);
|
|
|
|
Draws(linee:linee+NumberOfLines-1) = x2(iline:end,column);
|
|
|
|
linee = linee+NumberOfLines;
|
|
|
|
iline = 1;
|
|
|
|
end
|
|
|
|
else
|
|
|
|
for file = FirstMhFile:TotalNumberOfMhFile
|
2023-09-14 08:51:04 +02:00
|
|
|
load([DirectoryName '/' fname '_mh' int2str(file) '_blck' int2str(blck)],'logpo2')
|
2009-12-16 18:17:34 +01:00
|
|
|
NumberOfLines = size(logpo2(iline:end,:),1);
|
|
|
|
Draws(linee:linee+NumberOfLines-1) = logpo2(iline:end);
|
|
|
|
linee = linee+NumberOfLines;
|
|
|
|
iline = 1;
|
|
|
|
end
|
|
|
|
end
|
2005-09-10 12:04:22 +02:00
|
|
|
end
|