Disentangle computation and display of conditional_variance_decomposition
Previously, noprint suppressed the computation of conditional_variance_decomposition although it should only suppress its display. Also adds a dedicated field for the unconditional variance decomposition.time-shift
parent
4a8e737c7a
commit
6eb3a3d3ad
|
@ -50,43 +50,54 @@ z = [ m sd s2 ];
|
||||||
oo_.mean = m;
|
oo_.mean = m;
|
||||||
oo_.var = oo_.gamma_y{1};
|
oo_.var = oo_.gamma_y{1};
|
||||||
|
|
||||||
if ~options_.noprint %options_.nomoments == 0
|
if M_.exo_nbr > 1 && size(stationary_vars, 1) > 0
|
||||||
if options_.order == 2
|
oo_.variance_decomposition=100*oo_.gamma_y{options_.ar+2};
|
||||||
title='APROXIMATED THEORETICAL MOMENTS';
|
if ~options_.noprint %options_.nomoments == 0
|
||||||
else
|
|
||||||
title='THEORETICAL MOMENTS';
|
|
||||||
end
|
|
||||||
if options_.hp_filter
|
|
||||||
title = [title ' (HP filter, lambda = ' num2str(options_.hp_filter) ')'];
|
|
||||||
end
|
|
||||||
headers=char('VARIABLE','MEAN','STD. DEV.','VARIANCE');
|
|
||||||
labels = deblank(M_.endo_names(ivar,:));
|
|
||||||
lh = size(labels,2)+2;
|
|
||||||
dyntable(title,headers,labels,z,lh,11,4);
|
|
||||||
if M_.exo_nbr > 1 && size(stationary_vars, 1) > 0
|
|
||||||
skipline()
|
|
||||||
if options_.order == 2
|
if options_.order == 2
|
||||||
title='APPROXIMATED VARIANCE DECOMPOSITION (in percent)';
|
title='APROXIMATED THEORETICAL MOMENTS';
|
||||||
else
|
else
|
||||||
title='VARIANCE DECOMPOSITION (in percent)';
|
title='THEORETICAL MOMENTS';
|
||||||
end
|
end
|
||||||
if options_.hp_filter
|
if options_.hp_filter
|
||||||
title = [title ' (HP filter, lambda = ' ...
|
title = [title ' (HP filter, lambda = ' num2str(options_.hp_filter) ')'];
|
||||||
num2str(options_.hp_filter) ')'];
|
|
||||||
end
|
end
|
||||||
headers = M_.exo_names;
|
headers=char('VARIABLE','MEAN','STD. DEV.','VARIANCE');
|
||||||
headers(M_.exo_names_orig_ord,:) = headers;
|
labels = deblank(M_.endo_names(ivar,:));
|
||||||
headers = char(' ',headers);
|
lh = size(labels,2)+2;
|
||||||
lh = size(deblank(M_.endo_names(ivar(stationary_vars),:)),2)+2;
|
dyntable(title,headers,labels,z,lh,11,4);
|
||||||
dyntable(title,headers,deblank(M_.endo_names(ivar(stationary_vars), ...
|
|
||||||
:)),100*oo_.gamma_y{options_.ar+2}(stationary_vars,:),lh,8,2);
|
skipline()
|
||||||
|
if options_.order == 2
|
||||||
|
title='APPROXIMATED VARIANCE DECOMPOSITION (in percent)';
|
||||||
|
else
|
||||||
|
title='VARIANCE DECOMPOSITION (in percent)';
|
||||||
|
end
|
||||||
|
if options_.hp_filter
|
||||||
|
title = [title ' (HP filter, lambda = ' ...
|
||||||
|
num2str(options_.hp_filter) ')'];
|
||||||
|
end
|
||||||
|
headers = M_.exo_names;
|
||||||
|
headers(M_.exo_names_orig_ord,:) = headers;
|
||||||
|
headers = char(' ',headers);
|
||||||
|
lh = size(deblank(M_.endo_names(ivar(stationary_vars),:)),2)+2;
|
||||||
|
dyntable(title,headers,deblank(M_.endo_names(ivar(stationary_vars), ...
|
||||||
|
:)),100*oo_.gamma_y{options_.ar+2}(stationary_vars,:),lh,8,2);
|
||||||
end
|
end
|
||||||
|
|
||||||
conditional_variance_steps = options_.conditional_variance_decomposition;
|
conditional_variance_steps = options_.conditional_variance_decomposition;
|
||||||
if length(conditional_variance_steps)
|
if length(conditional_variance_steps)
|
||||||
oo_ = display_conditional_variance_decomposition(conditional_variance_steps,...
|
StateSpaceModel.number_of_state_equations = M_.endo_nbr;
|
||||||
ivar,dr,M_, ...
|
StateSpaceModel.number_of_state_innovations = M_.exo_nbr;
|
||||||
options_,oo_);
|
StateSpaceModel.sigma_e_is_diagonal = M_.sigma_e_is_diagonal;
|
||||||
|
[StateSpaceModel.transition_matrix,StateSpaceModel.impulse_matrix] = kalman_transition_matrix(dr,(1:M_.endo_nbr)',M_.nstatic+(1:M_.nspred)',M_.exo_nbr);
|
||||||
|
StateSpaceModel.state_innovations_covariance_matrix = M_.Sigma_e;
|
||||||
|
StateSpaceModel.order_var = dr.order_var;
|
||||||
|
oo_.conditional_variance_decomposition = conditional_variance_decomposition(StateSpaceModel,conditional_variance_steps,ivar);
|
||||||
|
|
||||||
|
if options_.noprint == 0
|
||||||
|
display_conditional_variance_decomposition(oo_.conditional_variance_decomposition,conditional_variance_steps,...
|
||||||
|
ivar,M_,options_);
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,22 +1,19 @@
|
||||||
function oo_ = display_conditional_variance_decomposition(Steps, SubsetOfVariables, dr,M_,options_,oo_)
|
function display_conditional_variance_decomposition(conditional_decomposition_array,Steps,SubsetOfVariables,M_,options_)
|
||||||
% This function computes the conditional variance decomposition of a given state space model
|
% This function displays the conditional variance decomposition of a given state space model
|
||||||
% for a subset of endogenous variables.
|
% for a subset of endogenous variables.
|
||||||
%
|
%
|
||||||
% INPUTS
|
% INPUTS
|
||||||
% StateSpaceModel [structure] Specification of the state space model.
|
% conditional_decomposition_array [matrix] Output matrix from compute_conditional_variance_decomposition
|
||||||
% Steps [integer] 1*h vector of dates.
|
% Steps [integer] 1*h vector of dates.
|
||||||
% SubsetOfVariables [integer] 1*q vector of indices.
|
% SubsetOfVariables [integer] 1*q vector of indices.
|
||||||
%
|
% M_ [structure] Dynare structure containing the
|
||||||
|
% Model description
|
||||||
|
% options_ [structure] Dynare structure containing the
|
||||||
|
% options
|
||||||
% OUTPUTS
|
% OUTPUTS
|
||||||
% PackedConditionalVarianceDecomposition [double] n(n+1)/2*p matrix, where p is the number of state innovations and
|
% none
|
||||||
% n is equal to length(SubsetOfVariables).
|
|
||||||
%
|
%
|
||||||
% SPECIAL REQUIREMENTS
|
% Copyright (C) 2010-2014 Dynare Team
|
||||||
%
|
|
||||||
% [1] The covariance matrix of the state innovations needs to be diagonal.
|
|
||||||
% [2] In this version, absence of measurement errors is assumed...
|
|
||||||
|
|
||||||
% Copyright (C) 2010-2013 Dynare Team
|
|
||||||
%
|
%
|
||||||
% This file is part of Dynare.
|
% This file is part of Dynare.
|
||||||
%
|
%
|
||||||
|
@ -33,49 +30,28 @@ function oo_ = display_conditional_variance_decomposition(Steps, SubsetOfVariabl
|
||||||
% You should have received a copy of the GNU General Public License
|
% You should have received a copy of the GNU General Public License
|
||||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
endo_nbr = M_.endo_nbr;
|
if options_.order == 2
|
||||||
exo_nbr = M_.exo_nbr;
|
skipline()
|
||||||
StateSpaceModel.number_of_state_equations = M_.endo_nbr;
|
disp('APPROXIMATED CONDITIONAL VARIANCE DECOMPOSITION (in percent)')
|
||||||
StateSpaceModel.number_of_state_innovations = exo_nbr;
|
else
|
||||||
StateSpaceModel.sigma_e_is_diagonal = M_.sigma_e_is_diagonal;
|
skipline()
|
||||||
|
disp('CONDITIONAL VARIANCE DECOMPOSITION (in percent)')
|
||||||
iv = (1:endo_nbr)';
|
|
||||||
ic = M_.nstatic+(1:M_.nspred)';
|
|
||||||
|
|
||||||
[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;
|
|
||||||
|
|
||||||
conditional_decomposition_array = conditional_variance_decomposition(StateSpaceModel,Steps,SubsetOfVariables );
|
|
||||||
|
|
||||||
if options_.noprint == 0
|
|
||||||
if options_.order == 2
|
|
||||||
skipline()
|
|
||||||
disp('APPROXIMATED CONDITIONAL VARIANCE DECOMPOSITION (in percent)')
|
|
||||||
else
|
|
||||||
skipline()
|
|
||||||
disp('CONDITIONAL VARIANCE DECOMPOSITION (in percent)')
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
vardec_i = zeros(length(SubsetOfVariables),exo_nbr);
|
vardec_i = zeros(length(SubsetOfVariables),M_.exo_nbr);
|
||||||
|
|
||||||
for i=1:length(Steps)
|
for i=1:length(Steps)
|
||||||
disp(['Period ' int2str(Steps(i)) ':'])
|
disp(['Period ' int2str(Steps(i)) ':'])
|
||||||
|
|
||||||
for j=1:exo_nbr
|
for j=1:M_.exo_nbr
|
||||||
vardec_i(:,j) = 100*conditional_decomposition_array(:, ...
|
vardec_i(:,j) = 100*conditional_decomposition_array(:, ...
|
||||||
i,j);
|
i,j);
|
||||||
end
|
end
|
||||||
if options_.noprint == 0
|
headers = M_.exo_names;
|
||||||
headers = M_.exo_names;
|
headers(M_.exo_names_orig_ord,:) = headers;
|
||||||
headers(M_.exo_names_orig_ord,:) = headers;
|
headers = char(' ',headers);
|
||||||
headers = char(' ',headers);
|
lh = size(deblank(M_.endo_names(SubsetOfVariables,:)),2)+2;
|
||||||
lh = size(deblank(M_.endo_names(SubsetOfVariables,:)),2)+2;
|
dyntable('',headers,...
|
||||||
dyntable('',headers,...
|
deblank(M_.endo_names(SubsetOfVariables,:)),...
|
||||||
deblank(M_.endo_names(SubsetOfVariables,:)),...
|
vardec_i,lh,8,2);
|
||||||
vardec_i,lh,8,2);
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
oo_.conditional_variance_decomposition = conditional_decomposition_array;
|
|
Loading…
Reference in New Issue