


Inversion of the extended path simulation approach. This routine computes the innovations needed to
reproduce the time path of a subset of endogenous variables.
INPUTS
o x [double] n*1 vector, time t innovations.
o y [double] n*1 vector, time t restricted endogenous variables.
o ix [integer] index of control innovations in the full vector of innovations.
o iy [integer] index of controlled variables in the full vector of endogenous variables.
o s [double] m*1 vector, endogenous variables at time t-1.
OUTPUTS
o r [double] n*1 vector of residuals.
ALGORITHM
SPECIAL REQUIREMENTS

0001 function r = ep_residuals(x, y, ix, iy, steadystate, dr, maximum_lag, endo_nbr) 0002 % Inversion of the extended path simulation approach. This routine computes the innovations needed to 0003 % reproduce the time path of a subset of endogenous variables. 0004 % 0005 % INPUTS 0006 % o x [double] n*1 vector, time t innovations. 0007 % o y [double] n*1 vector, time t restricted endogenous variables. 0008 % o ix [integer] index of control innovations in the full vector of innovations. 0009 % o iy [integer] index of controlled variables in the full vector of endogenous variables. 0010 % o s [double] m*1 vector, endogenous variables at time t-1. 0011 % 0012 % 0013 % OUTPUTS 0014 % o r [double] n*1 vector of residuals. 0015 % 0016 % ALGORITHM 0017 % 0018 % SPECIAL REQUIREMENTS 0019 0020 % Copyright (C) 2010 Dynare Team. 0021 % 0022 % This file is part of Dynare. 0023 % 0024 % Dynare is free software: you can redistribute it and/or modify 0025 % it under the terms of the GNU General Public License as published by 0026 % the Free Software Foundation, either version 3 of the License, or 0027 % (at your option) any later version. 0028 % 0029 % Dynare is distributed in the hope that it will be useful, 0030 % but WITHOUT ANY WARRANTY; without even the implied warranty of 0031 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0032 % GNU General Public License for more details. 0033 % 0034 % You should have received a copy of the GNU General Public License 0035 % along with Dynare. If not, see <http://www.gnu.org/licenses/>. 0036 0037 global oo_ 0038 0039 persistent k1 k2 weight 0040 0041 if isempty(k1) 0042 k1 = [maximum_lag:-1:1]; 0043 k2 = dr.kstate(find(dr.kstate(:,2) <= maximum_lag+1),[1 2]); 0044 k2 = k2(:,1)+(maximum_lag+1-k2(:,2))*endo_nbr; 0045 weight = 0.0; 0046 end 0047 0048 verbose = 0; 0049 0050 % Copy the shocks in exo_simul. 0051 oo_.exo_simul(maximum_lag+1,ix) = exp(transpose(x)); 0052 exo_simul = log(oo_.exo_simul); 0053 0054 % Compute the initial solution path for the endogenous variables using a first order approximation. 0055 if verbose 0056 disp('ep_residuals:: Set initial condition for endogenous variable paths.') 0057 end 0058 initial_path = oo_.endo_simul; 0059 for i = maximum_lag+1:size(oo_.exo_simul) 0060 tempx1 = oo_.endo_simul(dr.order_var,k1); 0061 tempx2 = bsxfun(@minus,tempx1,dr.ys(dr.order_var)); 0062 tempx = tempx2(k2); 0063 initial_path(dr.order_var,i) = dr.ys(dr.order_var)+dr.ghx*tempx2(k2)+dr.ghu*transpose(exo_simul(i,:)); 0064 k1 = k1+1; 0065 end 0066 oo_.endo_simul = weight*initial_path + (1-weight)*oo_.endo_simul; 0067 0068 info = perfect_foresight_simulation(dr,steadystate); 0069 if verbose>1 0070 info 0071 info.iterations.errors 0072 end 0073 0074 r = y-transpose(oo_.endo_simul(maximum_lag+1,iy)); 0075 0076 %(re)Set k1 (indices for the initial conditions) 0077 k1 = [maximum_lag:-1:1];