Home > matlab > evaluate_steady_state_file.m

evaluate_steady_state_file

PURPOSE ^

function [ys,params1,info] = evaluate_steady_state_file(ys_init,exo_ss,M,options)

SYNOPSIS ^

function [ys,params,info] = evaluate_steady_state_file(ys_init,exo_ss,M,options)

DESCRIPTION ^

 function [ys,params1,info] = evaluate_steady_state_file(ys_init,exo_ss,M,options)
 Evaluates steady state files 
  
 INPUTS
   ys_init                   vector           initial values used to compute the steady
                                                 state
   exo_ss                    vector           exogenous steady state
   M                         struct           model parameters
   options                   struct           options
  
 OUTPUTS
   ys                        vector           steady state
   params1                   vector           model parameters possibly
                                              modified by user steadystate
                                              function
   info                      2x1 vector       error codes

 SPECIAL REQUIREMENTS
   none

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [ys,params,info] = evaluate_steady_state_file(ys_init,exo_ss,M,options)
0002 % function [ys,params1,info] = evaluate_steady_state_file(ys_init,exo_ss,M,options)
0003 % Evaluates steady state files
0004 %
0005 % INPUTS
0006 %   ys_init                   vector           initial values used to compute the steady
0007 %                                                 state
0008 %   exo_ss                    vector           exogenous steady state
0009 %   M                         struct           model parameters
0010 %   options                   struct           options
0011 %
0012 % OUTPUTS
0013 %   ys                        vector           steady state
0014 %   params1                   vector           model parameters possibly
0015 %                                              modified by user steadystate
0016 %                                              function
0017 %   info                      2x1 vector       error codes
0018 %
0019 % SPECIAL REQUIREMENTS
0020 %   none
0021 
0022 % Copyright (C) 2001-2012 Dynare Team
0023 %
0024 % This file is part of Dynare.
0025 %
0026 % Dynare is free software: you can redistribute it and/or modify
0027 % it under the terms of the GNU General Public License as published by
0028 % the Free Software Foundation, either version 3 of the License, or
0029 % (at your option) any later version.
0030 %
0031 % Dynare is distributed in the hope that it will be useful,
0032 % but WITHOUT ANY WARRANTY; without even the implied warranty of
0033 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0034 % GNU General Public License for more details.
0035 %
0036 % You should have received a copy of the GNU General Public License
0037 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
0038 
0039     ys = [];
0040     params = [];
0041     info = 0; 
0042     params = M.params;
0043     fname = M.fname;
0044     if options.steadystate_flag == 1
0045         % old format
0046         assignin('base','tmp_00_',params);
0047         evalin('base','M_.params=tmp_00_; clear(''tmp_00_'')');
0048         h_steadystate = str2func([fname '_steadystate']);                       
0049         [ys,check] = h_steadystate(ys_init, exo_ss);
0050         params1 = evalin('base','M_.params');
0051     else % steadystate_flag == 2
0052          % new format
0053         h_steadystate = str2func([fname '_steadystate2']);                       
0054         [ys,params1,check] = h_steadystate(ys_init, exo_ss, params);
0055     end            
0056     
0057     if check
0058         info(1) = 19
0059         info(2) = NaN;
0060     end
0061     
0062     updated_params_flag = max(abs(params1-params)) > 1e-12 || ~isequal(isnan(params1),isnan(params)); %checks whether numbers or NaN changed
0063 
0064     if  isnan(updated_params_flag) || (updated_params_flag  && any(isnan(params(~isnan(params))-params1(~isnan(params))))) %checks if new NaNs were added
0065         info(1) = 24;
0066         info(2) = NaN;
0067         return
0068     end
0069 
0070     if updated_params_flag && ~isreal(params1)
0071         info(1) = 23;
0072         info(2) = sum(imag(params).^2);
0073         return
0074     end
0075     
0076     if updated_params_flag
0077         params = params1;
0078     end
0079 
0080     % adding values for auxiliary variables
0081     if length(M.aux_vars) > 0 && ~options.ramsey_policy
0082         h_set_auxiliary_variables = str2func([M.fname '_set_auxiliary_variables']);
0083         ys = h_set_auxiliary_variables(ys,exo_ss,params);
0084     end
0085 
0086     check1 = 0;
0087     if ~options.steadystate.nocheck
0088         % Check whether the steady state obtained from the _steadystate file is a steady state.
0089         [residuals,check] = evaluate_static_model(ys,exo_ss,params,M,options);
0090         if check
0091             info(1) = 19;
0092             info(2) = check; % to be improved
0093             return;
0094         end
0095         if max(abs(residuals)) > options.dynatol.f
0096             info(1) = 19;
0097             info(2) = residuals'*residuals;
0098             return
0099         end
0100     elseif ~isempty(options.steadystate_partial)
0101         ssvar = options.steadystate_partial.ssvar;
0102         nov   = length(ssvar);
0103         indv  = zeros(nov,1);
0104         for i = 1:nov
0105             indv(i) = strmatch(ssvar(i),M.endo_names,'exact');
0106         end
0107         [ys,check] = dynare_solve('restricted_steadystate',...
0108                                   ys(indv),...
0109                                   options.jacobian_flag, ...
0110                                   exo_ss,indv);
0111     end
0112 
0113

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