0001 function varlist = check_list_of_variables(options_, M_, varlist)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
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