0001 function [info,description] = check_posterior_analysis_data(type,M_)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 info = 0;
0021 if nargout>1
0022 description = '';
0023 end
0024
0025
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
0034 drawsinfo = dir([ M_.dname '/metropolis/' M_.fname '_posterior_draws*.mat']);
0035 if isempty(drawsinfo)
0036 info = 1;
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;
0047 if nargout>1
0048 description = 'posterior draws files have to be updated.';
0049 end
0050 return
0051 else
0052 info = 3;
0053 if nargout>1
0054 description = 'posterior draws files are up to date.';
0055 end
0056 end
0057 end
0058
0059
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;
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;
0091 if nargout>1
0092 description = 'posterior data files have to be updated.';
0093 end
0094 else
0095 info = 6;
0096 if nargout>1
0097 description = 'There is nothing to do';
0098 end
0099 end
0100 end