v4 stoch_simul.m: added storage of IRFs in oo_.irfs

git-svn-id: https://www.dynare.org/svn/dynare/dynare_v4@1337 ac1d8469-bf42-47a9-8791-bf33cf982152
time-shift
michel 2007-07-05 04:34:24 +00:00
parent bcefdfc37c
commit d75d2a459b
1 changed files with 101 additions and 97 deletions

View File

@ -120,6 +120,8 @@ function info=stoch_simul(var_list)
for j = 1:n
assignin('base',[deblank(M_.endo_names(ivar(j),:)) '_' deblank(M_.exo_names(i,:))],...
y(ivar(j),:)');
eval(['oo_.irfs.' deblank(M_.endo_names(ivar(j),:)) '_' ...
deblank(M_.exo_names(i,:)) ' = y(ivar(j),:);']);
if max(y(ivar(j),:)) - min(y(ivar(j),:)) > 1e-10
irfs = cat(1,irfs,y(ivar(j),:));
mylist = strvcat(mylist,deblank(var_list(j,:)));
@ -128,125 +130,127 @@ function info=stoch_simul(var_list)
end
end
end
number_of_plots_to_draw = size(irfs,1);
[nbplt,nr,nc,lr,lc,nstar] = pltorg(number_of_plots_to_draw);
if nbplt == 0
elseif nbplt == 1
if options_.relative_irf
hh = figure('Name',['Relative response to' ...
' orthogonalized shock to ' tit(i,:)]);
else
hh = figure('Name',['Orthogonalized shock to' ...
' ' tit(i,:)]);
end
for j = 1:number_of_plots_to_draw
subplot(nr,nc,j);
plot(1:options_.irf,transpose(irfs(j,:)),'-k','linewidth',1);
hold on
plot([1 options_.irf],[0 0],'-r','linewidth',0.5);
hold off
xlim([1 options_.irf]);
title(deblank(mylist(j,:)),'Interpreter','none');
end
eval(['print -depsc2 ' M_.fname '_IRF_' deblank(tit(i,:))]);
eval(['print -dpdf ' M_.fname '_IRF_' deblank(tit(i,:))]);
saveas(hh,[M_.fname '_IRF_' deblank(tit(i,:)) '.fig']);
if TeX
fprintf(fidTeX,'\\begin{figure}[H]\n');
for j = 1:number_of_plots_to_draw
fprintf(fidTeX,['\\psfrag{%s}[1][][0.5][0]{$%s$}\n'],deblank(mylist(j,:)),deblank(mylistTeX(j,:)));
end
fprintf(fidTeX,'\\centering \n');
fprintf(fidTeX,'\\includegraphics[scale=0.5]{%s_IRF_%s}\n',M_.fname,deblank(tit(i,:)));
fprintf(fidTeX,'\\caption{Impulse response functions (orthogonalized shock to $%s$).}',titTeX(i,:));
fprintf(fidTeX,'\\label{Fig:IRF:%s}\n',deblank(tit(i,:)));
fprintf(fidTeX,'\\end{figure}\n');
fprintf(fidTeX,' \n');
end
% close(hh)
else
for fig = 1:nbplt-1
if options_.relative_irf == 1
hh = figure('Name',['Relative response to orthogonalized shock' ...
' to ' tit(i,:) ' figure ' int2str(fig)]);
if options_.nograph == 0
number_of_plots_to_draw = size(irfs,1);
[nbplt,nr,nc,lr,lc,nstar] = pltorg(number_of_plots_to_draw);
if nbplt == 0
elseif nbplt == 1
if options_.relative_irf
hh = figure('Name',['Relative response to' ...
' orthogonalized shock to ' tit(i,:)]);
else
hh = figure('Name',['Orthogonalized shock to ' tit(i,:) ...
' figure ' int2str(fig)]);
hh = figure('Name',['Orthogonalized shock to' ...
' ' tit(i,:)]);
end
for plt = 1:nstar
subplot(nr,nc,plt);
plot(1:options_.irf,transpose(irfs((fig-1)*nstar+plt,:)),'-k','linewidth',1);
for j = 1:number_of_plots_to_draw
subplot(nr,nc,j);
plot(1:options_.irf,transpose(irfs(j,:)),'-k','linewidth',1);
hold on
plot([1 options_.irf],[0 0],'-r','linewidth',0.5);
hold off
xlim([1 options_.irf]);
title(deblank(mylist((fig-1)*nstar+plt,:)),'Interpreter','none');
title(deblank(mylist(j,:)),'Interpreter','none');
end
eval(['print -depsc2 ' M_.fname '_IRF_' deblank(tit(i,:)) int2str(fig)]);
eval(['print -dpdf ' M_.fname '_IRF_' deblank(tit(i,:)) int2str(fig)]);
saveas(hh,[M_.fname '_IRF_' deblank(tit(i,:)) int2str(fig) '.fig']);
eval(['print -depsc2 ' M_.fname '_IRF_' deblank(tit(i,:))]);
eval(['print -dpdf ' M_.fname '_IRF_' deblank(tit(i,:))]);
saveas(hh,[M_.fname '_IRF_' deblank(tit(i,:)) '.fig']);
if TeX
fprintf(fidTeX,'\\begin{figure}[H]\n');
for j = 1:nstar
fprintf(fidTeX,['\\psfrag{%s}[1][][0.5][0]{$%s$}\n'],deblank(mylist((fig-1)*nstar+j,:)),deblank(mylistTeX((fig-1)*nstar+j,:)));
for j = 1:number_of_plots_to_draw
fprintf(fidTeX,['\\psfrag{%s}[1][][0.5][0]{$%s$}\n'],deblank(mylist(j,:)),deblank(mylistTeX(j,:)));
end
fprintf(fidTeX,'\\centering \n');
fprintf(fidTeX,'\\includegraphics[scale=0.5]{%s_IRF_%s%s}\n',M_.fname,deblank(tit(i,:)),int2str(fig));
fprintf(fidTeX,'\\includegraphics[scale=0.5]{%s_IRF_%s}\n',M_.fname,deblank(tit(i,:)));
fprintf(fidTeX,'\\caption{Impulse response functions (orthogonalized shock to $%s$).}',titTeX(i,:));
fprintf(fidTeX,'\\label{Fig:IRF:%s}\n',deblank(tit(i,:)));
fprintf(fidTeX,'\\end{figure}\n');
fprintf(fidTeX,' \n');
end
% close(hh)
else
for fig = 1:nbplt-1
if options_.relative_irf == 1
hh = figure('Name',['Relative response to orthogonalized shock' ...
' to ' tit(i,:) ' figure ' int2str(fig)]);
else
hh = figure('Name',['Orthogonalized shock to ' tit(i,:) ...
' figure ' int2str(fig)]);
end
for plt = 1:nstar
subplot(nr,nc,plt);
plot(1:options_.irf,transpose(irfs((fig-1)*nstar+plt,:)),'-k','linewidth',1);
hold on
plot([1 options_.irf],[0 0],'-r','linewidth',0.5);
hold off
xlim([1 options_.irf]);
title(deblank(mylist((fig-1)*nstar+plt,:)),'Interpreter','none');
end
eval(['print -depsc2 ' M_.fname '_IRF_' deblank(tit(i,:)) int2str(fig)]);
eval(['print -dpdf ' M_.fname '_IRF_' deblank(tit(i,:)) int2str(fig)]);
saveas(hh,[M_.fname '_IRF_' deblank(tit(i,:)) int2str(fig) '.fig']);
if TeX
fprintf(fidTeX,'\\begin{figure}[H]\n');
for j = 1:nstar
fprintf(fidTeX,['\\psfrag{%s}[1][][0.5][0]{$%s$}\n'],deblank(mylist((fig-1)*nstar+j,:)),deblank(mylistTeX((fig-1)*nstar+j,:)));
end
fprintf(fidTeX,'\\centering \n');
fprintf(fidTeX,'\\includegraphics[scale=0.5]{%s_IRF_%s%s}\n',M_.fname,deblank(tit(i,:)),int2str(fig));
if options_.relative_irf
fprintf(fidTeX,['\\caption{Relative impulse response' ...
' functions (orthogonalized shock to $%s$).}'],deblank(titTeX(i,:)));
else
fprintf(fidTeX,['\\caption{Impulse response functions' ...
' (orthogonalized shock to $%s$).}'],deblank(titTeX(i,:)));
end
fprintf(fidTeX,'\\label{Fig:BayesianIRF:%s:%s}\n',deblank(tit(i,:)),int2str(fig));
fprintf(fidTeX,'\\end{figure}\n');
fprintf(fidTeX,' \n');
end
% close(hh);
end
hh = figure('Name',['Orthogonalized shock to ' tit(i,:) ' figure ' int2str(nbplt) '.']);
m = 0;
for plt = 1:number_of_plots_to_draw-(nbplt-1)*nstar;
m = m+1;
subplot(lr,lc,m);
plot(1:options_.irf,transpose(irfs((nbplt-1)*nstar+plt,:)),'-k','linewidth',1);
hold on
plot([1 options_.irf],[0 0],'-r','linewidth',0.5);
hold off
xlim([1 options_.irf]);
title(deblank(mylist((nbplt-1)*nstar+plt,:)),'Interpreter','none');
end
eval(['print -depsc2 ' M_.fname '_IRF_' deblank(tit(i,:)) int2str(nbplt)]);
eval(['print -dpdf ' M_.fname '_IRF_' deblank(tit(i,:)) int2str(nbplt)]);
saveas(hh,[M_.fname '_IRF_' deblank(tit(i,:)) int2str(nbplt) '.fig']);
if TeX
fprintf(fidTeX,'\\begin{figure}[H]\n');
for j = 1:m
fprintf(fidTeX,['\\psfrag{%s}[1][][0.5][0]{$%s$}\n'],deblank(mylist((nbplt-1)*nstar+j,:)),deblank(mylistTeX((nbplt-1)*nstar+j,:)));
end
fprintf(fidTeX,'\\centering \n');
fprintf(fidTeX,'\\includegraphics[scale=0.5]{%s_IRF_%s%s}\n',M_.fname,deblank(tit(i,:)),int2str(nbplt));
if options_.relative_irf
fprintf(fidTeX,['\\caption{Relative impulse response' ...
' functions (orthogonalized shock to $%s$).}'],deblank(titTeX(i,:)));
fprintf(fidTeX,['\\caption{Relative impulse response functions' ...
' (orthogonalized shock to $%s$).}'],deblank(titTeX(i,:)));
else
fprintf(fidTeX,['\\caption{Impulse response functions' ...
' (orthogonalized shock to $%s$).}'],deblank(titTeX(i,:)));
end
fprintf(fidTeX,'\\label{Fig:BayesianIRF:%s:%s}\n',deblank(tit(i,:)),int2str(fig));
fprintf(fidTeX,'\\label{Fig:IRF:%s:%s}\n',deblank(tit(i,:)),int2str(nbplt));
fprintf(fidTeX,'\\end{figure}\n');
fprintf(fidTeX,' \n');
end
% close(hh);
% close(hh);
end
hh = figure('Name',['Orthogonalized shock to ' tit(i,:) ' figure ' int2str(nbplt) '.']);
m = 0;
for plt = 1:number_of_plots_to_draw-(nbplt-1)*nstar;
m = m+1;
subplot(lr,lc,m);
plot(1:options_.irf,transpose(irfs((nbplt-1)*nstar+plt,:)),'-k','linewidth',1);
hold on
plot([1 options_.irf],[0 0],'-r','linewidth',0.5);
hold off
xlim([1 options_.irf]);
title(deblank(mylist((nbplt-1)*nstar+plt,:)),'Interpreter','none');
end
eval(['print -depsc2 ' M_.fname '_IRF_' deblank(tit(i,:)) int2str(nbplt)]);
eval(['print -dpdf ' M_.fname '_IRF_' deblank(tit(i,:)) int2str(nbplt)]);
saveas(hh,[M_.fname '_IRF_' deblank(tit(i,:)) int2str(nbplt) '.fig']);
if TeX
fprintf(fidTeX,'\\begin{figure}[H]\n');
for j = 1:m
fprintf(fidTeX,['\\psfrag{%s}[1][][0.5][0]{$%s$}\n'],deblank(mylist((nbplt-1)*nstar+j,:)),deblank(mylistTeX((nbplt-1)*nstar+j,:)));
end
fprintf(fidTeX,'\\centering \n');
fprintf(fidTeX,'\\includegraphics[scale=0.5]{%s_IRF_%s%s}\n',M_.fname,deblank(tit(i,:)),int2str(nbplt));
if options_.relative_irf
fprintf(fidTeX,['\\caption{Relative impulse response functions' ...
' (orthogonalized shock to $%s$).}'],deblank(titTeX(i,:)));
else
fprintf(fidTeX,['\\caption{Impulse response functions' ...
' (orthogonalized shock to $%s$).}'],deblank(titTeX(i,:)));
end
fprintf(fidTeX,'\\label{Fig:IRF:%s:%s}\n',deblank(tit(i,:)),int2str(nbplt));
fprintf(fidTeX,'\\end{figure}\n');
fprintf(fidTeX,' \n');
end
% close(hh);
end
end
end
iter_ = olditer;
if TeX
fprintf(fidTeX,' \n');
fprintf(fidTeX,'%% End Of TeX file. \n');
fclose(fidTeX);
iter_ = olditer;
if TeX
fprintf(fidTeX,' \n');
fprintf(fidTeX,'%% End Of TeX file. \n');
fclose(fidTeX);
end
end
end