Home > matlab > forcst2.m

forcst2

PURPOSE ^

Copyright (C) 2008-2010 Dynare Team

SYNOPSIS ^

function yf=forcst2(y0,horizon,dr,n)

DESCRIPTION ^

 Copyright (C) 2008-2010 Dynare Team

 This file is part of Dynare.

 Dynare is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.

 Dynare is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with Dynare.  If not, see <http://www.gnu.org/licenses/>.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function yf=forcst2(y0,horizon,dr,n)
0002 
0003 % Copyright (C) 2008-2010 Dynare Team
0004 %
0005 % This file is part of Dynare.
0006 %
0007 % Dynare is free software: you can redistribute it and/or modify
0008 % it under the terms of the GNU General Public License as published by
0009 % the Free Software Foundation, either version 3 of the License, or
0010 % (at your option) any later version.
0011 %
0012 % Dynare is distributed in the hope that it will be useful,
0013 % but WITHOUT ANY WARRANTY; without even the implied warranty of
0014 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0015 % GNU General Public License for more details.
0016 %
0017 % You should have received a copy of the GNU General Public License
0018 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
0019 
0020 global M_ options_
0021 
0022 Sigma_e_ = M_.Sigma_e;
0023 endo_nbr = M_.endo_nbr;
0024 exo_nbr = M_.exo_nbr;
0025 ykmin_ = M_.maximum_endo_lag;
0026 
0027 order = options_.order;
0028 
0029 k1 = [ykmin_:-1:1];
0030 k2 = dr.kstate(find(dr.kstate(:,2) <= ykmin_+1),[1 2]);
0031 k2 = k2(:,1)+(ykmin_+1-k2(:,2))*endo_nbr;
0032 
0033 it_ = ykmin_ + 1 ;
0034 
0035 % eliminate shocks with 0 variance
0036 i_exo_var = setdiff([1:exo_nbr],find(diag(Sigma_e_) == 0));
0037 nxs = length(i_exo_var);
0038 
0039 chol_S = chol(Sigma_e_(i_exo_var,i_exo_var));
0040 
0041 if ~isempty(Sigma_e_)
0042     e = randn(nxs,n,horizon);
0043 end
0044 
0045 B1 = dr.ghu(:,i_exo_var)*chol_S';
0046 
0047 yf = zeros(endo_nbr,horizon+ykmin_,n);
0048 yf(:,1:ykmin_,:,:) = repmat(y0,[1,1,n]);
0049 
0050 j = ykmin_*endo_nbr;
0051 for i=ykmin_+(1:horizon)
0052     tempx1 = reshape(yf(:,k1,:),[j,n]);
0053     tempx = tempx1(k2,:);
0054     yf(:,i,:) = dr.ghx*tempx+B1*squeeze(e(:,:,i-ykmin_));
0055     k1 = k1+1;
0056 end
0057 
0058 yf(dr.order_var,:,:) = yf;
0059 yf=permute(yf,[2 1 3]);

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