Home > matlab > get_name_of_the_last_mh_file.m

get_name_of_the_last_mh_file

PURPOSE ^

This function returns the name of the last mh file and test if the metropolis was completed.

SYNOPSIS ^

function [mhname,info] = get_name_of_the_last_mh_file(M_)

DESCRIPTION ^

 This function returns the name of the last mh file and test if the metropolis was completed.

 INPUTS 
   M_       [structure]   Dynare structure specifying the model.     

 OUTPUTS 
  mhname    [string]      Name of the last mh file (with complete path).  
  info      [integer]     Scalar. If info is equal to 1 then the predicted name of the last
                          metropolis hastings matches the name of the name of the last mh 
                          file. Otherwise info is equal to zero (a likely reason for this is 
                          that the mcmc simulations were not completed).

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [mhname,info] = get_name_of_the_last_mh_file(M_)
0002 % This function returns the name of the last mh file and test if the metropolis was completed.
0003 %
0004 % INPUTS
0005 %   M_       [structure]   Dynare structure specifying the model.
0006 %
0007 % OUTPUTS
0008 %  mhname    [string]      Name of the last mh file (with complete path).
0009 %  info      [integer]     Scalar. If info is equal to 1 then the predicted name of the last
0010 %                          metropolis hastings matches the name of the name of the last mh
0011 %                          file. Otherwise info is equal to zero (a likely reason for this is
0012 %                          that the mcmc simulations were not completed).
0013 
0014 % Copyright (C) 2008-2010 Dynare Team
0015 %
0016 % This file is part of Dynare.
0017 %
0018 % Dynare is free software: you can redistribute it and/or modify
0019 % it under the terms of the GNU General Public License as published by
0020 % the Free Software Foundation, either version 3 of the License, or
0021 % (at your option) any later version.
0022 %
0023 % Dynare is distributed in the hope that it will be useful,
0024 % but WITHOUT ANY WARRANTY; without even the implied warranty of
0025 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0026 % GNU General Public License for more details.
0027 %
0028 % You should have received a copy of the GNU General Public License
0029 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
0030 
0031 mhname = [];
0032 info = 1;
0033 
0034 MhDirectoryName = CheckPath('metropolis',M_.dname);
0035 
0036 load([ MhDirectoryName '/' M_.fname '_mh_history.mat']) ;
0037 mh_number = record.LastFileNumber ;
0038 bk_number = record.Nblck ;
0039 clear('record') ;
0040 predicted_mhname = [ MhDirectoryName  '/' M_.fname '_mh' int2str(mh_number) '_blck' int2str(bk_number) '.mat' ] ;
0041 
0042 AllMhFiles = dir([MhDirectoryName  '/' M_.fname '_mh*_blck*' ]);
0043 idx = 1;
0044 latest_date = 0;
0045 for i=2:size(AllMhFiles)
0046     if AllMhFiles(i).datenum > latest_date
0047         idx = i;
0048         latest_date = AllMhFiles(i).datenum;
0049     end
0050 end
0051 mhname = [ MhDirectoryName  '/'  AllMhFiles(idx).name];
0052 
0053 if ~strcmpi(mhname,predicted_mhname)
0054     info = 0;
0055 end

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