Home > matlab > check_posterior_analysis_data.m

check_posterior_analysis_data

PURPOSE ^

Copyright (C) 2008-2009 Dynare Team

SYNOPSIS ^

function [info,description] = check_posterior_analysis_data(type,M_)

DESCRIPTION ^

 Copyright (C) 2008-2009 Dynare Team

 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
 along with Dynare.  If not, see <http://www.gnu.org/licenses/>.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [info,description] = check_posterior_analysis_data(type,M_)
0002 
0003 % Copyright (C) 2008-2009 Dynare Team
0004 %
0005 % This file is part of Dynare.
0006 %
0007 % Dynare is free software: you can redistribute it and/or modify
0008 % it under the terms of the GNU General Public License as published by
0009 % the Free Software Foundation, either version 3 of the License, or
0010 % (at your option) any later version.
0011 %
0012 % Dynare is distributed in the hope that it will be useful,
0013 % but WITHOUT ANY WARRANTY; without even the implied warranty of
0014 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0015 % GNU General Public License for more details.
0016 %
0017 % You should have received a copy of the GNU General Public License
0018 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
0019 
0020 info = 0;
0021 if nargout>1
0022     description = '';
0023 end
0024 
0025 %% Get informations about mcmc files.
0026 if ~exist([ M_.dname '/metropolis'],'dir')
0027     disp('check_posterior_analysis_data:: Can''t find any mcmc file!')
0028     return
0029 end
0030 mhname = get_name_of_the_last_mh_file(M_);
0031 mhdate = get_date_of_a_file(mhname);
0032 
0033 %% Get informations about _posterior_draws files.
0034 drawsinfo = dir([ M_.dname '/metropolis/' M_.fname '_posterior_draws*.mat']);
0035 if isempty(drawsinfo)
0036     info = 1; % select_posterior_draws has to be called first.
0037     if nargout>1
0038         description = 'select_posterior_draws has to be called.';
0039     end
0040     return
0041 else
0042     number_of_last_posterior_draws_file = length(drawsinfo);
0043     pddate = get_date_of_a_file([ M_.dname '/metropolis/' M_.fname '_posterior_draws'...
0044                         int2str(number_of_last_posterior_draws_file) '.mat']);
0045     if pddate<mhdate
0046         info = 2; % _posterior_draws files have to be updated.
0047         if nargout>1
0048             description = 'posterior draws files have to be updated.';
0049         end
0050         return
0051     else
0052         info = 3; % Ok!
0053         if nargout>1
0054             description = 'posterior draws files are up to date.';
0055         end
0056     end
0057 end
0058 
0059 %% Get informations about posterior data files.
0060 switch type
0061   case 'variance'
0062     generic_post_data_file_name = 'Posterior2ndOrderMoments';
0063   case 'decomposition'
0064     generic_post_data_file_name = 'PosteriorVarianceDecomposition';
0065   case 'correlation'
0066     generic_post_data_file_name = 'PosteriorCorrelations';
0067   case 'conditional decomposition'
0068     generic_post_data_file_name = 'PosteriorConditionalVarianceDecomposition';
0069   otherwise
0070     disp('This feature is not yest implemented!')
0071 end
0072 pdfinfo = dir([ M_.dname '/metropolis/' M_.fname '_' generic_post_data_file_name '*']);
0073 if isempty(pdfinfo)
0074     info = 4; % posterior draws have to be processed.
0075     if nargout>1
0076         description = 'posterior draws files have to be processed.';
0077     end
0078     return
0079 else
0080     number_of_the_last_post_data_file = length(pdfinfo);
0081     name_of_the_last_post_data_file = ...
0082         [ './' M_.dname ...
0083           '/metropolis/' ...
0084           M_.fname '_' ... 
0085           generic_post_data_file_name ...
0086           int2str(number_of_the_last_post_data_file) ...
0087           '.mat' ];
0088     pdfdate = get_date_of_a_file(name_of_the_last_post_data_file);
0089     if pdfdate<pddate
0090         info = 5; % posterior data files have to be updated.
0091         if nargout>1
0092             description = 'posterior data files have to be updated.';
0093         end            
0094     else
0095         info = 6; % Ok (nothing to do ;-)
0096         if nargout>1
0097             description = 'There is nothing to do';
0098         end        
0099     end
0100 end

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