Add display of theoretical moments at order=3 with pruning
parent
ed8845c60f
commit
dfc7357636
|
@ -3816,8 +3816,9 @@ Computing the stochastic solution
|
||||||
``oo_.conditional_variance_decomposition_ME`` (see
|
``oo_.conditional_variance_decomposition_ME`` (see
|
||||||
:mvar:`oo_.conditional_variance_decomposition_ME`). The
|
:mvar:`oo_.conditional_variance_decomposition_ME`). The
|
||||||
variance decomposition is only conducted, if theoretical
|
variance decomposition is only conducted, if theoretical
|
||||||
moments are requested, *i.e.* using the ``periods=0``-option.
|
moments are requested, *i.e.* using the ``periods=0``-option.
|
||||||
In case of ``order=2``, Dynare provides a second-order accurate
|
Only available at ``order<3``. In case of ``order=2``,
|
||||||
|
Dynare provides a second-order accurate
|
||||||
approximation to the true second moments based on the linear
|
approximation to the true second moments based on the linear
|
||||||
terms of the second-order solution (see *Kim, Kim,
|
terms of the second-order solution (see *Kim, Kim,
|
||||||
Schaumburg and Sims (2008)*). Note that the unconditional
|
Schaumburg and Sims (2008)*). Note that the unconditional
|
||||||
|
@ -4013,9 +4014,10 @@ Computing the stochastic solution
|
||||||
|
|
||||||
|br| After a run of ``stoch_simul``, contains the
|
|br| After a run of ``stoch_simul``, contains the
|
||||||
variance-covariance of the endogenous variables. Contains
|
variance-covariance of the endogenous variables. Contains
|
||||||
theoretical variance if the ``periods`` option is not present (or
|
theoretical variance if the ``periods`` option is not present and simulated variance
|
||||||
an approximation thereof for ``order=2``), and simulated variance
|
otherwise. Only available for ``order<4``. At ``order=2`` it will be be
|
||||||
otherwise. The variables are arranged in declaration order.
|
a second-order accurate approximation. At ``order=3``, theoretical moments
|
||||||
|
are only available with ``pruning``. The variables are arranged in declaration order.
|
||||||
|
|
||||||
.. matvar:: oo_.var_list
|
.. matvar:: oo_.var_list
|
||||||
|
|
||||||
|
@ -4042,9 +4044,10 @@ Computing the stochastic solution
|
||||||
number of the matrix in the cell array corresponds to the order of
|
number of the matrix in the cell array corresponds to the order of
|
||||||
autocorrelation. The option ar specifies the number of
|
autocorrelation. The option ar specifies the number of
|
||||||
autocorrelation matrices available. Contains theoretical
|
autocorrelation matrices available. Contains theoretical
|
||||||
autocorrelations if the ``periods`` option is not present (or an
|
autocorrelations if the ``periods`` option is not present and simulated
|
||||||
approximation thereof for ``order=2``), and simulated
|
autocorrelations otherwise. Only available for ``order<4``. At ``order=2`` it will be be
|
||||||
autocorrelations otherwise. The field is only created if
|
a second-order accurate approximation. At ``order=3``, theoretical moments
|
||||||
|
are only available with ``pruning``. The field is only created if
|
||||||
stationary variables are present.
|
stationary variables are present.
|
||||||
|
|
||||||
The element ``oo_.autocorr{i}(k,l)`` is equal to the correlation
|
The element ``oo_.autocorr{i}(k,l)`` is equal to the correlation
|
||||||
|
@ -4082,9 +4085,10 @@ Computing the stochastic solution
|
||||||
If a second order approximation has been requested,
|
If a second order approximation has been requested,
|
||||||
contains the vector of the mean correction terms.
|
contains the vector of the mean correction terms.
|
||||||
|
|
||||||
In case ``order=2``, the theoretical second moments are a
|
Only available at ``order<4``. In case ``order=2``, the
|
||||||
second order accurate approximation of the true second
|
theoretical second moments are a second order accurate
|
||||||
moments, see conditional_variance_decomposition.
|
approximation of the true second moments. See conditional_variance_decomposition.
|
||||||
|
At ``order=3``, theoretical moments are only available with ``pruning``.
|
||||||
|
|
||||||
.. matvar:: oo_.variance_decomposition
|
.. matvar:: oo_.variance_decomposition
|
||||||
|
|
||||||
|
@ -4152,8 +4156,10 @@ Computing the stochastic solution
|
||||||
|br| After a run of ``stoch_simul`` with the
|
|br| After a run of ``stoch_simul`` with the
|
||||||
``contemporaneous_correlation option``, contains theoretical
|
``contemporaneous_correlation option``, contains theoretical
|
||||||
contemporaneous correlations if the ``periods`` option is not
|
contemporaneous correlations if the ``periods`` option is not
|
||||||
present (or an approximation thereof for ``order=2``), and
|
present, and simulated contemporaneous correlations otherwise.
|
||||||
simulated contemporaneous correlations otherwise. The variables
|
Only available for ``order<4``. At ``order=2`` it will be be
|
||||||
|
a second-order accurate approximation. At ``order=3``, theoretical moments
|
||||||
|
are only available with ``pruning``. The variables
|
||||||
are arranged in declaration order.
|
are arranged in declaration order.
|
||||||
|
|
||||||
.. matvar:: oo_.SpectralDensity
|
.. matvar:: oo_.SpectralDensity
|
||||||
|
|
|
@ -0,0 +1,126 @@
|
||||||
|
function oo_=disp_th_moments_order3(dr,M_,options_,i_var,oo_)
|
||||||
|
% oo_=disp_th_moments_order3(dr,M_,options_,i_var,oo_)
|
||||||
|
% Display theoretical moments of variables based on (third order) pruned
|
||||||
|
% state-space
|
||||||
|
%
|
||||||
|
% INPUTS:
|
||||||
|
% dr : Dynare decision rules structure
|
||||||
|
% M_ : Matlab's structure describing the Model (initialized by dynare, see @ref{M_}).
|
||||||
|
% options_ : Matlab's structure describing the options (initialized by dynare, see @ref{options_}).
|
||||||
|
% i_var : Index of requested variables in declaration order
|
||||||
|
% oo_ : Matlab's structure describing the Model (initialized by dynare, see @ref{M_}), containing
|
||||||
|
%
|
||||||
|
% OUTPUTS:
|
||||||
|
% oo_ : Matlab's structure describing the Model (initialized by dynare, see @ref{M_}), containing
|
||||||
|
% gamma_y [cell] Matlab cell of nar+1 arrays, where nar is the order of the autocorrelation function.
|
||||||
|
% gamma_y{1} [double] Covariance matrix.
|
||||||
|
% gamma_y{i+1} [double] Autocorrelation function (for i=1,...,options_.ar).
|
||||||
|
% mean [vector] Unconditional mean
|
||||||
|
% var [matrix] Unconditional covariance matrix
|
||||||
|
% autocorr [cell] Cell storing the theoretical autocorrelation
|
||||||
|
% contemporaneous_correlation [matrix] matrix of contemporaneous correlations
|
||||||
|
%
|
||||||
|
% Copyright (C) 2020 Dynare Team
|
||||||
|
%
|
||||||
|
% This file is part of Dynare.
|
||||||
|
%
|
||||||
|
% Dynare is free software: you can redistribute it and/or modify
|
||||||
|
% it under the terms of the GNU General Public License as published by
|
||||||
|
% the Free Software Foundation, either version 3 of the License, or
|
||||||
|
% (at your option) any later version.
|
||||||
|
%
|
||||||
|
% Dynare is distributed in the hope that it will be useful,
|
||||||
|
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
% GNU General Public License for more details.
|
||||||
|
%
|
||||||
|
% You should have received a copy of the GNU General Public License
|
||||||
|
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
|
if options_.one_sided_hp_filter || options_.hp_filter || options_.bandpass.indicator
|
||||||
|
error(['disp_th_moments:: theoretical moments incompatible with filtering. Use simulated moments instead'])
|
||||||
|
end
|
||||||
|
|
||||||
|
nvars=length(i_var);
|
||||||
|
obs_var=NaN(nvars,1);
|
||||||
|
for i=1:nvars
|
||||||
|
obs_var(i,1) = find(strcmp(M_.endo_names(i_var(i),:), M_.endo_names(dr.order_var)));
|
||||||
|
end
|
||||||
|
|
||||||
|
pruned_state_space = pruned_state_space_system(M_, options_, dr, obs_var, options_.ar, 1, 0);
|
||||||
|
|
||||||
|
|
||||||
|
m = pruned_state_space.E_y;
|
||||||
|
|
||||||
|
oo_.gamma_y{1} = pruned_state_space.Var_y;
|
||||||
|
|
||||||
|
i1 = find(abs(diag(oo_.gamma_y{1})) > 1e-12);
|
||||||
|
s2 = diag(oo_.gamma_y{1});
|
||||||
|
sd = sqrt(s2);
|
||||||
|
|
||||||
|
z = [ m sd s2 ];
|
||||||
|
oo_.mean = m;
|
||||||
|
oo_.var = oo_.gamma_y{1};
|
||||||
|
|
||||||
|
if ~options_.noprint %options_.nomoments == 0
|
||||||
|
title='THEORETICAL MOMENTS BASED ON PRUNED STATE SPACE';
|
||||||
|
headers={'VARIABLE','MEAN','STD. DEV.','VARIANCE'};
|
||||||
|
labels = M_.endo_names(i_var,:);
|
||||||
|
lh = cellofchararraymaxlength(labels)+2;
|
||||||
|
dyntable(options_,title,headers,labels,z,lh,11,4);
|
||||||
|
if options_.TeX
|
||||||
|
labels = M_.endo_names_tex(i_var,:);
|
||||||
|
lh = cellofchararraymaxlength(labels)+2;
|
||||||
|
dyn_latex_table(M_,options_,title,'th_moments',headers,labels,z,lh,11,4);
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if isempty(i1)
|
||||||
|
disp_verbose(' ',~options_.noprint)
|
||||||
|
disp_verbose('All endogenous are constant or non stationary, not displaying correlations and auto-correlations',~options_.noprint)
|
||||||
|
disp_verbose(' ',~options_.noprint)
|
||||||
|
return;
|
||||||
|
end
|
||||||
|
|
||||||
|
if options_.nocorr == 0 % && size(stationary_vars, 1) > 0
|
||||||
|
corr=pruned_state_space.Corr_y;
|
||||||
|
if options_.contemporaneous_correlation
|
||||||
|
oo_.contemporaneous_correlation = corr;
|
||||||
|
end
|
||||||
|
if ~options_.noprint
|
||||||
|
skipline()
|
||||||
|
title='MATRIX OF CORRELATIONS BASED ON PRUNED STATE SPACE';
|
||||||
|
labels = M_.endo_names(i_var,:);
|
||||||
|
headers = ['Variables';labels];
|
||||||
|
lh = cellofchararraymaxlength(labels)+2;
|
||||||
|
dyntable(options_,title,headers,labels,corr,lh,8,4);
|
||||||
|
if options_.TeX
|
||||||
|
labels = M_.endo_names_tex(i_var,:);
|
||||||
|
headers=['Variables';labels];
|
||||||
|
lh = cellofchararraymaxlength(labels)+2;
|
||||||
|
dyn_latex_table(M_,options_,title,'th_corr_matrix',headers,labels,corr,lh,8,4);
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if options_.ar > 0 %&& size(stationary_vars, 1) > 0
|
||||||
|
z=NaN(length(i1),options_.ar);
|
||||||
|
for i=1:options_.ar
|
||||||
|
oo_.gamma_y{i+1} = pruned_state_space.Corr_yi(:,:,i);
|
||||||
|
oo_.autocorr{i} = oo_.gamma_y{i+1};
|
||||||
|
z(:,i) = diag(oo_.gamma_y{i+1}(i1,i1));
|
||||||
|
end
|
||||||
|
if ~options_.noprint
|
||||||
|
skipline()
|
||||||
|
title='COEFFICIENTS OF AUTOCORRELATION BASED ON PRUNED STATE SPACE';
|
||||||
|
labels = M_.endo_names(i_var(i1),:);
|
||||||
|
headers = ['Order ';cellstr(int2str([1:options_.ar]'))];
|
||||||
|
lh = cellofchararraymaxlength(labels)+2;
|
||||||
|
dyntable(options_,title,headers,labels,z,lh,8,4);
|
||||||
|
if options_.TeX
|
||||||
|
labels = M_.endo_names_tex(i_var(i1),:);
|
||||||
|
lh = cellofchararraymaxlength(labels)+2;
|
||||||
|
dyn_latex_table(M_,options_,title,'th_autocorr_matrix',headers,labels,z,lh,8,4);
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -189,9 +189,11 @@ if ~options_.nomoments
|
||||||
if PI_PCL_solver
|
if PI_PCL_solver
|
||||||
PCL_Part_info_moments(0, PCL_varobs, oo_.dr, i_var);
|
PCL_Part_info_moments(0, PCL_varobs, oo_.dr, i_var);
|
||||||
elseif options_.periods == 0
|
elseif options_.periods == 0
|
||||||
% There is no code for theoretical moments at 3rd order
|
|
||||||
if options_.order <= 2
|
if options_.order <= 2
|
||||||
oo_=disp_th_moments(oo_.dr,var_list,M_,options_,oo_);
|
oo_=disp_th_moments(oo_.dr,var_list,M_,options_,oo_);
|
||||||
|
elseif options_.order == 3 && options_.pruning
|
||||||
|
% There is no code for theoretical moments at 3rd order without pruning
|
||||||
|
oo_=disp_th_moments_order3(oo_.dr,M_,options_,i_var,oo_);
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
oo_=disp_moments(oo_.endo_simul,var_list,M_,options_,oo_);
|
oo_=disp_moments(oo_.endo_simul,var_list,M_,options_,oo_);
|
||||||
|
|
|
@ -116,6 +116,6 @@ options_.solve_tolf=1E-12;
|
||||||
steady(solve_algo=3);
|
steady(solve_algo=3);
|
||||||
|
|
||||||
check;
|
check;
|
||||||
stoch_simul(order=3,pruning,irf=0,nocorr,nofunctions,nomoments) C I Y H r D K lambda phi;
|
stoch_simul(order=3,pruning,irf=0,nofunctions,contemporaneous_correlation,TeX) C I Y H r D K lambda phi;
|
||||||
|
|
||||||
comparison_policy_functions_dynare_mathematica;
|
comparison_policy_functions_dynare_mathematica;
|
Loading…
Reference in New Issue