Home > matlab > partial_information > PCL_Part_info_irf.m

PCL_Part_info_irf

PURPOSE ^

sets up parameters and calls part-info kalman filter

SYNOPSIS ^

function y=PCL_Part_info_irf( H, varobs, ivar, M_, dr, irfpers,ii)

DESCRIPTION ^

 sets up parameters and calls part-info kalman filter
 developed by G Perendia, July 2006 for implementation from notes by Prof. Joe Pearlman to 
 suit partial information RE solution in accordance with, and based on, the 
 Pearlman, Currie and Levine 1986 solution.
 22/10/06 - Version 2 for new Riccati with 4 params instead 5

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function  y=PCL_Part_info_irf( H, varobs, ivar, M_, dr, irfpers,ii)
0002 % sets up parameters and calls part-info kalman filter
0003 % developed by G Perendia, July 2006 for implementation from notes by Prof. Joe Pearlman to
0004 % suit partial information RE solution in accordance with, and based on, the
0005 % Pearlman, Currie and Levine 1986 solution.
0006 % 22/10/06 - Version 2 for new Riccati with 4 params instead 5
0007 
0008 % Copyright (C) 2006-2011 Dynare Team
0009 %
0010 % This file is part of Dynare.
0011 %
0012 % Dynare is free software: you can redistribute it and/or modify
0013 % it under the terms of the GNU General Public License as published by
0014 % the Free Software Foundation, either version 3 of the License, or
0015 % (at your option) any later version.
0016 %
0017 % Dynare is distributed in the hope that it will be useful,
0018 % but WITHOUT ANY WARRANTY; without even the implied warranty of
0019 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0020 % GNU General Public License for more details.
0021 %
0022 % You should have received a copy of the GNU General Public License
0023 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
0024 
0025 
0026 % Recall that the state space is given by the
0027 % predetermined variables s(t-1), x(t-1)
0028 % and the jump variables x(t).
0029 % The jump variables have dimension NETA
0030 
0031 
0032 OBS = [];
0033 for i=1:rows(varobs)
0034     OBS = [OBS find(strcmp(deblank(varobs(i,:)), cellstr(M_.endo_names))) ];
0035 end
0036 NOBS = length(OBS);
0037 
0038 G1=dr.PI_ghx;
0039 impact=dr.PI_ghu;
0040 nmat=dr.PI_nmat;
0041 CC=dr.PI_CC;
0042 NX=M_.exo_nbr; % no of exogenous varexo shock variables.
0043 FL_RANK=dr.PI_FL_RANK;
0044 NY=M_.endo_nbr;
0045 LL = sparse(1:NOBS,OBS,ones(NOBS,1),NY,NY);
0046 
0047 ss=size(G1,1);
0048 pd=ss-size(nmat,1);
0049 SDX=M_.Sigma_e^0.5; % =SD,not V-COV, of Exog shocks or M_.Sigma_e^0.5 num_exog x num_exog matrix
0050 if isempty(H)
0051     H=M_.H;
0052 end
0053 VV=H; % V-COV of observation errors.
0054 MM=impact*SDX; % R*(Q^0.5) in standard KF notation
0055                % observation vector indices
0056                % mapping to endogenous variables.
0057 
0058 L1=LL*dr.PI_TT1;
0059 L2=LL*dr.PI_TT2;
0060 
0061 MM1=MM(1:ss-FL_RANK,:);
0062 U11=MM1*MM1';
0063 % SDX
0064 
0065 U22=0;
0066 % determine K1 and K2 observation mapping matrices
0067 % This uses the fact that measurements are given by L1*s(t)+L2*x(t)
0068 % and s(t) is expressed in the dynamics as
0069 % H1*eps(t)+G11*s(t-1)+G12*x(t-1)+G13*x(t).
0070 % Thus the observations o(t) can be written in the form
0071 % o(t)=K1*[eps(t)' s(t-1)' x(t-1)']' + K2*x(t) where
0072 % K1=[L1*H1 L1*G11 L1*G12] K2=L1*G13+L2
0073 
0074 G12=G1(NX+1:ss-2*FL_RANK,:);
0075 KK1=L1*G12;
0076 K1=KK1(:,1:ss-FL_RANK);
0077 K2=KK1(:,ss-FL_RANK+1:ss)+L2;
0078 
0079 %pre calculate time-invariant factors
0080 A11=G1(1:pd,1:pd);
0081 A22=G1(pd+1:end, pd+1:end);
0082 A12=G1(1:pd, pd+1:end);
0083 A21=G1(pd+1:end,1:pd);
0084 Lambda= nmat*A12+A22;
0085 I_L=inv(Lambda);
0086 BB=A12*inv(A22);
0087 FF=K2*inv(A22);       
0088 QQ=BB*U22*BB' + U11;        
0089 UFT=U22*FF';
0090 AA=A11-BB*A21;
0091 CCCC=A11-A12*nmat; % F in new notation
0092 DD=K1-FF*A21; % H in new notation
0093 EE=K1-K2*nmat;
0094 RR=FF*UFT+VV;
0095 if ~any(RR) 
0096     % if zero add some dummy measurement err. variance-covariances
0097     % with diagonals 0.000001. This would not be needed if we used
0098     % the slow solver, or the generalised eigenvalue approach,
0099     % but these are both slower.
0100     RR=eye(size(RR,1))*1.0e-6;
0101 end
0102 SS=BB*UFT;
0103 VKLUFT=VV+K2*I_L*UFT;
0104 ALUFT=A12*I_L*UFT;
0105 FULKV=FF*U22*I_L'*K2'+VV;
0106 FUBT=FF*U22*BB';
0107 nmat=nmat;
0108 % initialise pshat
0109 AQDS=AA*QQ*DD'+SS;
0110 DQDR=DD*QQ*DD'+RR;
0111 I_DQDR=inv(DQDR);
0112 AQDQ=AQDS*I_DQDR;
0113 ff=AA-AQDQ*DD;
0114 hh=AA*QQ*AA'-AQDQ*AQDS';%*(DD*QQ*AA'+SS');
0115 rr=DD*QQ*DD'+RR;
0116 ZSIG0=disc_riccati_fast(ff,DD,rr,hh);
0117 PP=ZSIG0 +QQ;
0118 
0119 exo_names=M_.exo_names(M_.exo_names_orig_ord,:);
0120 
0121 DPDR=DD*PP*DD'+RR;
0122 I_DPDR=inv(DPDR);
0123 PDIDPDRD=PP*DD'*I_DPDR*DD;
0124 GG=[CCCC (AA-CCCC)*(eye(ss-FL_RANK)-PDIDPDRD); zeros(ss-FL_RANK) AA*(eye(ss-FL_RANK)-PDIDPDRD)];
0125 imp=[impact(1:ss-FL_RANK,:); impact(1:ss-FL_RANK,:)];
0126 
0127 % Calculate IRFs of observable series
0128 I_PD=(eye(ss-FL_RANK)-PDIDPDRD);
0129 LL0=[ EE (DD-EE)*I_PD];
0130 VV = [  dr.PI_TT1 dr.PI_TT2];
0131 stderr=diag(M_.Sigma_e^0.5);        
0132 irfmat=zeros(size(dr.PI_TT1 ,1),irfpers+1);
0133 irfst=zeros(size(GG,1),irfpers+1); 
0134 irfst(:,1)=stderr(ii)*imp(:,ii);
0135 for jj=2:irfpers+1;
0136     irfst(:,jj)=GG*irfst(:,jj-1);
0137     irfmat(:,jj-1)=VV*irfst(NX+1:ss-FL_RANK,jj);
0138 end   
0139 y = irfmat(:,1:irfpers);
0140 
0141 save ([M_.fname '_PCL_PtInfoIRFs_' num2str(ii) '_' deblank(exo_names(ii,:))], 'irfmat','irfst');

Generated on Tue 22-May-2012 02:40:23 by m2html © 2005