Home > matlab > check_list_of_variables.m

check_list_of_variables

PURPOSE ^

This function defines, if necessary, the list of endogenous variables

SYNOPSIS ^

function varlist = check_list_of_variables(options_, M_, varlist)

DESCRIPTION ^

 This function defines, if necessary, the list of endogenous variables
 for which the posterior statistics have to be computed. 
 

 INPUTS 

   options_        [structure]    Dynare structure.
   M_              [structure]    Dynare structure (related to model definition).
   varlist         [string]       Array of strings with name of the endogenous variables.
    
 OUTPUTS 
   varlist         [string] 
        
 SPECIAL REQUIREMENTS

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function varlist = check_list_of_variables(options_, M_, varlist)
0002 % This function defines, if necessary, the list of endogenous variables
0003 % for which the posterior statistics have to be computed.
0004 %
0005 %
0006 % INPUTS
0007 %
0008 %   options_        [structure]    Dynare structure.
0009 %   M_              [structure]    Dynare structure (related to model definition).
0010 %   varlist         [string]       Array of strings with name of the endogenous variables.
0011 %
0012 % OUTPUTS
0013 %   varlist         [string]
0014 %
0015 % SPECIAL REQUIREMENTS
0016 
0017 % Copyright (C) 2003-2010 Dynare Team
0018 %
0019 % This file is part of Dynare.
0020 %
0021 % Dynare is free software: you can redistribute it and/or modify
0022 % it under the terms of the GNU General Public License as published by
0023 % the Free Software Foundation, either version 3 of the License, or
0024 % (at your option) any later version.
0025 %
0026 % Dynare is distributed in the hope that it will be useful,
0027 % but WITHOUT ANY WARRANTY; without even the implied warranty of
0028 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0029 % GNU General Public License for more details.
0030 %
0031 % You should have received a copy of the GNU General Public License
0032 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
0033 
0034 msg = 0;
0035 if options_.dsge_var && options_.bayesian_irf
0036     if ~isempty(varlist)
0037         for i=1:size(varlist,1)
0038             idx = strmatch(deblank(varlist(i,:)),options_.varobs,'exact');
0039             if isempty(idx)
0040                 disp([varlist(i,:) ' is not an observed variable!']);
0041                 msg = 1;
0042             end
0043         end
0044         if size(varlist,1)~=size(options_.varobs)
0045             msg = 1;
0046         end
0047         if msg
0048             disp(' ')
0049             disp('Posterior IRFs will be computed for all observed variables.')
0050             disp(' ')
0051         end
0052     end
0053     varlist = options_.varobs;
0054     return
0055 end
0056 
0057 if isempty(varlist)
0058     disp(' ')
0059     disp(['You did not declare endogenous variables after the estimation command.'])
0060     cas = [];
0061     if options_.bayesian_irf
0062         cas = 'Posterior IRFs';
0063     end
0064     if options_.moments_varendo
0065         if isempty(cas)
0066             cas = 'Posterior moments';
0067         else
0068             cas = [ cas , ', posterior moments'];
0069         end
0070     end
0071     if options_.smoother
0072         if isempty(cas)
0073             cas = 'Posterior smoothed variables';
0074         else
0075             cas = [ cas , ', posterior smoothed variables'];
0076         end
0077     end
0078     if options_.smoother
0079         if isempty(cas)
0080             cas = 'Posterior smoothed variables';
0081         else
0082             cas = [ cas , ', posterior smoothed variables'];
0083         end
0084     end
0085     if ~isempty(options_.filter_step_ahead)
0086         if isempty(cas)
0087             cas = 'Posterior k-step ahead filtered variables';
0088         else
0089             cas = [ cas , ', posterior k-step ahead filtered variables'];
0090         end
0091     end
0092     if options_.forecast
0093         if isempty(cas)
0094             cas = 'Posterior forecasts';
0095         else
0096             cas = [ cas , ' and posterior forecats'];
0097         end
0098     end
0099     if ~isempty(cas)
0100         string = [ cas , ' will be computed for the ' num2str(M_.endo_nbr)  ' endogenous variables'];
0101         string = [ string ' of your model, this can be very long....']; 
0102         format_text(string, 10)
0103         choice = [];
0104         while isempty(choice)
0105             disp(' ')
0106             disp(' ')
0107             disp('Choose one of the following options:')
0108             disp(' ')
0109             disp(' [1] Consider all the endogenous variables.')
0110             disp(' [2] Consider all the observed endogenous variables.')
0111             disp(' [3] Stop Dynare and change the mod file.')
0112             disp(' ')
0113             choice = input('options [default is 1] =  ');
0114             if isempty(choice)
0115                 choice=1;
0116             end
0117             if choice==1
0118                 varlist = M_.endo_names(1:M_.orig_endo_nbr, :);
0119             elseif choice==2
0120                 varlist = options_.varobs;
0121             elseif choice==3
0122                 varlist = NaN;
0123             else
0124                 disp('')
0125                 disp('YOU HAVE TO ANSWER 1, 2 or 3!')
0126                 disp('')
0127             end
0128         end
0129     end
0130     if isnan(varlist)
0131         edit([M_.fname '.mod'])
0132     end
0133     disp('')
0134 end
0135 
0136 
0137 
0138 function format_text(remain, max_number_of_words_per_line)
0139 index = 0;
0140 line_of_text = [];
0141 while ~isempty(remain)
0142     [token, remain] = strtok(remain);
0143     index = index+1;
0144     if isempty(line_of_text)
0145         line_of_text = token;
0146     else
0147         line_of_text = [line_of_text , ' ' , token];
0148     end
0149     if index==max_number_of_words_per_line
0150         disp(line_of_text)
0151         index = 0;
0152         line_of_text = [];
0153     end
0154 end
0155 if index<max_number_of_words_per_line
0156     disp(line_of_text)
0157 end

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