Measuring the Effects of a Shock to Monetary Policy - Humboldt ...
Measuring the Effects of a Shock to Monetary Policy - Humboldt ...
Measuring the Effects of a Shock to Monetary Policy - Humboldt ...
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
98 Bayesian FAVARs with Agnostic Identification<br />
%%%%% start kalman filter<br />
% Setting Dimensions<br />
[T,var] = size(Y_Data);<br />
[H_row,H_col] = size(H_Prior); % has <strong>to</strong> equal size <strong>of</strong> Lam_bar<br />
[Xsi_row,Xsi_col] = size(Xsi_Prior);<br />
[G_row,G_col] = size(G_Prior);<br />
[Q_row,Q_col] = size(Q_Prior);<br />
[R_row,R_col] = size(R_Prior);<br />
km = Xsi_col/13;<br />
kmd = Xsi_col;<br />
%Variables for State-Space<br />
Y_t = Y_Data;<br />
H_t = H_Prior;<br />
G = G_Prior;<br />
R = R_Prior;<br />
Q = Q_Prior;<br />
vecQ = reshape(Q,Q_row^2,1);<br />
% Sequence <strong>of</strong> draws <strong>to</strong> be s<strong>to</strong>red in Xsi_all and P_all<br />
Xsi_all = zeros(T,((K+M)*d));<br />
P_all = zeros(((K+M)*d)^2,T);<br />
%invI = inv(eye(size(Xsi_Prior,1)^2) - kron(G,G));<br />
%vecP_Prior = invI * vecQ;<br />
%P_Prior = reshape(vecP_Prior,size(Xsi_row,1),size(Xsi_row,1));<br />
% Initialization <strong>the</strong> state vec<strong>to</strong>rs variance-covariance matrix<br />
%Xsi_Prior = zeros(Xsi_row,1); % could be taken in case <strong>of</strong> no initial value<br />
%P_Prior = eye(Xsi_row); % could be taken in case <strong>of</strong> no initial value<br />
Xsi_tlag = Xsi_Prior;<br />
P_tlag = P_Prior;<br />
% Final Draws <strong>to</strong> be s<strong>to</strong>red in Xsi_F and P_F<br />
Xsi_F = zeros(Xsi_row,Xsi_col);<br />
P_F = zeros(Xsi_row^2,T);<br />
for t=1:T<br />
%=======================================================%<br />
% Updating equations (Kim&Nelson) %<br />
%*******************************************************%<br />
Eta_tlag = Y_t(t,:)’ - H_t * Xsi_tlag(1:(K+M)); %<br />
f_tlag = H_t * P_tlag(1:(K+M),1:(K+M)) * H_t’ + R;%<br />
if_tlag = inv(f_tlag); %<br />
%if_tlag = pinv(f_tlag); %<br />
K_t = P_tlag(:,1:(K+M)) * H_t’ * if_tlag; %<br />
% %<br />
Xsi_tt = Xsi_tlag + K_t * Eta_tlag; %<br />
P_tt = P_tlag - K_t * H_t * P_tlag(1:(K+M),:); %<br />
%=======================================================%<br />
%-------------------------------------------------------%<br />
%=======================================================%<br />
% Prediction equation (Kim&Nelson) %<br />
%*******************************************************%