Home > matlab > check_prior_analysis_data.m

check_prior_analysis_data

PURPOSE ^

Copyright (C) 2009 Dynare Team

SYNOPSIS ^

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

DESCRIPTION ^

 Copyright (C) 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_prior_analysis_data(type,M_)
0002 % Copyright (C) 2009 Dynare Team
0003 %
0004 % This file is part of Dynare.
0005 %
0006 % Dynare is free software: you can redistribute it and/or modify
0007 % it under the terms of the GNU General Public License as published by
0008 % the Free Software Foundation, either version 3 of the License, or
0009 % (at your option) any later version.
0010 %
0011 % Dynare is distributed in the hope that it will be useful,
0012 % but WITHOUT ANY WARRANTY; without even the implied warranty of
0013 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0014 % GNU General Public License for more details.
0015 %
0016 % You should have received a copy of the GNU General Public License
0017 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
0018 
0019 info = 0;
0020 if nargout>1
0021     description = '';
0022 end
0023 
0024 %% Get informations about prior draws files.
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 %% Get informations about _posterior_draws files.
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; % Nothing to do!
0052         if nargout>1
0053             description = 'prior draws files are up to date.';
0054         end
0055     end
0056 end
0057 
0058 %% Get informations about prior data files.
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     % /!\ REMARK /!\
0084     % The user can change the model or the value of a calibrated
0085     % parameter without changing the prior. In this case the (prior)
0086     % moments should be computed. But this case cannot be detected!!!
0087     if pdfdate<date_of_the_last_prior_draw_file
0088         info = 5; % prior data files have to be updated.
0089         if nargout>1
0090             description = 'prior data files have to be updated.';
0091         end
0092     else
0093         info = 6; % Ok (nothing to do ;-)
0094         if nargout>1
0095             description = 'prior data files are up to date.';
0096         end
0097     end
0098 end

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