Merge branch 'fixes_4.6' into 'master'

Fixes 4.6

See merge request Dynare/dynare!1641
time-shift
Stéphane Adjemian 2019-02-04 10:19:05 +00:00
commit 768555b523
10 changed files with 240 additions and 121 deletions

View File

@ -120,6 +120,7 @@ elseif q2a.plot ~= 2
end
% end initialize names
steady_state=steady_state(i_var);
if realtime_==0
% usual shock decomp
@ -143,7 +144,6 @@ if realtime_==0
aux.yss=steady_state_aux;
end
end
steady_state=steady_state(i_var);
% make annualized shock decomp
[z, steady_state_a, steady_state_ga] = annualiz(z,t0,q2a,aux,steady_state);
end
@ -323,4 +323,4 @@ elseif q2a.plot == 2
z=za;
else
z=cat(1,za,gza);
end
end

View File

@ -10,7 +10,7 @@ function expand_group(use_shock_groups,var_list_, ic)
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2016-2017 Dynare Team
% Copyright (C) 2016-2018 Dynare Team
%
% 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
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
filename = get(gcf,'filename');
[filepath, name, ext]=fileparts(filename);
M = evalin('base','M_');
oo = evalin('base','oo_');
options = evalin('base','options_');
@ -39,9 +41,12 @@ options.first_obs=mydata.first_obs;
options.nobs=mydata.nobs;
% define expanded group
label = mydata.shock_group.label;
label = strrep(label,' ','_');
label = strrep(label,'-','_');
shocks = mydata.shock_group.shocks;
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)
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);
@ -49,4 +54,16 @@ end
options.plot_shock_decomp.interactive=0;
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_);

View File

@ -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
% 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;
% number of components equals number of shocks + 1 (initial conditions)
@ -87,7 +89,7 @@ end
nvar = length(i_var);
%% 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');
fprintf(fidTeX,'%% TeX eps-loader file generated by Dynare''s graph_decomp.m.\n');
fprintf(fidTeX,['%% ' datestr(now,0) '\n']);
@ -197,6 +199,9 @@ for j=1:nvar
mydata.plot_shock_decomp = DynareOptions.plot_shock_decomp;
mydata.first_obs = DynareOptions.first_obs;
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)
c = uicontextmenu;
hl.UIContextMenu=c;
@ -216,20 +221,26 @@ for j=1:nvar
colormap(new_colormap)
end
hold off
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)))
fprintf(fidTeX,'\\begin{figure}[H]\n');
fprintf(fidTeX,'\\centering \n');
fprintf(fidTeX,'\\includegraphics[width=0.8\\textwidth]{%s/graphs/%s_shock_decomposition_%s}\n',DynareModel.fname,DynareModel.fname,[endo_names{i_var(j)} fig_mode1 fig_name]);
fprintf(fidTeX,'\\label{Fig:shock_decomp:%s}\n',[fig_mode endo_names{i_var(j)} fig_name]);
fprintf(fidTeX,['\\caption{' preamble_txt fig_name_long strrep(fig_mode1, '_', ' ') ': $ %s $.}\n'],DynareModel.endo_names_tex{i_var(j)});
fprintf(fidTeX,'\\end{figure}\n');
fprintf(fidTeX,' \n');
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);
if DynareOptions.TeX && any(strcmp('eps',cellstr(DynareOptions.plot_shock_decomp.graph_format)))
fprintf(fidTeX,'\\begin{figure}[H]\n');
fprintf(fidTeX,'\\centering \n');
fprintf(fidTeX,'\\includegraphics[width=0.8\\textwidth]{%s/graphs/%s_shock_decomposition_%s}\n',DynareModel.fname,DynareModel.fname,[endo_names{i_var(j)} fig_mode1 fig_name]);
fprintf(fidTeX,'\\label{Fig:shock_decomp:%s}\n',[fig_mode endo_names{i_var(j)} fig_name]);
fprintf(fidTeX,['\\caption{' preamble_txt fig_name_long strrep(fig_mode1, '_', ' ') ': $ %s $.}\n'],DynareModel.endo_names_tex{i_var(j)});
fprintf(fidTeX,'\\end{figure}\n');
fprintf(fidTeX,' \n');
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
%% 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,'%% End of TeX file.\n');
fclose(fidTeX);

View File

@ -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
% 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;
fig_mode='';
fig_mode1='';
@ -108,7 +110,7 @@ end
nvar = length(i_var);
%% 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');
fprintf(fidTeX,'%% TeX eps-loader file generated by Dynare''s graph_decomp_detail.m.\n');
fprintf(fidTeX,['%% ' datestr(now,0) '\n']);
@ -199,6 +201,9 @@ for j=1:nvar
mydata.plot_shock_decomp = DynareOptions.plot_shock_decomp;
mydata.first_obs = DynareOptions.first_obs;
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)
c = uicontextmenu;
hax.UIContextMenu=c;
@ -241,22 +246,27 @@ for j=1:nvar
else
suffix = ['_detail'];
end
dyn_saveas(fhandle,[GraphDirectoryName, filesep, DynareModel.fname, ...
if ~DynareOptions.plot_shock_decomp.expand
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);
if DynareOptions.TeX && any(strcmp('eps',cellstr(DynareOptions.plot_shock_decomp.graph_format)))
fprintf(fidTeX,'\\begin{figure}[H]\n');
fprintf(fidTeX,'\\centering \n');
fprintf(fidTeX,'\\includegraphics[width=0.8\\textwidth]{%s/graphs/%s_shock_decomposition_%s}\n',DynareModel.fname,DynareModel.fname,[endo_names{i_var(j)} fig_mode1 fig_name suffix]);
fprintf(fidTeX,'\\label{Fig:shock_decomp_detail:%s}\n',[fig_mode endo_names{i_var(j)} fig_name suffix]);
fprintf(fidTeX,['\\caption{' preamble_txt fig_name_long strrep(fig_mode1, '_', ' ') ': $ %s $ (detail).}\n'], DynareModel.endo_names_tex{i_var(j)});
fprintf(fidTeX,'\\end{figure}\n');
fprintf(fidTeX,' \n');
if DynareOptions.TeX && any(strcmp('eps',cellstr(DynareOptions.plot_shock_decomp.graph_format)))
fprintf(fidTeX,'\\begin{figure}[H]\n');
fprintf(fidTeX,'\\centering \n');
fprintf(fidTeX,'\\includegraphics[width=0.8\\textwidth]{%s/graphs/%s_shock_decomposition_%s}\n',DynareModel.fname,DynareModel.fname,[endo_names{i_var(j)} fig_mode1 fig_name suffix]);
fprintf(fidTeX,'\\label{Fig:shock_decomp_detail:%s}\n',[fig_mode endo_names{i_var(j)} fig_name suffix]);
fprintf(fidTeX,['\\caption{' preamble_txt fig_name_long strrep(fig_mode1, '_', ' ') ': $ %s $ (detail).}\n'], DynareModel.endo_names_tex{i_var(j)});
fprintf(fidTeX,'\\end{figure}\n');
fprintf(fidTeX,' \n');
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
%% 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,'%% End of TeX file.\n');
fclose(fidTeX);

View File

@ -394,6 +394,7 @@ if ~isempty(indx_moment)
% For single legend search which has maximum nbr of restrictions
maxijv=0;
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
maxij=ij;maxijv=length(endo_prior_restrictions.moment{ij,3});
end
@ -477,6 +478,7 @@ if ~isempty(indx_moment)
% end
end
for ij=1:nbr_moment_couples
time_matrix{ij} = sort(time_matrix{ij});
if length(time_matrix{ij})>1
if ~DynareOptions.nograph
itmp = (find(plot_indx==ij));
@ -505,7 +507,7 @@ if ~isempty(indx_moment)
hold off
axis(a)
box on
set(gca,'xtick',sort(time_matrix{ij}))
% set(gca,'xtick',sort(time_matrix{ij}))
itmp = min(itmp);
title([endo_prior_restrictions.moment{itmp,1},' vs ',endo_prior_restrictions.moment{itmp,2}],'interpreter','none'),
end

View File

@ -50,6 +50,7 @@ if isfield(options_.plot_shock_decomp,'expand') % private trap for uimenu calls
expand=options_.plot_shock_decomp.expand;
else
expand=0;
options_.plot_shock_decomp.expand=0;
end
if ~isempty(options_.plot_shock_decomp.fig_name)
@ -88,106 +89,132 @@ else
end
switch realtime_
case 0
z = oo_.shock_decomposition;
fig_name1=fig_name;
case 1 % realtime
if vintage_
z = oo_.realtime_shock_decomposition.(['time_' int2str(vintage_)]);
fig_name1=[fig_name ' realtime (vintage ' char(initial_date+vintage_-1) ')'];
else
z = oo_.realtime_shock_decomposition.pool;
fig_name1=[fig_name ' realtime (rolling)'];
end
case 2 % conditional
if vintage_
z = oo_.realtime_conditional_shock_decomposition.(['time_' int2str(vintage_)]);
initial_date = initial_date+vintage_-1;
fig_name1=[fig_name ' ' int2str(forecast_) '-step ahead conditional forecast (given ' char(initial_date) ')'];
else
z = oo_.conditional_shock_decomposition.pool;
fig_name1=[fig_name ' 1-step ahead conditional forecast (rolling)'];
end
case 3 % forecast
if vintage_
z = oo_.realtime_forecast_shock_decomposition.(['time_' int2str(vintage_)]);
initial_date = initial_date+vintage_-1;
fig_name1=[fig_name ' ' int2str(forecast_) '-step ahead forecast (given ' char(initial_date) ')'];
else
z = oo_.realtime_forecast_shock_decomposition.pool;
fig_name1=[fig_name ' 1-step ahead forecast (rolling)'];
end
case 0
if ~expand
z = oo_.shock_decomposition;
end
fig_name1=fig_name;
case 1 % realtime
if vintage_
if ~expand
z = oo_.realtime_shock_decomposition.(['time_' int2str(vintage_)]);
end
fig_name1=[fig_name ' realtime (vintage ' char(initial_date+vintage_-1) ')'];
else
if ~expand
z = oo_.realtime_shock_decomposition.pool;
end
fig_name1=[fig_name ' realtime (rolling)'];
end
case 2 % conditional
if vintage_
if ~expand
z = oo_.realtime_conditional_shock_decomposition.(['time_' int2str(vintage_)]);
end
initial_date = initial_date+vintage_-1;
fig_name1=[fig_name ' ' int2str(forecast_) '-step ahead conditional forecast (given ' char(initial_date) ')'];
else
if ~expand
z = oo_.conditional_shock_decomposition.pool;
end
fig_name1=[fig_name ' 1-step ahead conditional forecast (rolling)'];
end
case 3 % forecast
if vintage_
if ~expand
z = oo_.realtime_forecast_shock_decomposition.(['time_' int2str(vintage_)]);
end
initial_date = initial_date+vintage_-1;
fig_name1=[fig_name ' ' int2str(forecast_) '-step ahead forecast (given ' char(initial_date) ')'];
else
if ~expand
z = oo_.realtime_forecast_shock_decomposition.pool;
end
fig_name1=[fig_name ' 1-step ahead forecast (rolling)'];
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_
% take all dates where realtime is saved
qqq=options_.initial_date+options_.shock_decomp.save_realtime(:)-1;
% take the first Q4 of saved realtime
t0=min(options_.shock_decomp.save_realtime(qqq.time(:,2)==4));
if isempty(t0)
error('the realtime decompositions are not stored in Q4! Please check your dates and settings.')
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 ~isfield(q2a,'var_type') % private trap for aoa calls
q2a.var_type=1;
if realtime_
% take all dates where realtime is saved
qqq=options_.initial_date+options_.shock_decomp.save_realtime(:)-1;
% take the first Q4 of saved realtime
t0=min(options_.shock_decomp.save_realtime(qqq.time(:,2)==4));
if isempty(t0)
error('the realtime decompositions are not stored in Q4! Please check your dates and settings.')
end
if ~isfield(q2a,'var_type') % private trap for aoa calls
q2a.var_type=1;
end
if ~isfield(q2a,'islog') % private trap for aoa calls
q2a.islog=0;
end
if ~isfield(q2a,'GYTREND0') % private trap for aoa calls
q2a.GYTREND0=0;
end
if ~isfield(q2a,'aux') % private trap for aoa calls
q2a.aux=0;
end
if ~isfield(q2a,'cumfix') % private trap for aoa calls
q2a.cumfix=1;
end
if ~isfield(q2a,'plot') % private trap for aoa calls
q2a.plot=1; % growth rate
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_] = ...
annualized_shock_decomposition(oo_,M_, options_, i_var, t0, options_.nobs, realtime_, vintage_, steady_state,q2a);
end
end
if ~isfield(q2a,'islog') % private trap for aoa calls
q2a.islog=0;
end
if ~isfield(q2a,'GYTREND0') % private trap for aoa calls
q2a.GYTREND0=0;
end
if ~isfield(q2a,'aux') % private trap for aoa calls
q2a.aux=0;
end
if ~isfield(q2a,'cumfix') % private trap for aoa calls
q2a.cumfix=1;
end
if ~isfield(q2a,'plot') % private trap for aoa calls
q2a.plot=1; % growth rate
end
[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);
end
if ~expand
fig_name = fig_name1;
end
gend = size(z,3);
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];
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, M_.exo_names));
zz(:,i,:) = zz(:,i,:) + z(:,k,:);
z(:,k,:) = 0;
kcum = [kcum k];
if expand
z = options_.plot_shock_decomp.zfull;
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
else
gend = size(z,3);
zfull = z;
[z, shock_names, M_] = make_the_groups(z,gend,endo_nbr,nshocks,M_,options_);
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
shock_names = M_.exo_names;
end
@ -259,6 +286,7 @@ switch type
q2a.plot=1; % growth rate
end
if ~expand
if isstruct(q2a.aux) && ischar(q2a.aux.y)
opts=options_;
opts.plot_shock_decomp.type='qoq';
@ -268,8 +296,19 @@ switch type
end
[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);
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
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_tex = endo_names_tex;
% 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.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
graph_decomp_detail(z, shock_names, M_.endo_names, i_var, my_initial_date, M_, options_)
else
@ -331,5 +373,39 @@ else
end
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

View File

@ -366,7 +366,9 @@ elseif options_.mh_recover
FirstLine = ones(NumberOfBlocks,1);
LastFileFullIndicator=1;
end
[d,bayestopt_]=set_proposal_density_to_previous_value(record,options_,bayestopt_);
if ~isequal(options_.posterior_sampler_options.posterior_sampling_method,'slice'),
[d,bayestopt_]=set_proposal_density_to_previous_value(record,options_,bayestopt_);
end
%% Now find out what exactly needs to be redone
% 1. Check if really something needs to be done
% How many mh files should we have ?

View File

@ -41,11 +41,11 @@ if isempty(options.(field))
return
end
if ~iscell(options.(field))
if ~iscell(options.(field)) && ~isdates(options.(field))
if isnan(options.(field))
options.(field) = default;
return
end
end
% 06/07/03 MJ added ; to eval expression
% 06/07/03 MJ added ; to eval expression

View File

@ -139,7 +139,8 @@ switch type
end
% 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;
if islog

View File

@ -88,7 +88,7 @@ end;
moment_calibration;
//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]
@#for ilag in -2:2
y_obs,R_obs(@{ilag}), -; //[ccf]