Home > matlab > GetAllPosteriorDraws.m

GetAllPosteriorDraws

PURPOSE ^

function Draws = GetAllPosteriorDraws(column,FirstMhFile,FirstLine,TotalNumberOfMhFile,NumberOfDraws)

SYNOPSIS ^

function Draws = GetAllPosteriorDraws(column, FirstMhFile, FirstLine, TotalNumberOfMhFile, NumberOfDraws, blck)

DESCRIPTION ^

 function Draws = GetAllPosteriorDraws(column,FirstMhFile,FirstLine,TotalNumberOfMhFile,NumberOfDraws)
 Gets all posterior draws

 INPUTS
    column:               column
    FirstMhFile:          first mh file 
    FirstLine:            first line
    TotalNumberOfMhFile:  total number of mh file 
    NumberOfDraws:        number of draws

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function Draws = GetAllPosteriorDraws(column, FirstMhFile, FirstLine, TotalNumberOfMhFile, NumberOfDraws, blck)
0002 
0003 % function Draws = GetAllPosteriorDraws(column,FirstMhFile,FirstLine,TotalNumberOfMhFile,NumberOfDraws)
0004 % Gets all posterior draws
0005 %
0006 % INPUTS
0007 %    column:               column
0008 %    FirstMhFile:          first mh file
0009 %    FirstLine:            first line
0010 %    TotalNumberOfMhFile:  total number of mh file
0011 %    NumberOfDraws:        number of draws
0012 
0013 % OUTPUTS
0014 %    Draws:                draws from posterior distribution
0015 %
0016 % SPECIAL REQUIREMENTS
0017 %    none
0018 
0019 % Copyright (C) 2005-2009 Dynare Team
0020 %
0021 % This file is part of Dynare.
0022 %
0023 % Dynare is free software: you can redistribute it and/or modify
0024 % it under the terms of the GNU General Public License as published by
0025 % the Free Software Foundation, either version 3 of the License, or
0026 % (at your option) any later version.
0027 %
0028 % Dynare is distributed in the hope that it will be useful,
0029 % but WITHOUT ANY WARRANTY; without even the implied warranty of
0030 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0031 % GNU General Public License for more details.
0032 %
0033 % You should have received a copy of the GNU General Public License
0034 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
0035 
0036 global M_ options_
0037 
0038 nblck = options_.mh_nblck;
0039 
0040 iline = FirstLine;
0041 linee = 1;
0042 DirectoryName = CheckPath('metropolis',M_.dname);
0043 
0044 if nblck>1 && nargin<6
0045     Draws = zeros(NumberOfDraws*nblck,1);
0046     iline0=iline;
0047     if column>0
0048         for blck = 1:nblck
0049             iline=iline0;
0050             for file = FirstMhFile:TotalNumberOfMhFile
0051                 load([DirectoryName '/'  M_.fname '_mh' int2str(file) '_blck' int2str(blck)],'x2')
0052                 NumberOfLines = size(x2(iline:end,:),1);
0053                 Draws(linee:linee+NumberOfLines-1) = x2(iline:end,column);
0054                 linee = linee+NumberOfLines;
0055                 iline = 1;
0056             end
0057         end
0058     else 
0059         for blck = 1:nblck
0060             iline=iline0;
0061             for file = FirstMhFile:TotalNumberOfMhFile
0062                 load([DirectoryName '/'  M_.fname '_mh' int2str(file) '_blck' int2str(blck)],'logpo2')
0063                 NumberOfLines = size(logpo2(iline:end),1);
0064                 Draws(linee:linee+NumberOfLines-1) = logpo2(iline:end);
0065                 linee = linee+NumberOfLines;
0066                 iline = 1;
0067             end
0068         end
0069     end
0070 else
0071     if nblck==1
0072         blck=1;
0073     end
0074     if column>0
0075         for file = FirstMhFile:TotalNumberOfMhFile
0076             load([DirectoryName '/'  M_.fname '_mh' int2str(file) '_blck' int2str(blck)],'x2')
0077             NumberOfLines = size(x2(iline:end,:),1);
0078             Draws(linee:linee+NumberOfLines-1) = x2(iline:end,column);
0079             linee = linee+NumberOfLines;
0080             iline = 1;
0081         end
0082     else
0083         for file = FirstMhFile:TotalNumberOfMhFile
0084             load([DirectoryName '/'  M_.fname '_mh' int2str(file) '_blck' int2str(blck)],'logpo2')
0085             NumberOfLines = size(logpo2(iline:end,:),1);
0086             Draws(linee:linee+NumberOfLines-1) = logpo2(iline:end);
0087             linee = linee+NumberOfLines;
0088             iline = 1;
0089         end
0090     end
0091 end

Generated on Mon 21-May-2012 02:42:43 by m2html © 2005