Home > . > resol1.m

resol1

PURPOSE ^

Copyright (C) 2001 Michel Juillard

SYNOPSIS ^

function dr=resol1(ys,algo,linear,iorder)

DESCRIPTION ^

 Copyright (C) 2001 Michel Juillard

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % Copyright (C) 2001 Michel Juillard
0002 %
0003 function dr=resol1(ys,algo,linear,iorder)
0004 
0005 global M_  options_ oo_ bayestopt_
0006 global  it_  means_ stderrs_ dr1_test_
0007 
0008 dr1_test_ = zeros(2,1);
0009 
0010 if linear == 1
0011   iorder =1;
0012 end
0013 
0014 xlen = M_.maximum_lead + M_.maximum_lag + 1;
0015 klen = M_.maximum_lag + M_.maximum_lead + 1;
0016 iyv = M_.lead_lag_incidence';
0017 iyv = iyv(:);
0018 iyr0 = find(iyv) ;
0019 it_ = M_.maximum_lag + 1 ;
0020 
0021 if M_.exo_nbr == 0
0022   oo_.exo_steady_state = [] ;
0023 end
0024 
0025 if ~ M_.lead_lag_incidence(M_.maximum_lag+1,:) > 0
0026   error ('RESOL: Error in model specification: some variables don"t appear as current') ;
0027 end
0028 
0029 %if xlen > 1
0030 %  error (['RESOL: stochastic exogenous variables must appear only at the' ...
0031 %      ' current period. Use additional endogenous variables']) ;
0032 %end
0033 
0034 % check if ys is steady state
0035 tempex = oo_.exo_simul;
0036 oo_.exo_simul = repmat(transpose(oo_.exo_steady_state), M_.maximum_lag + ...
0037                M_.maximum_lead+1,1);
0038 fh = str2func([M_.fname '_static']);
0039 if max(abs(feval(fh,ys,oo_.exo_simul))) > options_.dynatol
0040   % dirty trick to call either user function or dynare_solve
0041   [dr.ys, cheik] = feval(bayestopt_.static_solve,[M_.fname '_static'],ys,oo_.exo_simul);
0042   if cheik
0043     dr1_test_(1) = 1; % dynare_solve did not converge to the steady state.
0044     resid = feval([M_.fname '_static'],dr.ys,oo_.exo_simul);
0045     dr1_test_(2) = resid'*resid; % penalty...
0046     disp('dynare_solve is unable to find the steady state.')
0047     return
0048   end
0049 else
0050   dr.ys = ys;
0051 end
0052 
0053 dr.fbias = zeros(M_.endo_nbr,1);
0054 dr = dr11(iorder,dr,0);
0055 
0056 if algo == 1 & iorder > 1
0057   dr.ys = dynare_solve('dr2',ys,dr);
0058   dr.fbias = 2*feval([M_.fname '_static'],dr.ys,oo_.exo_simul);
0059   dr = dr11(iorder,dr,0);
0060 end
0061 oo_.exo_simul = tempex;
0062 tempex = [];
0063 
0064 % 01/01/2003 MJ added dr_algo == 1
0065 % 08/24/2001 MJ uses Schmitt-Grohe and Uribe (2001) constant correction
0066 %               in dr.ghs2
0067 % 05/26/2003 MJ added temporary values for oo_.exo_simul
0068 % 01/22/2005 SA check --> cheik (to avoid confusion with the function check.m)

Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003