1function Draws = GetAllPosteriorDraws(column, FirstMhFile, FirstLine, TotalNumberOfMhFile, NumberOfDraws, blck)
2
3% function Draws = GetAllPosteriorDraws(column,FirstMhFile,FirstLine,TotalNumberOfMhFile,NumberOfDraws)
4% Gets all posterior draws
5%
6% INPUTS
7%    column:               column
8%    FirstMhFile:          first mh file
9%    FirstLine:            first line
10%    TotalNumberOfMhFile:  total number of mh file
11%    NumberOfDraws:        number of draws
12
13% OUTPUTS
14%    Draws:                draws from posterior distribution
15%
16% SPECIAL REQUIREMENTS
17%    none
18
19% Copyright (C) 2005-2017 Dynare Team
20%
21% This file is part of Dynare.
22%
23% Dynare is free software: you can redistribute it and/or modify
24% it under the terms of the GNU General Public License as published by
25% the Free Software Foundation, either version 3 of the License, or
26% (at your option) any later version.
27%
28% Dynare is distributed in the hope that it will be useful,
29% but WITHOUT ANY WARRANTY; without even the implied warranty of
30% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
31% GNU General Public License for more details.
32%
33% You should have received a copy of the GNU General Public License
34% along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
35
36global M_ options_
37
38nblck = options_.mh_nblck;
39
40iline = FirstLine;
41linee = 1;
42DirectoryName = CheckPath('metropolis',M_.dname);
43
44if nblck>1 && nargin<6
45    Draws = zeros(NumberOfDraws*nblck,1);
46    iline0=iline;
47    if column>0
48        for blck = 1:nblck
49            iline=iline0;
50            for file = FirstMhFile:TotalNumberOfMhFile
51                load([DirectoryName '/'  M_.fname '_mh' int2str(file) '_blck' int2str(blck)],'x2')
52                NumberOfLines = size(x2(iline:end,:),1);
53                Draws(linee:linee+NumberOfLines-1) = x2(iline:end,column);
54                linee = linee+NumberOfLines;
55                iline = 1;
56            end
57        end
58    else
59        for blck = 1:nblck
60            iline=iline0;
61            for file = FirstMhFile:TotalNumberOfMhFile
62                load([DirectoryName '/'  M_.fname '_mh' int2str(file) '_blck' int2str(blck)],'logpo2')
63                NumberOfLines = size(logpo2(iline:end),1);
64                Draws(linee:linee+NumberOfLines-1) = logpo2(iline:end);
65                linee = linee+NumberOfLines;
66                iline = 1;
67            end
68        end
69    end
70else
71    if nblck==1
72        blck=1;
73    end
74    if column>0
75        for file = FirstMhFile:TotalNumberOfMhFile
76            load([DirectoryName '/'  M_.fname '_mh' int2str(file) '_blck' int2str(blck)],'x2')
77            NumberOfLines = size(x2(iline:end,:),1);
78            Draws(linee:linee+NumberOfLines-1) = x2(iline:end,column);
79            linee = linee+NumberOfLines;
80            iline = 1;
81        end
82    else
83        for file = FirstMhFile:TotalNumberOfMhFile
84            load([DirectoryName '/'  M_.fname '_mh' int2str(file) '_blck' int2str(blck)],'logpo2')
85            NumberOfLines = size(logpo2(iline:end,:),1);
86            Draws(linee:linee+NumberOfLines-1) = logpo2(iline:end);
87            linee = linee+NumberOfLines;
88            iline = 1;
89        end
90    end
91end