annualized_shock_decomposition.m: fix bug introduced in 735bd66d
Use dedicated indicator instead of nargout to only request decomposition; closes #1919dprior
parent
60e3b6a19f
commit
2ed416532b
|
@ -129,7 +129,7 @@ if realtime_==0
|
|||
myopts=options_;
|
||||
myopts.plot_shock_decomp.type='qoq';
|
||||
myopts.plot_shock_decomp.realtime=0;
|
||||
z = plot_shock_decomposition(M_,oo_,myopts,[]);
|
||||
z = plot_shock_decomposition(M_,oo_,myopts,[],true);
|
||||
else
|
||||
z = oo_;
|
||||
end
|
||||
|
@ -139,7 +139,7 @@ if realtime_==0
|
|||
myopts=options_;
|
||||
myopts.plot_shock_decomp.type='qoq';
|
||||
myopts.plot_shock_decomp.realtime=0;
|
||||
[y_aux, steady_state_aux] = plot_shock_decomposition(M_,oo_,myopts,aux.y);
|
||||
[y_aux, steady_state_aux] = plot_shock_decomposition(M_,oo_,myopts,aux.y,true);
|
||||
aux.y=y_aux;
|
||||
aux.yss=steady_state_aux;
|
||||
end
|
||||
|
@ -158,13 +158,13 @@ if realtime_ && isstruct(oo_) && isfield(oo_, 'realtime_shock_decomposition')
|
|||
myopts.plot_shock_decomp.realtime=1;
|
||||
myopts.plot_shock_decomp.vintage=i;
|
||||
% retrieve quarterly shock decomp
|
||||
z = plot_shock_decomposition(M_,oo_,myopts,[]);
|
||||
z = plot_shock_decomposition(M_,oo_,myopts,[],true);
|
||||
zdim = size(z);
|
||||
z = z(i_var,:,:);
|
||||
if isstruct(aux)
|
||||
if ischar(aux0.y)
|
||||
% retrieve quarterly shock decomp for aux variable
|
||||
[y_aux, steady_state_aux] = plot_shock_decomposition(M_,oo_,myopts,aux0.y);
|
||||
[y_aux, steady_state_aux] = plot_shock_decomposition(M_,oo_,myopts,aux0.y,true);
|
||||
aux.y=y_aux;
|
||||
aux.yss=steady_state_aux;
|
||||
end
|
||||
|
@ -185,13 +185,13 @@ if realtime_ && isstruct(oo_) && isfield(oo_, 'realtime_shock_decomposition')
|
|||
if qvintage_>i-4 && qvintage_<i
|
||||
myopts.plot_shock_decomp.vintage=qvintage_;
|
||||
% retrieve quarterly shock decomp
|
||||
z = plot_shock_decomposition(M_,oo_,myopts,[]);
|
||||
z = plot_shock_decomposition(M_,oo_,myopts,[],true);
|
||||
z(:,:,end+1:zdim(3))=nan; % fill with nan's remaining time points to reach Q4
|
||||
z = z(i_var,:,:);
|
||||
if isstruct(aux)
|
||||
if ischar(aux0.y)
|
||||
% retrieve quarterly shock decomp for aux variable
|
||||
[y_aux, steady_state_aux] = plot_shock_decomposition(M_,oo_,myopts,aux0.y);
|
||||
[y_aux, steady_state_aux] = plot_shock_decomposition(M_,oo_,myopts,aux0.y,true);
|
||||
y_aux(:,:,end+1:zdim(3))=nan; % fill with nan's remaining time points to reach Q4
|
||||
aux.y=y_aux;
|
||||
aux.yss=steady_state_aux;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
function [out, steady_state] = plot_shock_decomposition(M_,oo_,options_,varlist)
|
||||
function [out, steady_state] = plot_shock_decomposition(M_,oo_,options_,varlist,get_decomp_only)
|
||||
% function plot_shock_decomposition(M_,oo_,options_,varlist)
|
||||
% Plots the results of shock_decomposition
|
||||
%
|
||||
|
@ -7,11 +7,12 @@ function [out, steady_state] = plot_shock_decomposition(M_,oo_,options_,varlist)
|
|||
% oo_: [structure] Storage of results
|
||||
% options_: [structure] Options
|
||||
% varlist: [char] List of variables
|
||||
%
|
||||
% get_decomp_only [bool] indicator on whether to only return with
|
||||
% basic decomposition (required for e.g. annualized_shock_decomposition)
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright © 2016-2019 Dynare Team
|
||||
% Copyright © 2016-2023 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -28,6 +29,10 @@ function [out, steady_state] = plot_shock_decomposition(M_,oo_,options_,varlist)
|
|||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
if nargin<5
|
||||
get_decomp_only=false;
|
||||
end
|
||||
|
||||
options_.nodisplay = options_.plot_shock_decomp.nodisplay;
|
||||
options_.graph_format = options_.plot_shock_decomp.graph_format;
|
||||
|
||||
|
@ -532,7 +537,7 @@ if steadystate
|
|||
options_.plot_shock_decomp.steady_state=steady_state;
|
||||
end
|
||||
|
||||
if nargout == 2
|
||||
if get_decomp_only
|
||||
out=z(i_var,:,:);
|
||||
steady_state = steady_state(i_var);
|
||||
return
|
||||
|
|
Loading…
Reference in New Issue