From 77488f5f225d93bda648c2f96e84cc49f27008c6 Mon Sep 17 00:00:00 2001 From: Johannes Pfeifer Date: Sun, 19 May 2013 10:50:23 +0200 Subject: [PATCH] Make BVAR obey graph-options and save to graph folder --- matlab/bvar_forecast.m | 9 +++++---- matlab/dynare_graph.m | 10 ++++------ matlab/dynare_graph_init.m | 10 +++++----- matlab/forcst_unc.m | 15 ++++++++------- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/matlab/bvar_forecast.m b/matlab/bvar_forecast.m index 62b6f847c..3ce2883cd 100644 --- a/matlab/bvar_forecast.m +++ b/matlab/bvar_forecast.m @@ -114,17 +114,18 @@ sims_with_shocks_sort = sort(sims_with_shocks, 3); sims_with_shocks_down_conf = sims_with_shocks_sort(:, :, sort_idx(1)); sims_with_shocks_up_conf = sims_with_shocks_sort(:, :, sort_idx(2)); -dynare_graph_init(sprintf('BVAR forecasts (nlags = %d)', nlags), ny, {'b-' 'g-' 'g-' 'r-' 'r-'}); +OutputDirectoryName = CheckPath('graphs',M_.fname); + +dyn_graph=dynare_graph_init(sprintf('BVAR forecasts (nlags = %d)', nlags), ny, {'b-' 'g-' 'g-' 'r-' 'r-'}); for i = 1:ny - dynare_graph([ sims_no_shock_median(:, i) ... + dyn_graph=dynare_graph(dyn_graph,[ sims_no_shock_median(:, i) ... sims_no_shock_up_conf(:, i) sims_no_shock_down_conf(:, i) ... sims_with_shocks_up_conf(:, i) sims_with_shocks_down_conf(:, i) ], ... options_.varobs(i, :)); end -dynare_graph_close; - +dyn_saveas(dyn_graph.fh,[OutputDirectoryName '/' M_.fname '_BVAR_forecast_',num2str(nlags)],options_) % Compute RMSE diff --git a/matlab/dynare_graph.m b/matlab/dynare_graph.m index bc12e7513..9af832f7f 100644 --- a/matlab/dynare_graph.m +++ b/matlab/dynare_graph.m @@ -1,4 +1,4 @@ -function dynare_graph(y,tit,x) +function dyn_graph=dynare_graph(dyn_graph,y,tit,x) % function dynare_graph(y,tit,x) % graphs % @@ -7,12 +7,12 @@ function dynare_graph(y,tit,x) % colors: line colors % % OUTPUT -% none +% dyn_graph: structure with figure information % % SPECIAL REQUIREMENT % none -% Copyright (C) 2006-2009 Dynare Team +% Copyright (C) 2006-2013 Dynare Team % % This file is part of Dynare. % @@ -29,9 +29,7 @@ function dynare_graph(y,tit,x) % You should have received a copy of the GNU General Public License % along with Dynare. If not, see . -global dyn_graph - -if nargin < 3 +if nargin < 4 x = (1:size(y,1))'; end nplot = dyn_graph.plot_nbr + 1; diff --git a/matlab/dynare_graph_init.m b/matlab/dynare_graph_init.m index a4b3d6bd3..4e0af5b8c 100644 --- a/matlab/dynare_graph_init.m +++ b/matlab/dynare_graph_init.m @@ -1,4 +1,4 @@ -function dynare_graph_init(figure_name,nplot,line_types,line_width) +function dyn_graph=dynare_graph_init(figure_name,nplot,line_types,line_width) % function dynare_graph_init(figure_name,colors) % initializes set of graphs % @@ -7,12 +7,12 @@ function dynare_graph_init(figure_name,nplot,line_types,line_width) % colors: line colors % % OUTPUTS -% none +% dyn_graph: structure with figure information % % SPECIAL REQUIREMENT % none -% Copyright (C) 2006-2009 Dynare Team +% Copyright (C) 2006-2013 Dynare Team % % This file is part of Dynare. % @@ -29,9 +29,9 @@ function dynare_graph_init(figure_name,nplot,line_types,line_width) % You should have received a copy of the GNU General Public License % along with Dynare. If not, see . -global dyn_graph options_ +global options_ -dyn_graph.fh = figure('Name',figure_name); +dyn_graph.fh = dyn_figure(options_,'Name',figure_name); dyn_graph.figure_name = figure_name; if nargin > 2 dyn_graph.line_types = line_types; diff --git a/matlab/forcst_unc.m b/matlab/forcst_unc.m index 633164ae1..a402837da 100644 --- a/matlab/forcst_unc.m +++ b/matlab/forcst_unc.m @@ -15,7 +15,7 @@ function forcst_unc(y0,var_list) % SPECIAL REQUIREMENTS % None. -% Copyright (C) 2006-2011 Dynare Team +% Copyright (C) 2006-2013 Dynare Team % % This file is part of Dynare. % @@ -129,20 +129,21 @@ yf3_1 = yf3'-[zeros(maximum_lag,n); yf3_intv]; yf3_2 = yf3'+[zeros(maximum_lag,n); yf3_intv]; % graphs +OutputDirectoryName = CheckPath('graphs',M_.fname); -dynare_graph_init('Forecasts type I',n,{'b-' 'g-' 'g-' 'r-' 'r-'}); +dyn_graph=dynare_graph_init('Forecasts type I',n,{'b-' 'g-' 'g-' 'r-' 'r-'}); for i=1:n - dynare_graph([yf_mean(:,i) squeeze(yf1(:,i,k1)) squeeze(yf2(:,i,k2))],... + dynare_graph(dyn_graph,[yf_mean(:,i) squeeze(yf1(:,i,k1)) squeeze(yf2(:,i,k2))],... var_list(i,:)); end -dynare_graph_close; +dyn_saveas(dyn_graph.fh,[OutputDirectoryName '/' M_.fname '_forecast_param_uncert_',num2str(nlags)],options_) -dynare_graph_init('Forecasts type II',n,{'b-' 'k-' 'k-' 'r-' 'r-'}); +dyn_graph=dynare_graph_init('Forecasts type II',n,{'b-' 'k-' 'k-' 'r-' 'r-'}); for i=1:n - dynare_graph([yf_mean(:,i) yf3_1(:,i) yf3_2(:,i) squeeze(yf2(:,i,k2))],... + dynare_graph(dyn_graph,[yf_mean(:,i) yf3_1(:,i) yf3_2(:,i) squeeze(yf2(:,i,k2))],... var_list(i,:)); end -dynare_graph_close; +dyn_saveas(dyn_graph.fh,[OutputDirectoryName '/' M_.fname '_forecast_param_shock_uncert_',num2str(nlags)],options_) % saving results