commit
9ddad32e4e
|
@ -28,7 +28,9 @@ function WriteShockDecomp2Excel(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/>.
|
||||||
|
|
||||||
SteadyState=[];
|
OutputDirectoryName = CheckPath('Output',DynareModel.dname);
|
||||||
|
|
||||||
|
SteadyState=zeros(DynareModel.endo_nbr,1);
|
||||||
fig_mode='';
|
fig_mode='';
|
||||||
fig_mode1='';
|
fig_mode1='';
|
||||||
fig_name='';
|
fig_name='';
|
||||||
|
@ -114,15 +116,13 @@ for j=1:nvar
|
||||||
end
|
end
|
||||||
|
|
||||||
warning off
|
warning off
|
||||||
try
|
fig_name1 = strrep(fig_name1,' ','_');
|
||||||
[STATUS,MESSAGE] = xlswrite([DynareModel.fname,'_shock_decomposition',fig_mode,fig_name1],d0,endo_names{i_var(j)});
|
fig_name1 = strrep(fig_name1,'.','');
|
||||||
catch
|
|
||||||
if exist('xlwrite.m','file')
|
if ~ismac
|
||||||
[STATUS] = xlwrite([DynareModel.fname,'_shock_decomposition',fig_mode,fig_name1],d0,endo_names{i_var(j)});
|
[STATUS,MESSAGE] = xlswrite([OutputDirectoryName,filesep,DynareModel.fname,'_shock_decomposition',fig_mode,fig_name1],d0,endo_names{i_var(j)});
|
||||||
else
|
else
|
||||||
fprintf('\nWriteShockDecomp2Excel: could not write Excel file. It seems Excel is not installed on your machine.\n')
|
writetable(cell2table(d0), [OutputDirectoryName,filesep,DynareModel.fname,'_shock_decomposition',fig_mode,fig_name1 '.xls'], 'Sheet', endo_names{i_var(j)},'WriteVariableNames',false);
|
||||||
fprintf('Please install the free xlwrite.m from https://mathworks.com/matlabcentral/fileexchange/38591-xlwrite-generate-xls-x-files-without-excel-on-mac-linux-win\n')
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
warning on
|
warning on
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
function expand_group(use_shock_groups,var_list_, ic)
|
function expand_group(use_shock_groups,var_list_, ic, no_graph)
|
||||||
% function expand_group(use_shock_groups,var_list_, ic)
|
% function expand_group(use_shock_groups,var_list_, ic)
|
||||||
% Expands shocks contributions out of a group of shocks
|
% Expands shocks contributions out of a group of shocks
|
||||||
%
|
%
|
||||||
|
@ -27,6 +27,9 @@ 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/>.
|
||||||
|
|
||||||
|
if nargin<4
|
||||||
|
no_graph=0;
|
||||||
|
end
|
||||||
filename = get(gcf,'filename');
|
filename = get(gcf,'filename');
|
||||||
[filepath, name, ext]=fileparts(filename);
|
[filepath, name, ext]=fileparts(filename);
|
||||||
M = evalin('base','M_');
|
M = evalin('base','M_');
|
||||||
|
@ -56,7 +59,12 @@ M.exo_names = mydata.exo_names;
|
||||||
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.nodisplay=0;
|
||||||
options.plot_shock_decomp.write_xls=0;
|
if no_graph
|
||||||
|
options.no_graph.plot_shock_decomposition=1;
|
||||||
|
options.plot_shock_decomp.write_xls=1;
|
||||||
|
else
|
||||||
|
options.plot_shock_decomp.write_xls=0;
|
||||||
|
end
|
||||||
%% set optimal colormap
|
%% set optimal colormap
|
||||||
func = @(x) colorspace('RGB->Lab',x);
|
func = @(x) colorspace('RGB->Lab',x);
|
||||||
MAP = distinguishable_colors(length(shocks)+1,'w',func);
|
MAP = distinguishable_colors(length(shocks)+1,'w',func);
|
||||||
|
|
|
@ -227,6 +227,8 @@ for j=1:nvar
|
||||||
browse_menu = uimenu(c,'Label','Browse group');
|
browse_menu = uimenu(c,'Label','Browse group');
|
||||||
expand_menu = uimenu(c,'Label','Expand group','Callback',['expand_group(''' mydata.plot_shock_decomp.use_shock_groups ''',''' mydata.plot_shock_decomp.orig_varlist{j} ''',' int2str(i) ')']);
|
expand_menu = uimenu(c,'Label','Expand group','Callback',['expand_group(''' mydata.plot_shock_decomp.use_shock_groups ''',''' mydata.plot_shock_decomp.orig_varlist{j} ''',' int2str(i) ')']);
|
||||||
set(expand_menu,'UserData',mydata,'Tag',['group' int2str(i)]);
|
set(expand_menu,'UserData',mydata,'Tag',['group' int2str(i)]);
|
||||||
|
save_expand2xls_menu = uimenu(c,'Label','Export group to xls','Callback',['expand_group(''' mydata.plot_shock_decomp.use_shock_groups ''',''' mydata.plot_shock_decomp.orig_varlist{j} ''',' int2str(i) ', 1)']);
|
||||||
|
set(save_expand2xls_menu,'Tag',['xls_group' int2str(i)]);
|
||||||
for jmember = mydata.shock_group.shocks
|
for jmember = mydata.shock_group.shocks
|
||||||
uimenu('parent',browse_menu,'Label',char(jmember))
|
uimenu('parent',browse_menu,'Label',char(jmember))
|
||||||
end
|
end
|
||||||
|
|
|
@ -24,7 +24,7 @@ function []=graph_decomp_detail(z,shock_names,endo_names,i_var,initial_date,Dyna
|
||||||
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
% GNU General Public License for more details.
|
% GNU General Public License for more details.
|
||||||
%xf
|
%
|
||||||
% 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/>.
|
||||||
|
|
||||||
|
@ -233,6 +233,8 @@ for j=1:nvar
|
||||||
browse_menu = uimenu(c,'Label','Browse group');
|
browse_menu = uimenu(c,'Label','Browse group');
|
||||||
expand_menu = uimenu(c,'Label','Expand group','Callback',['expand_group(''' mydata.plot_shock_decomp.use_shock_groups ''',''' mydata.plot_shock_decomp.orig_varlist{j} ''',' int2str(ic) ')']);
|
expand_menu = uimenu(c,'Label','Expand group','Callback',['expand_group(''' mydata.plot_shock_decomp.use_shock_groups ''',''' mydata.plot_shock_decomp.orig_varlist{j} ''',' int2str(ic) ')']);
|
||||||
set(expand_menu,'UserData',mydata,'Tag',['group' int2str(ic)]);
|
set(expand_menu,'UserData',mydata,'Tag',['group' int2str(ic)]);
|
||||||
|
save_expand2xls_menu = uimenu(c,'Label','Export group to xls','Callback',['expand_group(''' mydata.plot_shock_decomp.use_shock_groups ''',''' mydata.plot_shock_decomp.orig_varlist{j} ''',' int2str(ic) ', 1)']);
|
||||||
|
set(save_expand2xls_menu,'Tag',['xls_group' int2str(ic)]);
|
||||||
for jmember = mydata.shock_group.shocks
|
for jmember = mydata.shock_group.shocks
|
||||||
uimenu('parent',browse_menu,'Label',char(jmember))
|
uimenu('parent',browse_menu,'Label',char(jmember))
|
||||||
end
|
end
|
||||||
|
|
|
@ -50,7 +50,7 @@ if size(varlist,1) == 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if isfield(options_.plot_shock_decomp,'init2shocks') % private trap for uimenu calls
|
if isfield(options_.plot_shock_decomp,'init2shocks') && options_.plot_shock_decomp.realtime==0 % private trap for uimenu calls
|
||||||
init2shocks=options_.plot_shock_decomp.init2shocks;
|
init2shocks=options_.plot_shock_decomp.init2shocks;
|
||||||
else
|
else
|
||||||
init2shocks=[];
|
init2shocks=[];
|
||||||
|
@ -59,7 +59,7 @@ if ~isempty(init2shocks)
|
||||||
init2shocks=M_.init2shocks.(init2shocks);
|
init2shocks=M_.init2shocks.(init2shocks);
|
||||||
end
|
end
|
||||||
|
|
||||||
|
orig_endo_names = M_.endo_names;
|
||||||
epilogue_decomp=false;
|
epilogue_decomp=false;
|
||||||
if exist_varlist && any(ismember(varlist,M_.epilogue_names))
|
if exist_varlist && any(ismember(varlist,M_.epilogue_names))
|
||||||
epilogue_decomp=true;
|
epilogue_decomp=true;
|
||||||
|
@ -252,15 +252,15 @@ if ~isempty(init2shocks) && ~expand
|
||||||
n=size(init2shocks,1);
|
n=size(init2shocks,1);
|
||||||
M_.exo_names_init=M_.exo_names;
|
M_.exo_names_init=M_.exo_names;
|
||||||
for i=1:n
|
for i=1:n
|
||||||
j=strmatch(init2shocks{i}{1},M_.endo_names,'exact');
|
j=strmatch(init2shocks{i}{1},orig_endo_names,'exact');
|
||||||
if ~isempty(init2shocks{i}{2})
|
if ~isempty(init2shocks{i}{2})
|
||||||
jj=strmatch(init2shocks{i}{2},M_.exo_names,'exact');
|
jj=strmatch(init2shocks{i}{2},M_.exo_names,'exact');
|
||||||
M_.exo_names_init{jj}=[M_.exo_names_init{jj} ' + ' M_.endo_names{j}];
|
M_.exo_names_init{jj}=[M_.exo_names_init{jj} ' + ' orig_endo_names{j}];
|
||||||
z(:,jj,:)= z(:,jj,:) + oo_.initval_decomposition (:,j,:);
|
z(:,jj,:)= z(:,jj,:) + oo_.initval_decomposition (:,j,1:size(z,3));
|
||||||
else
|
else
|
||||||
z(:,end,:)= z(:,end,:) - oo_.initval_decomposition (:,j,:);
|
z(:,end,:)= z(:,end,:) - oo_.initval_decomposition (:,j,1:size(z,3));
|
||||||
end
|
end
|
||||||
z(:,end-1,:)= z(:,end-1,:) - oo_.initval_decomposition (:,j,:);
|
z(:,end-1,:)= z(:,end-1,:) - oo_.initval_decomposition (:,j,1:size(z,3));
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -271,6 +271,9 @@ if ~epilogue_decomp
|
||||||
else
|
else
|
||||||
steady_state = oo_.steady_state;
|
steady_state = oo_.steady_state;
|
||||||
end
|
end
|
||||||
|
if isfield(oo_.shock_decomposition_info,'i_var') && (M_.endo_nbr<length(orig_endo_names))
|
||||||
|
steady_state=steady_state(oo_.shock_decomposition_info.i_var);
|
||||||
|
end
|
||||||
else
|
else
|
||||||
steady_state = oo_.shock_decomposition_info.epilogue_steady_state;
|
steady_state = oo_.shock_decomposition_info.epilogue_steady_state;
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue