0001 function [info,description] = check_prior_analysis_data(type,M_)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019 info = 0;
0020 if nargout>1
0021 description = '';
0022 end
0023
0024
0025 if ~exist([ M_.dname '/prior/draws'],'dir')
0026 disp('check_prior_analysis_data:: Can''t find any prior draws file!')
0027 return
0028 end
0029
0030 prior_draws_info = dir([ M_.dname '/prior/draws/prior_draws*.mat']);
0031 name_of_the_last_prior_draw_file = prior_draws_info(end).name;
0032 date_of_the_last_prior_draw_file = prior_draws_info(end).datenum;
0033
0034
0035 if isempty(prior_draws_info)
0036 info = 1;
0037 if nargout>1
0038 description = 'prior_sampler has to be called.';
0039 end
0040 return
0041 else
0042 number_of_last_prior_draws_file = length(prior_draws_info);
0043 date_of_the_prior_definition = get_date_of_a_file([ M_.dname '/prior/definition.mat']);
0044 if date_of_the_prior_definition>date_of_the_last_prior_draw_file
0045 info = 2;
0046 if nargout>1
0047 description = 'prior draws files have to be updated.';
0048 end
0049 return
0050 else
0051 info = 3;
0052 if nargout>1
0053 description = 'prior draws files are up to date.';
0054 end
0055 end
0056 end
0057
0058
0059 switch type
0060 case 'variance'
0061 generic_prior_data_file_name = 'Prior2ndOrderMoments';
0062 case 'decomposition'
0063 generic_prior_data_file_name = 'PriorVarianceDecomposition';
0064 case 'correlation'
0065 generic_prior_data_file_name = 'PriorCorrelations';
0066 case 'conditional decomposition'
0067 generic_prior_data_file_name = 'PriorConditionalVarianceDecomposition';
0068 otherwise
0069 disp(['This feature is not yet implemented!'])
0070 end
0071 CheckPath('prior/moments',M_.dname);
0072 pdfinfo = dir([ M_.dname '/prior/' generic_prior_data_file_name '*']);
0073 if isempty(pdfinfo)
0074 info = 4;
0075 if nargout>1
0076 description = 'prior draws files have to be processed.';
0077 end
0078 return
0079 else
0080 number_of_the_last_prior_data_file = length(pdfinfo);
0081 name_of_the_last_prior_data_file = pdinfo(end).name;
0082 pdfdate = pdinfo(end).datenum;
0083
0084
0085
0086
0087 if pdfdate<date_of_the_last_prior_draw_file
0088 info = 5;
0089 if nargout>1
0090 description = 'prior data files have to be updated.';
0091 end
0092 else
0093 info = 6;
0094 if nargout>1
0095 description = 'prior data files are up to date.';
0096 end
0097 end
0098 end