commit
768555b523
|
@ -120,6 +120,7 @@ elseif q2a.plot ~= 2
|
||||||
end
|
end
|
||||||
|
|
||||||
% end initialize names
|
% end initialize names
|
||||||
|
steady_state=steady_state(i_var);
|
||||||
|
|
||||||
if realtime_==0
|
if realtime_==0
|
||||||
% usual shock decomp
|
% usual shock decomp
|
||||||
|
@ -143,7 +144,6 @@ if realtime_==0
|
||||||
aux.yss=steady_state_aux;
|
aux.yss=steady_state_aux;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
steady_state=steady_state(i_var);
|
|
||||||
% make annualized shock decomp
|
% make annualized shock decomp
|
||||||
[z, steady_state_a, steady_state_ga] = annualiz(z,t0,q2a,aux,steady_state);
|
[z, steady_state_a, steady_state_ga] = annualiz(z,t0,q2a,aux,steady_state);
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,7 +10,7 @@ function expand_group(use_shock_groups,var_list_, ic)
|
||||||
% SPECIAL REQUIREMENTS
|
% SPECIAL REQUIREMENTS
|
||||||
% none
|
% none
|
||||||
|
|
||||||
% Copyright (C) 2016-2017 Dynare Team
|
% Copyright (C) 2016-2018 Dynare Team
|
||||||
%
|
%
|
||||||
% This file is part of Dynare.
|
% This file is part of Dynare.
|
||||||
%
|
%
|
||||||
|
@ -27,6 +27,8 @@ function expand_group(use_shock_groups,var_list_, ic)
|
||||||
% 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/>.
|
||||||
|
|
||||||
|
filename = get(gcf,'filename');
|
||||||
|
[filepath, name, ext]=fileparts(filename);
|
||||||
M = evalin('base','M_');
|
M = evalin('base','M_');
|
||||||
oo = evalin('base','oo_');
|
oo = evalin('base','oo_');
|
||||||
options = evalin('base','options_');
|
options = evalin('base','options_');
|
||||||
|
@ -39,9 +41,12 @@ options.first_obs=mydata.first_obs;
|
||||||
options.nobs=mydata.nobs;
|
options.nobs=mydata.nobs;
|
||||||
% define expanded group
|
% define expanded group
|
||||||
label = mydata.shock_group.label;
|
label = mydata.shock_group.label;
|
||||||
|
label = strrep(label,' ','_');
|
||||||
|
label = strrep(label,'-','_');
|
||||||
shocks = mydata.shock_group.shocks;
|
shocks = mydata.shock_group.shocks;
|
||||||
options.plot_shock_decomp.fig_name = [mydata.fig_name '. Expand'];
|
options.plot_shock_decomp.fig_name = [mydata.fig_name '. Expand'];
|
||||||
options.plot_shock_decomp.use_shock_groups = strrep(label,' ','_'); %[use_shock_groups_old int2str(ic)];
|
options.plot_shock_decomp.use_shock_groups = label; %[use_shock_groups_old int2str(ic)];
|
||||||
|
options.plot_shock_decomp.filepath = filepath;
|
||||||
for j=1:length(shocks)
|
for j=1:length(shocks)
|
||||||
M.shock_groups.(options.plot_shock_decomp.use_shock_groups).(['group' int2str(j)]).label=shocks{j};
|
M.shock_groups.(options.plot_shock_decomp.use_shock_groups).(['group' int2str(j)]).label=shocks{j};
|
||||||
M.shock_groups.(options.plot_shock_decomp.use_shock_groups).(['group' int2str(j)]).shocks=shocks(j);
|
M.shock_groups.(options.plot_shock_decomp.use_shock_groups).(['group' int2str(j)]).shocks=shocks(j);
|
||||||
|
@ -49,4 +54,16 @@ end
|
||||||
|
|
||||||
options.plot_shock_decomp.interactive=0;
|
options.plot_shock_decomp.interactive=0;
|
||||||
options.plot_shock_decomp.expand=1;
|
options.plot_shock_decomp.expand=1;
|
||||||
|
options.plot_shock_decomp.nodisplay=0;
|
||||||
|
options.plot_shock_decomp.write_xls=0;
|
||||||
|
%% set optimal colormap
|
||||||
|
func = @(x) colorspace('RGB->Lab',x);
|
||||||
|
MAP = distinguishable_colors(length(shocks)+1,'w',func);
|
||||||
|
MAP(end,:) = [0.7 0.7 0.7];
|
||||||
|
|
||||||
|
options.plot_shock_decomp.colormap = MAP;
|
||||||
|
|
||||||
|
options.plot_shock_decomp.endo_names = mydata.endo_names;
|
||||||
|
options.plot_shock_decomp.endo_names_tex = mydata.endo_names_tex;
|
||||||
|
|
||||||
plot_shock_decomposition(M,oo,options,var_list_);
|
plot_shock_decomposition(M,oo,options,var_list_);
|
||||||
|
|
|
@ -28,7 +28,9 @@ function []=graph_decomp(z,shock_names,endo_names,i_var,initial_date,DynareModel
|
||||||
% 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/>.
|
||||||
|
|
||||||
GraphDirectoryName = CheckPath('graphs',DynareModel.dname);
|
if ~DynareOptions.plot_shock_decomp.expand
|
||||||
|
GraphDirectoryName = CheckPath('graphs',DynareModel.dname);
|
||||||
|
end
|
||||||
new_colormap = DynareOptions.plot_shock_decomp.colormap;
|
new_colormap = DynareOptions.plot_shock_decomp.colormap;
|
||||||
|
|
||||||
% number of components equals number of shocks + 1 (initial conditions)
|
% number of components equals number of shocks + 1 (initial conditions)
|
||||||
|
@ -87,7 +89,7 @@ end
|
||||||
nvar = length(i_var);
|
nvar = length(i_var);
|
||||||
|
|
||||||
%% write LaTeX-Header
|
%% write LaTeX-Header
|
||||||
if DynareOptions.TeX && any(strcmp('eps',cellstr(DynareOptions.plot_shock_decomp.graph_format)))
|
if DynareOptions.TeX && any(strcmp('eps',cellstr(DynareOptions.plot_shock_decomp.graph_format))) && ~DynareOptions.plot_shock_decomp.expand
|
||||||
fidTeX = fopen([GraphDirectoryName, filesep, DynareModel.fname '_shock_decomp' fig_mode1 fig_name '.tex'],'w');
|
fidTeX = fopen([GraphDirectoryName, filesep, DynareModel.fname '_shock_decomp' fig_mode1 fig_name '.tex'],'w');
|
||||||
fprintf(fidTeX,'%% TeX eps-loader file generated by Dynare''s graph_decomp.m.\n');
|
fprintf(fidTeX,'%% TeX eps-loader file generated by Dynare''s graph_decomp.m.\n');
|
||||||
fprintf(fidTeX,['%% ' datestr(now,0) '\n']);
|
fprintf(fidTeX,['%% ' datestr(now,0) '\n']);
|
||||||
|
@ -197,6 +199,9 @@ for j=1:nvar
|
||||||
mydata.plot_shock_decomp = DynareOptions.plot_shock_decomp;
|
mydata.plot_shock_decomp = DynareOptions.plot_shock_decomp;
|
||||||
mydata.first_obs = DynareOptions.first_obs;
|
mydata.first_obs = DynareOptions.first_obs;
|
||||||
mydata.nobs = DynareOptions.nobs;
|
mydata.nobs = DynareOptions.nobs;
|
||||||
|
mydata.plot_shock_decomp.zfull = DynareOptions.plot_shock_decomp.zfull(i_var(j),:,:);
|
||||||
|
mydata.endo_names = endo_names{i_var(j)};
|
||||||
|
mydata.endo_names_tex = DynareModel.endo_names_tex{i_var(j)};
|
||||||
if ~isempty(mydata.shock_group.shocks)
|
if ~isempty(mydata.shock_group.shocks)
|
||||||
c = uicontextmenu;
|
c = uicontextmenu;
|
||||||
hl.UIContextMenu=c;
|
hl.UIContextMenu=c;
|
||||||
|
@ -216,6 +221,8 @@ for j=1:nvar
|
||||||
colormap(new_colormap)
|
colormap(new_colormap)
|
||||||
end
|
end
|
||||||
hold off
|
hold off
|
||||||
|
if ~DynareOptions.plot_shock_decomp.expand
|
||||||
|
|
||||||
dyn_saveas(fhandle,[GraphDirectoryName, filesep, DynareModel.fname,'_shock_decomposition_',endo_names{i_var(j)},fig_mode1,fig_name],DynareOptions.plot_shock_decomp.nodisplay,DynareOptions.plot_shock_decomp.graph_format);
|
dyn_saveas(fhandle,[GraphDirectoryName, filesep, DynareModel.fname,'_shock_decomposition_',endo_names{i_var(j)},fig_mode1,fig_name],DynareOptions.plot_shock_decomp.nodisplay,DynareOptions.plot_shock_decomp.graph_format);
|
||||||
if DynareOptions.TeX && any(strcmp('eps',cellstr(DynareOptions.plot_shock_decomp.graph_format)))
|
if DynareOptions.TeX && any(strcmp('eps',cellstr(DynareOptions.plot_shock_decomp.graph_format)))
|
||||||
fprintf(fidTeX,'\\begin{figure}[H]\n');
|
fprintf(fidTeX,'\\begin{figure}[H]\n');
|
||||||
|
@ -226,10 +233,14 @@ for j=1:nvar
|
||||||
fprintf(fidTeX,'\\end{figure}\n');
|
fprintf(fidTeX,'\\end{figure}\n');
|
||||||
fprintf(fidTeX,' \n');
|
fprintf(fidTeX,' \n');
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
dyn_saveas(fhandle,[DynareOptions.plot_shock_decomp.filepath, filesep, DynareModel.fname,'_shock_decomposition_',endo_names{i_var(j)},fig_mode1,fig_name],DynareOptions.plot_shock_decomp.nodisplay,DynareOptions.plot_shock_decomp.graph_format);
|
||||||
|
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
%% write LaTeX-Footer
|
%% write LaTeX-Footer
|
||||||
if DynareOptions.TeX && any(strcmp('eps',cellstr(DynareOptions.plot_shock_decomp.graph_format)))
|
if DynareOptions.TeX && any(strcmp('eps',cellstr(DynareOptions.plot_shock_decomp.graph_format))) && ~DynareOptions.plot_shock_decomp.expand
|
||||||
fprintf(fidTeX,' \n');
|
fprintf(fidTeX,' \n');
|
||||||
fprintf(fidTeX,'%% End of TeX file.\n');
|
fprintf(fidTeX,'%% End of TeX file.\n');
|
||||||
fclose(fidTeX);
|
fclose(fidTeX);
|
||||||
|
|
|
@ -28,7 +28,9 @@ function []=graph_decomp_detail(z,shock_names,endo_names,i_var,initial_date,Dyna
|
||||||
% 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/>.
|
||||||
|
|
||||||
GraphDirectoryName = CheckPath('graphs',DynareModel.dname);
|
if ~DynareOptions.plot_shock_decomp.expand
|
||||||
|
GraphDirectoryName = CheckPath('graphs',DynareModel.dname);
|
||||||
|
end
|
||||||
% interactive = 0;
|
% interactive = 0;
|
||||||
fig_mode='';
|
fig_mode='';
|
||||||
fig_mode1='';
|
fig_mode1='';
|
||||||
|
@ -108,7 +110,7 @@ end
|
||||||
nvar = length(i_var);
|
nvar = length(i_var);
|
||||||
|
|
||||||
%% write LaTeX-Header
|
%% write LaTeX-Header
|
||||||
if DynareOptions.TeX && any(strcmp('eps',cellstr(DynareOptions.plot_shock_decomp.graph_format)))
|
if DynareOptions.TeX && any(strcmp('eps',cellstr(DynareOptions.plot_shock_decomp.graph_format))) && ~DynareOptions.plot_shock_decomp.expand
|
||||||
fidTeX = fopen([GraphDirectoryName, filesep, DynareModel.fname '_shock_decomp' fig_mode1 fig_name '_detail.tex'],'w');
|
fidTeX = fopen([GraphDirectoryName, filesep, DynareModel.fname '_shock_decomp' fig_mode1 fig_name '_detail.tex'],'w');
|
||||||
fprintf(fidTeX,'%% TeX eps-loader file generated by Dynare''s graph_decomp_detail.m.\n');
|
fprintf(fidTeX,'%% TeX eps-loader file generated by Dynare''s graph_decomp_detail.m.\n');
|
||||||
fprintf(fidTeX,['%% ' datestr(now,0) '\n']);
|
fprintf(fidTeX,['%% ' datestr(now,0) '\n']);
|
||||||
|
@ -199,6 +201,9 @@ for j=1:nvar
|
||||||
mydata.plot_shock_decomp = DynareOptions.plot_shock_decomp;
|
mydata.plot_shock_decomp = DynareOptions.plot_shock_decomp;
|
||||||
mydata.first_obs = DynareOptions.first_obs;
|
mydata.first_obs = DynareOptions.first_obs;
|
||||||
mydata.nobs = DynareOptions.nobs;
|
mydata.nobs = DynareOptions.nobs;
|
||||||
|
mydata.plot_shock_decomp.zfull = DynareOptions.plot_shock_decomp.zfull(i_var(j),:,:);
|
||||||
|
mydata.endo_names = endo_names{i_var(j)};
|
||||||
|
mydata.endo_names_tex = DynareModel.endo_names_tex{i_var(j)};
|
||||||
if ~isempty(mydata.shock_group.shocks)
|
if ~isempty(mydata.shock_group.shocks)
|
||||||
c = uicontextmenu;
|
c = uicontextmenu;
|
||||||
hax.UIContextMenu=c;
|
hax.UIContextMenu=c;
|
||||||
|
@ -241,6 +246,7 @@ for j=1:nvar
|
||||||
else
|
else
|
||||||
suffix = ['_detail'];
|
suffix = ['_detail'];
|
||||||
end
|
end
|
||||||
|
if ~DynareOptions.plot_shock_decomp.expand
|
||||||
dyn_saveas(fhandle,[GraphDirectoryName, filesep, DynareModel.fname, ...
|
dyn_saveas(fhandle,[GraphDirectoryName, filesep, DynareModel.fname, ...
|
||||||
'_shock_decomposition_', endo_names{i_var(j)}, fig_mode1,fig_name suffix],DynareOptions.plot_shock_decomp.nodisplay,DynareOptions.plot_shock_decomp.graph_format);
|
'_shock_decomposition_', endo_names{i_var(j)}, fig_mode1,fig_name suffix],DynareOptions.plot_shock_decomp.nodisplay,DynareOptions.plot_shock_decomp.graph_format);
|
||||||
if DynareOptions.TeX && any(strcmp('eps',cellstr(DynareOptions.plot_shock_decomp.graph_format)))
|
if DynareOptions.TeX && any(strcmp('eps',cellstr(DynareOptions.plot_shock_decomp.graph_format)))
|
||||||
|
@ -252,11 +258,15 @@ for j=1:nvar
|
||||||
fprintf(fidTeX,'\\end{figure}\n');
|
fprintf(fidTeX,'\\end{figure}\n');
|
||||||
fprintf(fidTeX,' \n');
|
fprintf(fidTeX,' \n');
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
dyn_saveas(fhandle,[DynareOptions.plot_shock_decomp.filepath, filesep, DynareModel.fname,'_shock_decomposition_',endo_names{i_var(j)},fig_mode1,fig_name suffix],DynareOptions.plot_shock_decomp.nodisplay,DynareOptions.plot_shock_decomp.graph_format);
|
||||||
|
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
%% write LaTeX-Footer
|
%% write LaTeX-Footer
|
||||||
if DynareOptions.TeX && any(strcmp('eps',cellstr(DynareOptions.plot_shock_decomp.graph_format)))
|
if DynareOptions.TeX && any(strcmp('eps',cellstr(DynareOptions.plot_shock_decomp.graph_format))) && ~DynareOptions.plot_shock_decomp.expand
|
||||||
fprintf(fidTeX,' \n');
|
fprintf(fidTeX,' \n');
|
||||||
fprintf(fidTeX,'%% End of TeX file.\n');
|
fprintf(fidTeX,'%% End of TeX file.\n');
|
||||||
fclose(fidTeX);
|
fclose(fidTeX);
|
||||||
|
|
|
@ -394,6 +394,7 @@ if ~isempty(indx_moment)
|
||||||
% For single legend search which has maximum nbr of restrictions
|
% For single legend search which has maximum nbr of restrictions
|
||||||
maxijv=0;
|
maxijv=0;
|
||||||
for ij=1:nbr_moment_restrictions
|
for ij=1:nbr_moment_restrictions
|
||||||
|
endo_prior_restrictions.moment{ij,3} = sort(endo_prior_restrictions.moment{ij,3});
|
||||||
if length(endo_prior_restrictions.moment{ij,3})>maxijv
|
if length(endo_prior_restrictions.moment{ij,3})>maxijv
|
||||||
maxij=ij;maxijv=length(endo_prior_restrictions.moment{ij,3});
|
maxij=ij;maxijv=length(endo_prior_restrictions.moment{ij,3});
|
||||||
end
|
end
|
||||||
|
@ -477,6 +478,7 @@ if ~isempty(indx_moment)
|
||||||
% end
|
% end
|
||||||
end
|
end
|
||||||
for ij=1:nbr_moment_couples
|
for ij=1:nbr_moment_couples
|
||||||
|
time_matrix{ij} = sort(time_matrix{ij});
|
||||||
if length(time_matrix{ij})>1
|
if length(time_matrix{ij})>1
|
||||||
if ~DynareOptions.nograph
|
if ~DynareOptions.nograph
|
||||||
itmp = (find(plot_indx==ij));
|
itmp = (find(plot_indx==ij));
|
||||||
|
@ -505,7 +507,7 @@ if ~isempty(indx_moment)
|
||||||
hold off
|
hold off
|
||||||
axis(a)
|
axis(a)
|
||||||
box on
|
box on
|
||||||
set(gca,'xtick',sort(time_matrix{ij}))
|
% set(gca,'xtick',sort(time_matrix{ij}))
|
||||||
itmp = min(itmp);
|
itmp = min(itmp);
|
||||||
title([endo_prior_restrictions.moment{itmp,1},' vs ',endo_prior_restrictions.moment{itmp,2}],'interpreter','none'),
|
title([endo_prior_restrictions.moment{itmp,1},' vs ',endo_prior_restrictions.moment{itmp,2}],'interpreter','none'),
|
||||||
end
|
end
|
||||||
|
|
|
@ -50,6 +50,7 @@ if isfield(options_.plot_shock_decomp,'expand') % private trap for uimenu calls
|
||||||
expand=options_.plot_shock_decomp.expand;
|
expand=options_.plot_shock_decomp.expand;
|
||||||
else
|
else
|
||||||
expand=0;
|
expand=0;
|
||||||
|
options_.plot_shock_decomp.expand=0;
|
||||||
end
|
end
|
||||||
|
|
||||||
if ~isempty(options_.plot_shock_decomp.fig_name)
|
if ~isempty(options_.plot_shock_decomp.fig_name)
|
||||||
|
@ -90,42 +91,67 @@ end
|
||||||
switch realtime_
|
switch realtime_
|
||||||
|
|
||||||
case 0
|
case 0
|
||||||
|
if ~expand
|
||||||
z = oo_.shock_decomposition;
|
z = oo_.shock_decomposition;
|
||||||
|
end
|
||||||
fig_name1=fig_name;
|
fig_name1=fig_name;
|
||||||
|
|
||||||
case 1 % realtime
|
case 1 % realtime
|
||||||
if vintage_
|
if vintage_
|
||||||
|
if ~expand
|
||||||
z = oo_.realtime_shock_decomposition.(['time_' int2str(vintage_)]);
|
z = oo_.realtime_shock_decomposition.(['time_' int2str(vintage_)]);
|
||||||
|
end
|
||||||
fig_name1=[fig_name ' realtime (vintage ' char(initial_date+vintage_-1) ')'];
|
fig_name1=[fig_name ' realtime (vintage ' char(initial_date+vintage_-1) ')'];
|
||||||
else
|
else
|
||||||
|
if ~expand
|
||||||
z = oo_.realtime_shock_decomposition.pool;
|
z = oo_.realtime_shock_decomposition.pool;
|
||||||
|
end
|
||||||
fig_name1=[fig_name ' realtime (rolling)'];
|
fig_name1=[fig_name ' realtime (rolling)'];
|
||||||
end
|
end
|
||||||
|
|
||||||
case 2 % conditional
|
case 2 % conditional
|
||||||
if vintage_
|
if vintage_
|
||||||
|
if ~expand
|
||||||
z = oo_.realtime_conditional_shock_decomposition.(['time_' int2str(vintage_)]);
|
z = oo_.realtime_conditional_shock_decomposition.(['time_' int2str(vintage_)]);
|
||||||
|
end
|
||||||
initial_date = initial_date+vintage_-1;
|
initial_date = initial_date+vintage_-1;
|
||||||
fig_name1=[fig_name ' ' int2str(forecast_) '-step ahead conditional forecast (given ' char(initial_date) ')'];
|
fig_name1=[fig_name ' ' int2str(forecast_) '-step ahead conditional forecast (given ' char(initial_date) ')'];
|
||||||
else
|
else
|
||||||
|
if ~expand
|
||||||
z = oo_.conditional_shock_decomposition.pool;
|
z = oo_.conditional_shock_decomposition.pool;
|
||||||
|
end
|
||||||
fig_name1=[fig_name ' 1-step ahead conditional forecast (rolling)'];
|
fig_name1=[fig_name ' 1-step ahead conditional forecast (rolling)'];
|
||||||
end
|
end
|
||||||
|
|
||||||
case 3 % forecast
|
case 3 % forecast
|
||||||
if vintage_
|
if vintage_
|
||||||
|
if ~expand
|
||||||
z = oo_.realtime_forecast_shock_decomposition.(['time_' int2str(vintage_)]);
|
z = oo_.realtime_forecast_shock_decomposition.(['time_' int2str(vintage_)]);
|
||||||
|
end
|
||||||
initial_date = initial_date+vintage_-1;
|
initial_date = initial_date+vintage_-1;
|
||||||
fig_name1=[fig_name ' ' int2str(forecast_) '-step ahead forecast (given ' char(initial_date) ')'];
|
fig_name1=[fig_name ' ' int2str(forecast_) '-step ahead forecast (given ' char(initial_date) ')'];
|
||||||
else
|
else
|
||||||
|
if ~expand
|
||||||
z = oo_.realtime_forecast_shock_decomposition.pool;
|
z = oo_.realtime_forecast_shock_decomposition.pool;
|
||||||
|
end
|
||||||
fig_name1=[fig_name ' 1-step ahead forecast (rolling)'];
|
fig_name1=[fig_name ' 1-step ahead forecast (rolling)'];
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
steady_state = oo_.steady_state;
|
if isfield(oo_.dr,'ys')
|
||||||
|
steady_state = oo_.dr.ys;
|
||||||
|
else
|
||||||
|
steady_state = oo_.steady_state;
|
||||||
|
end
|
||||||
|
|
||||||
if isequal(type,'aoa') && isstruct(q2a) && realtime_
|
if isequal(type,'aoa') && isstruct(q2a)
|
||||||
|
if expand
|
||||||
|
za = options_.plot_shock_decomp.zfull;
|
||||||
|
genda = size(za,3);
|
||||||
|
endo_nbra = size(za,1);
|
||||||
|
[za, shock_names, M_] = make_the_groups(za,genda,endo_nbra,nshocks,M_, options_);
|
||||||
|
end
|
||||||
|
if realtime_
|
||||||
% take all dates where realtime is saved
|
% take all dates where realtime is saved
|
||||||
qqq=options_.initial_date+options_.shock_decomp.save_realtime(:)-1;
|
qqq=options_.initial_date+options_.shock_decomp.save_realtime(:)-1;
|
||||||
% take the first Q4 of saved realtime
|
% take the first Q4 of saved realtime
|
||||||
|
@ -151,43 +177,44 @@ if isequal(type,'aoa') && isstruct(q2a) && realtime_
|
||||||
if ~isfield(q2a,'plot') % private trap for aoa calls
|
if ~isfield(q2a,'plot') % private trap for aoa calls
|
||||||
q2a.plot=1; % growth rate
|
q2a.plot=1; % growth rate
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if ~expand
|
||||||
|
if options_.plot_shock_decomp.interactive && ~isempty(options_.plot_shock_decomp.use_shock_groups)
|
||||||
|
mygroup = options_.plot_shock_decomp.use_shock_groups;
|
||||||
|
options_.plot_shock_decomp.use_shock_groups='';
|
||||||
|
zafull = ...
|
||||||
|
annualized_shock_decomposition(oo_,M_, options_, i_var, t0, options_.nobs, realtime_, vintage_, steady_state,q2a);
|
||||||
|
options_.plot_shock_decomp.use_shock_groups = mygroup;
|
||||||
|
end
|
||||||
[za, endo_names, endo_names_tex, steady_state, i_var, oo_] = ...
|
[za, endo_names, endo_names_tex, steady_state, i_var, oo_] = ...
|
||||||
annualized_shock_decomposition(oo_,M_, options_, i_var, t0, options_.nobs, realtime_, vintage_, steady_state,q2a);
|
annualized_shock_decomposition(oo_,M_, options_, i_var, t0, options_.nobs, realtime_, vintage_, steady_state,q2a);
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if ~expand
|
if ~expand
|
||||||
fig_name = fig_name1;
|
fig_name = fig_name1;
|
||||||
end
|
end
|
||||||
gend = size(z,3);
|
|
||||||
if options_.plot_shock_decomp.use_shock_groups
|
if options_.plot_shock_decomp.use_shock_groups
|
||||||
shock_groups = M_.shock_groups.(options_.plot_shock_decomp.use_shock_groups);
|
|
||||||
shock_ind = fieldnames(shock_groups);
|
|
||||||
ngroups = length(shock_ind);
|
|
||||||
fig_name=[fig_name ' group ' options_.plot_shock_decomp.use_shock_groups];
|
fig_name=[fig_name ' group ' options_.plot_shock_decomp.use_shock_groups];
|
||||||
shock_names = shock_ind;
|
if expand
|
||||||
for i=1:ngroups
|
z = options_.plot_shock_decomp.zfull;
|
||||||
shock_names{i} = (shock_groups.(shock_ind{i}).label);
|
endo_names = options_.plot_shock_decomp.endo_names;
|
||||||
|
endo_names_tex = options_.plot_shock_decomp.endo_names_tex;
|
||||||
|
steady_state=steady_state(i_var);
|
||||||
|
i_var = 1;
|
||||||
|
if ~(isequal(type,'aoa') && isstruct(q2a))
|
||||||
|
gend = size(z,3);
|
||||||
|
endo_nbr = size(z,1);
|
||||||
|
[z, shock_names, M_] = make_the_groups(z,gend,endo_nbr,nshocks,M_,options_);
|
||||||
|
M_.endo_names = endo_names;
|
||||||
|
M_.endo_names_tex = endo_names_tex;
|
||||||
end
|
end
|
||||||
zz = zeros(endo_nbr,ngroups+2,gend);
|
else
|
||||||
kcum=[];
|
gend = size(z,3);
|
||||||
for i=1:ngroups
|
zfull = z;
|
||||||
for j = shock_groups.(shock_ind{i}).shocks
|
[z, shock_names, M_] = make_the_groups(z,gend,endo_nbr,nshocks,M_,options_);
|
||||||
k = find(strcmp(j, M_.exo_names));
|
|
||||||
zz(:,i,:) = zz(:,i,:) + z(:,k,:);
|
|
||||||
z(:,k,:) = 0;
|
|
||||||
kcum = [kcum k];
|
|
||||||
end
|
end
|
||||||
end
|
|
||||||
zothers = sum(z(:,1:nshocks,:),2);
|
|
||||||
shock_groups.(['group' int2str(ngroups+1)]).label = 'Others';
|
|
||||||
shock_groups.(['group' int2str(ngroups+1)]).shocks = M_.exo_names(find(~ismember([1:M_.exo_nbr],kcum)));
|
|
||||||
M_.shock_groups.(options_.plot_shock_decomp.use_shock_groups)=shock_groups;
|
|
||||||
if any(any(zothers))
|
|
||||||
shock_names = [shock_names; {'Others + Initial Values'}];
|
|
||||||
end
|
|
||||||
zz(:,ngroups+1,:) = sum(z(:,1:nshocks+1,:),2);
|
|
||||||
zz(:,ngroups+2,:) = z(:,nshocks+2,:);
|
|
||||||
z = zz;
|
|
||||||
else
|
else
|
||||||
shock_names = M_.exo_names;
|
shock_names = M_.exo_names;
|
||||||
end
|
end
|
||||||
|
@ -259,6 +286,7 @@ switch type
|
||||||
q2a.plot=1; % growth rate
|
q2a.plot=1; % growth rate
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if ~expand
|
||||||
if isstruct(q2a.aux) && ischar(q2a.aux.y)
|
if isstruct(q2a.aux) && ischar(q2a.aux.y)
|
||||||
opts=options_;
|
opts=options_;
|
||||||
opts.plot_shock_decomp.type='qoq';
|
opts.plot_shock_decomp.type='qoq';
|
||||||
|
@ -268,8 +296,19 @@ switch type
|
||||||
end
|
end
|
||||||
[za, endo_names, endo_names_tex, steady_state, i_var, oo_] = ...
|
[za, endo_names, endo_names_tex, steady_state, i_var, oo_] = ...
|
||||||
annualized_shock_decomposition(z,M_, options_, i_var, t0, options_.nobs, realtime_, vintage_, steady_state,q2a);
|
annualized_shock_decomposition(z,M_, options_, i_var, t0, options_.nobs, realtime_, vintage_, steady_state,q2a);
|
||||||
|
if options_.plot_shock_decomp.interactive && ~isempty(options_.plot_shock_decomp.use_shock_groups)
|
||||||
|
mygroup = options_.plot_shock_decomp.use_shock_groups;
|
||||||
|
options_.plot_shock_decomp.use_shock_groups='';
|
||||||
|
zafull = ...
|
||||||
|
annualized_shock_decomposition(z,M_, options_, i_var, t0, options_.nobs, realtime_, vintage_, steady_state,q2a);
|
||||||
|
options_.plot_shock_decomp.use_shock_groups = mygroup;
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
z = za;
|
z = za;
|
||||||
|
if options_.plot_shock_decomp.interactive && ~isempty(options_.plot_shock_decomp.use_shock_groups)
|
||||||
|
zfull = zafull;
|
||||||
|
end
|
||||||
M_.endo_names = endo_names;
|
M_.endo_names = endo_names;
|
||||||
M_.endo_names_tex = endo_names_tex;
|
M_.endo_names_tex = endo_names_tex;
|
||||||
% endo_nbr = size(z,1);
|
% endo_nbr = size(z,1);
|
||||||
|
@ -324,6 +363,9 @@ z = z(:,:,a:b);
|
||||||
|
|
||||||
options_.plot_shock_decomp.fig_name=fig_name;
|
options_.plot_shock_decomp.fig_name=fig_name;
|
||||||
options_.plot_shock_decomp.orig_varlist = varlist;
|
options_.plot_shock_decomp.orig_varlist = varlist;
|
||||||
|
if options_.plot_shock_decomp.interactive && ~isempty(options_.plot_shock_decomp.use_shock_groups)
|
||||||
|
options_.plot_shock_decomp.zfull = zfull;
|
||||||
|
end
|
||||||
if detail_plot
|
if detail_plot
|
||||||
graph_decomp_detail(z, shock_names, M_.endo_names, i_var, my_initial_date, M_, options_)
|
graph_decomp_detail(z, shock_names, M_.endo_names, i_var, my_initial_date, M_, options_)
|
||||||
else
|
else
|
||||||
|
@ -331,5 +373,39 @@ else
|
||||||
end
|
end
|
||||||
|
|
||||||
if write_xls
|
if write_xls
|
||||||
WriteShockDecomp2Excel(z,shock_names,M_.endo_names,i_var,initial_date,M_,options_,options_.plot_shock_decomp);
|
WriteShockDecomp2Excel(z,shock_names,M_.endo_names,i_var,my_initial_date,M_,options_,options_.plot_shock_decomp);
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
function [z, shock_names, M_] = make_the_groups(z,gend,endo_nbr,nshocks,M_,options_)
|
||||||
|
|
||||||
|
shock_groups = M_.shock_groups.(options_.plot_shock_decomp.use_shock_groups);
|
||||||
|
shock_ind = fieldnames(shock_groups);
|
||||||
|
ngroups = length(shock_ind);
|
||||||
|
shock_names = shock_ind;
|
||||||
|
for i=1:ngroups
|
||||||
|
shock_names{i} = (shock_groups.(shock_ind{i}).label);
|
||||||
|
end
|
||||||
|
zz = zeros(endo_nbr,ngroups+2,gend);
|
||||||
|
kcum=[];
|
||||||
|
for i=1:ngroups
|
||||||
|
for j = shock_groups.(shock_ind{i}).shocks
|
||||||
|
k = find(strcmp(j,cellstr(M_.exo_names)));
|
||||||
|
zz(:,i,:) = zz(:,i,:) + z(:,k,:);
|
||||||
|
z(:,k,:) = 0;
|
||||||
|
kcum = [kcum k];
|
||||||
|
end
|
||||||
|
end
|
||||||
|
zothers = sum(z(:,1:nshocks,:),2);
|
||||||
|
shock_groups.(['group' int2str(ngroups+1)]).label = 'Others';
|
||||||
|
shock_groups.(['group' int2str(ngroups+1)]).shocks = cellstr(M_.exo_names(find(~ismember([1:M_.exo_nbr],kcum)),:))';
|
||||||
|
M_.shock_groups.(options_.plot_shock_decomp.use_shock_groups)=shock_groups;
|
||||||
|
if any(any(zothers))
|
||||||
|
shock_names = [shock_names; {'Others + Initial Values'}];
|
||||||
|
end
|
||||||
|
zz(:,ngroups+1,:) = sum(z(:,1:nshocks+1,:),2);
|
||||||
|
zz(:,ngroups+2,:) = z(:,nshocks+2,:);
|
||||||
|
z = zz;
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -366,7 +366,9 @@ elseif options_.mh_recover
|
||||||
FirstLine = ones(NumberOfBlocks,1);
|
FirstLine = ones(NumberOfBlocks,1);
|
||||||
LastFileFullIndicator=1;
|
LastFileFullIndicator=1;
|
||||||
end
|
end
|
||||||
|
if ~isequal(options_.posterior_sampler_options.posterior_sampling_method,'slice'),
|
||||||
[d,bayestopt_]=set_proposal_density_to_previous_value(record,options_,bayestopt_);
|
[d,bayestopt_]=set_proposal_density_to_previous_value(record,options_,bayestopt_);
|
||||||
|
end
|
||||||
%% Now find out what exactly needs to be redone
|
%% Now find out what exactly needs to be redone
|
||||||
% 1. Check if really something needs to be done
|
% 1. Check if really something needs to be done
|
||||||
% How many mh files should we have ?
|
% How many mh files should we have ?
|
||||||
|
|
|
@ -41,7 +41,7 @@ if isempty(options.(field))
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if ~iscell(options.(field))
|
if ~iscell(options.(field)) && ~isdates(options.(field))
|
||||||
if isnan(options.(field))
|
if isnan(options.(field))
|
||||||
options.(field) = default;
|
options.(field) = default;
|
||||||
return
|
return
|
||||||
|
|
|
@ -139,7 +139,8 @@ switch type
|
||||||
end
|
end
|
||||||
|
|
||||||
% annual growth rate
|
% annual growth rate
|
||||||
gyass = GYTREND0*4;
|
% gyass = GYTREND0*4; % this is for log diff
|
||||||
|
gyass = exp(4*GYTREND0)-1; % this is for exact growth rate definition
|
||||||
gya = (ya+yass)./(lagged(ya,1)+yass).*exp(4*GYTREND0)-1-gyass;
|
gya = (ya+yass)./(lagged(ya,1)+yass).*exp(4*GYTREND0)-1-gyass;
|
||||||
|
|
||||||
if islog
|
if islog
|
||||||
|
|
|
@ -88,7 +88,7 @@ end;
|
||||||
|
|
||||||
moment_calibration;
|
moment_calibration;
|
||||||
//y_obs,y_obs, [0.8 1.1]; //[unconditional variance]
|
//y_obs,y_obs, [0.8 1.1]; //[unconditional variance]
|
||||||
y_obs,y_obs(-(1:4)), +; //[first year acf]
|
y_obs,y_obs(1:4), +; //[first year acf]
|
||||||
//y_obs,pie_obs(-4:4), -; //[ccf]
|
//y_obs,pie_obs(-4:4), -; //[ccf]
|
||||||
@#for ilag in -2:2
|
@#for ilag in -2:2
|
||||||
y_obs,R_obs(@{ilag}), -; //[ccf]
|
y_obs,R_obs(@{ilag}), -; //[ccf]
|
||||||
|
|
Loading…
Reference in New Issue