Home > . > kalman_transition_matrix.m

kalman_transition_matrix

PURPOSE ^

makes transition matrices out of ghx and ghu for Kalman filter

SYNOPSIS ^

function [A,B] = kalman_transition_matrix(dr)

DESCRIPTION ^

 makes transition matrices out of ghx and ghu for Kalman filter
 still needs to eliminate unobserved static variables
 order of variables s p b f p_1

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % makes transition matrices out of ghx and ghu for Kalman filter
0002 % still needs to eliminate unobserved static variables
0003 % order of variables s p b f p_1
0004 
0005 function [A,B] = kalman_transition_matrix(dr)
0006   global M_
0007   nx = size(dr.ghx,2)+dr.nfwrd+dr.nstatic;
0008   kstate = dr.kstate;
0009   ikx = [dr.nstatic+1:dr.nstatic+dr.npred];
0010   
0011   A = zeros(nx,nx);
0012   k0 = kstate(find(kstate(:,2) <= M_.maximum_lag+1),:);
0013   i0 = find(k0(:,2) == M_.maximum_lag+1);
0014   n0 = size(dr.ghx,1);
0015   A(1:n0,dr.nstatic+1:dr.nstatic+dr.npred) = dr.ghx(:,1:dr.npred);
0016   A(1:n0,dr.nstatic+dr.npred+dr.nfwrd+1:end) = dr.ghx(:,dr.npred+1:end);
0017   B = zeros(nx,M_.exo_nbr);
0018   B(1:n0,:) = dr.ghu;
0019   offset_col = dr.nstatic;
0020   for i=M_.maximum_lag:-1:2
0021     i1 = find(k0(:,2) == i);
0022     n1 = size(i1,1);
0023     j = zeros(n1,1);
0024     for j1 = 1:n1
0025       j(j1) = find(k0(i0,1)==k0(i1(j1),1));
0026     end
0027     if i == M_.maximum_lag-1
0028       offset_col = dr.nstatic+dr.nfwrd;
0029     end
0030     A(n0+i1-dr.npred,offset_col+i0(j))=eye(n1);
0031     i0 = i1;
0032   end

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