Commit 22d5bd16 authored by Michel Juillard's avatar Michel Juillard
Browse files

removed useless auxiliary variables from call to kalman_transition_matrix()

parent bff8de83
......@@ -93,7 +93,7 @@ for i=M_.maximum_lag:-1:2
i0 = i1;
end
Gamma = zeros(nvar,cutoff+1);
[A,B] = kalman_transition_matrix(dr,ikx',1:nx,dr.transition_auxiliary_variables,M_.exo_nbr);
[A,B] = kalman_transition_matrix(dr,ikx',1:nx,M_.exo_nbr);
[vx, u] = lyapunov_symm(A,B*M_.Sigma_e*B',options_.qz_criterium,options_.lyapunov_complex_threshold);
iky = iv(ivar);
if ~isempty(u)
......
......@@ -42,7 +42,7 @@ StateSpaceModel.sigma_e_is_diagonal = M_.sigma_e_is_diagonal;
iv = (1:endo_nbr)';
ic = dr.nstatic+(1:dr.npred)';
[StateSpaceModel.transition_matrix,StateSpaceModel.impulse_matrix] = kalman_transition_matrix(dr,iv,ic,[],exo_nbr);
[StateSpaceModel.transition_matrix,StateSpaceModel.impulse_matrix] = kalman_transition_matrix(dr,iv,ic,exo_nbr);
StateSpaceModel.state_innovations_covariance_matrix = M_.Sigma_e;
StateSpaceModel.order_var = dr.order_var;
......
......@@ -111,10 +111,6 @@ for file = 1:NumberOfDrawsFiles
npred = dr.npred;
iv = (1:endo_nbr)';
ic = [ nstatic+(1:npred) endo_nbr+(1:size(dr.ghx,2)-npred) ]';
aux = dr.transition_auxiliary_variables;
k = find(aux(:,2) > npred);
aux(:,2) = aux(:,2) + nstatic;
aux(k,2) = aux(k,2) + dr.nfwrd;
StateSpaceModel.number_of_state_equations = M_.endo_nbr+rows(aux);
StateSpaceModel.number_of_state_innovations = M_.exo_nbr;
StateSpaceModel.sigma_e_is_diagonal = M_.sigma_e_is_diagonal;
......@@ -122,7 +118,7 @@ for file = 1:NumberOfDrawsFiles
first_call = 0;
clear('endo_nbr','nstatic','npred','k');
end
[StateSpaceModel.transition_matrix,StateSpaceModel.impulse_matrix] = kalman_transition_matrix(dr,iv,ic,aux,M_.exo_nbr);
[StateSpaceModel.transition_matrix,StateSpaceModel.impulse_matrix] = kalman_transition_matrix(dr,iv,ic,M_.exo_nbr);
StateSpaceModel.state_innovations_covariance_matrix = M_.Sigma_e;
clear('dr');
Conditional_decomposition_array(:,:,:,linea) = conditional_variance_decomposition(StateSpaceModel, Steps, ivar);
......
......@@ -43,7 +43,7 @@ npred = dr.npred;
nc = size(dr.ghx,2);
endo_nbr = M_.endo_nbr;
inv_order_var = dr.inv_order_var;
[A,B] = kalman_transition_matrix(dr,nstatic+(1:npred),1:nc,dr.transition_auxiliary_variables,M_.exo_nbr);
[A,B] = kalman_transition_matrix(dr,nstatic+(1:npred),1:nc,M_.exo_nbr);
if size(var_list,1) == 0
var_list = M_.endo_names(1:M_.orig_endo_nbr,:);
......
......@@ -43,7 +43,7 @@ ghu = dr.ghu(i_var,:);
nc = size(ghx,2);
n = length(i_var);
[A,B] = kalman_transition_matrix(dr,nstatic+(1:npred),1:nc,dr.transition_auxiliary_variables,M_.exo_nbr);
[A,B] = kalman_transition_matrix(dr,nstatic+(1:npred),1:nc,M_.exo_nbr);
[vx,u] = lyapunov_symm(A,B*Sigma_e*B',options_.qz_criterium,options_.lyapunov_complex_threshold);
......
function [A,B] = kalman_transition_matrix(dr,iv,ic,aux,exo_nbr)
function [A,B] = kalman_transition_matrix(dr,iv,ic,exo_nbr)
%function [A,B] = kalman_transition_matrix(dr,iv,ic,exo_nbr)
% Builds the transition equation of the state space representation out of ghx and ghu for Kalman filter
%
% INPUTS
% dr: structure of decisions rules for stochastic simulations
% iv: selected variables
% ic: state variables position in the transition matrix columns
% aux: indices for auxiliary equations
% exo_nbr: number of exogenous variables
%
% OUTPUTS
......@@ -33,47 +33,14 @@ function [A,B] = kalman_transition_matrix(dr,iv,ic,aux,exo_nbr)
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
n_iv = length(iv);
n_ir1 = size(aux,1);
nr = n_iv + n_ir1;
A = zeros(nr,nr);
A = zeros(n_iv,n_iv);
i_n_iv = 1:n_iv;
A(i_n_iv,ic) = dr.ghx(iv,:);
if n_ir1 > 0
A(n_iv+1:end,:) = sparse(aux(:,1),aux(:,2),ones(n_ir1,1),n_ir1,nr);
end
if nargout>1
B = zeros(nr,exo_nbr);
B = zeros(n_iv,exo_nbr);
B(i_n_iv,:) = dr.ghu(iv,:);
end
% $$$ function [A,B] = kalman_transition_matrix(dr)
% $$$ global M_
% $$$ nx = size(dr.ghx,2)+dr.nfwrd+dr.nstatic;
% $$$ kstate = dr.kstate;
% $$$ ikx = [dr.nstatic+1:dr.nstatic+dr.npred];
% $$$
% $$$ A = zeros(nx,nx);
% $$$ k0 = kstate(find(kstate(:,2) <= M_.maximum_lag+1),:);
% $$$ i0 = find(k0(:,2) == M_.maximum_lag+1);
% $$$ n0 = size(dr.ghx,1);
% $$$ A(1:n0,dr.nstatic+1:dr.nstatic+dr.npred) = dr.ghx(:,1:dr.npred);
% $$$ A(1:n0,dr.nstatic+dr.npred+dr.nfwrd+1:end) = dr.ghx(:,dr.npred+1:end);
% $$$ B = zeros(nx,M_.exo_nbr);
% $$$ B(1:n0,:) = dr.ghu;
% $$$ offset_col = dr.nstatic;
% $$$ for i=M_.maximum_lag:-1:2
% $$$ i1 = find(k0(:,2) == i);
% $$$ n1 = size(i1,1);
% $$$ j = zeros(n1,1);
% $$$ for j1 = 1:n1
% $$$ j(j1) = find(k0(i0,1)==k0(i1(j1),1));
% $$$ end
% $$$ if i == M_.maximum_lag-1
% $$$ offset_col = dr.nstatic+dr.nfwrd;
% $$$ end
% $$$ A(n0+i1-dr.npred,offset_col+i0(j))=eye(n1);
% $$$ i0 = i1;
% $$$ end
......@@ -114,7 +114,7 @@ elseif iorder == 2
end
end
[A,B] = kalman_transition_matrix(dr,nstatic+(1:npred),1:nc,dr.transition_auxiliary_variables,M_.exo_nbr);
[A,B] = kalman_transition_matrix(dr,nstatic+(1:npred),1:nc,M_.exo_nbr);
inv_order_var = dr.inv_order_var;
ghx1 = dr.ghx(inv_order_var(ivar),:);
......
......@@ -92,7 +92,7 @@ b = ghu1*M_.Sigma_e*ghu1';
ipred = nstatic+(1:npred)';
% state space representation for state variables only
[A,B] = kalman_transition_matrix(dr,ipred,1:nx,dr.transition_auxiliary_variables,M_.exo_nbr);
[A,B] = kalman_transition_matrix(dr,ipred,1:nx,M_.exo_nbr);
% Compute stationary variables (before HP filtering),
% and compute 2nd order mean correction on stationary variables (in case of
% HP filtering, this mean correction is computed *before* filtering)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment