Attachment 'resid_with_names.m'

Download

   1 function z = resid(tagname)
   2 % function z = resid(junk)
   3 %
   4 % Computes static residuals associated with the guess values.
   5 % 
   6 % INPUTS
   7 %    junk:   dummy value for backward compatibility
   8 %    
   9 % OUTPUTS
  10 %    z:      residuals
  11 %        
  12 % SPECIAL REQUIREMENTS
  13 %    none
  14 
  15 % Copyright (C) 2001-2009 Dynare Team
  16 %
  17 % This file is part of Dynare.
  18 %
  19 % Dynare is free software: you can redistribute it and/or modify
  20 % it under the terms of the GNU General Public License as published by
  21 % the Free Software Foundation, either version 3 of the License, or
  22 % (at your option) any later version.
  23 %
  24 % Dynare is distributed in the hope that it will be useful,
  25 % but WITHOUT ANY WARRANTY; without even the implied warranty of
  26 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  27 % GNU General Public License for more details.
  28 %
  29 % You should have received a copy of the GNU General Public License
  30 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
  31 
  32 global M_ options_ oo_
  33 
  34 steady_state_old = oo_.steady_state;
  35 
  36 % If using a steady state file, initialize oo_.steady_state with that file
  37 if options_.steadystate_flag
  38     [ys,check] = feval([M_.fname '_steadystate'], ...
  39                        oo_.steady_state, ...
  40                        [oo_.exo_steady_state; ...
  41                         oo_.exo_det_steady_state]);
  42     if size(ys, 1) < M_.endo_nbr 
  43         if length(M_.aux_vars) > 0
  44             ys = add_auxiliary_variables_to_steadystate(ys,M_.aux_vars, ...
  45                                                         M_.fname, ...
  46                                                         oo_.exo_steady_state, ...
  47                                                         oo_.exo_det_steady_state, ...
  48                                                         M_.params);
  49         else
  50             error([M_.fname '_steadystate.m doesn''t match the model']);
  51         end
  52     end
  53     oo_.steady_state = ys;
  54 end
  55 
  56 % Compute the residuals
  57 if options_.block && ~options_.bytecode
  58     z = zeros(M_.endo_nbr,1);
  59     for i = 1:length(M_.blocksMFS)
  60       [r, g, yy, var_indx] = feval([M_.fname '_static'],...
  61               i,...
  62               oo_.steady_state,...
  63               [oo_.exo_steady_state; ...
  64                oo_.exo_det_steady_state], M_.params);
  65       if isempty(M_.blocksMFS{i})
  66           idx = var_indx;
  67       else
  68           idx = M_.blocksMFS{i};
  69       end
  70       z(idx) = r;
  71     end
  72 elseif options_.block && options_.bytecode
  73     [check, z] = bytecode('evaluate','static');
  74     mexErrCheck('bytecode', check);
  75 else
  76     z = feval([M_.fname '_static'],...
  77               oo_.steady_state,...
  78               [oo_.exo_steady_state; ...
  79                oo_.exo_det_steady_state], M_.params);
  80 end
  81 
  82 % Display the non-zero residuals if no return value
  83   % Display the non-zero residuals if no return value
  84   
  85 tags = M_.equations_tags;
  86 
  87 if nargout == 0
  88     for i = 1:4
  89           disp(' ')
  90     end
  91   
  92     for i=1:length(z)
  93         if abs(z(i)) < options_.dynatol/100
  94             tmp = 0;
  95         else
  96             tmp = z(i);
  97         end
  98         if length(tags) == 0
  99             tg = {}
 100             ind = []
 101         else  
 102             tg = tags(cell2mat(tags(:,1)) == i,2:3); % all tags for equation i
 103             ind = strmatch( tagname, cellstr( tg(:,1) ) );
 104         end
 105 
 106         if length(ind) == 0
 107             disp(['Eq ' int2str(i) ' : ' num2str(tmp)])
 108         else
 109             t1 = tg( ind , 2 );
 110             s = cell2mat(t1);
 111             disp( ['Eq ', int2str(i) ,' : ', num2str(tmp) ,' : ' s])
 112         end
 113     end
 114     for i = 1:2
 115         disp(' ')
 116     end
 117 end
 118 
 119 %oo_.steady_state = steady_state_old;

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2010-11-25 14:12:16, 3.5 KB) [[attachment:resid_with_names.m]]
  • [get | view] (2010-11-25 15:20:51, 0.3 KB) [[attachment:select_from_table.m]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.