MS-SBVAR: clean up plot_ms_*.m
parent
4e41ad7285
commit
11c63e5050
|
@ -7,10 +7,10 @@ function plot_ms_forecast(M_,options_,forecast,title_,save_graph_formats,TeX)
|
|||
% forecast should be in the form (percentile x horizon x nvar ), if banded otherwise
|
||||
% ( horizon x nvar )
|
||||
%
|
||||
% title: optional super title
|
||||
% title: title
|
||||
%
|
||||
|
||||
% Copyright (C) 2011 Dynare Team
|
||||
% Copyright (C) 2011-2012 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -26,15 +26,12 @@ function plot_ms_forecast(M_,options_,forecast,title_,save_graph_formats,TeX)
|
|||
%
|
||||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
nc = 2;
|
||||
nr = 2;
|
||||
nvars = M_.endo_nbr;
|
||||
endo_names = M_.endo_names;
|
||||
|
||||
var_list = endo_names(1:M_.orig_endo_nbr,:);
|
||||
|
||||
i_var = [];
|
||||
names = {};
|
||||
tex_names = {};
|
||||
m = 1;
|
||||
|
@ -49,16 +46,9 @@ function plot_ms_forecast(M_,options_,forecast,title_,save_graph_formats,TeX)
|
|||
tex_names{m} = tex_name;
|
||||
m = m + 1;
|
||||
end
|
||||
i_var = [i_var; tmp];
|
||||
end
|
||||
nvar = length(i_var);
|
||||
|
||||
|
||||
dims = size(forecast);
|
||||
|
||||
if nargin < 3
|
||||
title_ = '';
|
||||
end
|
||||
|
||||
if (length(dims) == 2)
|
||||
% Point Forecast (horizon x nvars )
|
||||
horizon = dims(1);
|
||||
|
@ -66,7 +56,7 @@ function plot_ms_forecast(M_,options_,forecast,title_,save_graph_formats,TeX)
|
|||
elseif (length(dims) == 3)
|
||||
% Banded Forecast
|
||||
horizon = dims(2);
|
||||
num_percentiles = dims(1);
|
||||
num_percentiles = dims(1);
|
||||
else
|
||||
error('The impulse response matrix passed to be plotted does not appear to be the correct size');
|
||||
end
|
||||
|
@ -86,16 +76,16 @@ end
|
|||
function plot_point_forecast(forecast,nvars,nr,nc,endo_names,title_,save_graph_formats,TeX,names,tex_names,dirname)
|
||||
if nvars > nr*nc
|
||||
graph_name = 'MS-Forecast (1)';
|
||||
fig = figure('Name','Forecast (I)');
|
||||
fig = figure('Name','Forecast (I)');
|
||||
else
|
||||
graph_name = 'MS-Forecast';
|
||||
fig = figure('Name','Forecast');
|
||||
end
|
||||
fig = figure('Name','Forecast');
|
||||
end
|
||||
m = 1;
|
||||
n_fig = 1;
|
||||
for j=1:nvars
|
||||
if m > nr*nc
|
||||
graph_name = ['MS-Forecast (' int2str(n_fig) ')']
|
||||
graph_name = ['MS-Forecast (' int2str(n_fig) ')'];
|
||||
dyn_save_graph(dirname,['MS-forecast-' int2str(n_fig)],...
|
||||
save_graph_formats,TeX,names,tex_names,graph_name);
|
||||
n_fig =n_fig+1;
|
||||
|
@ -118,11 +108,11 @@ end
|
|||
function plot_banded_forecast(forecast,nvars,nr,nc,endo_names,num_percentiles,title_,save_graph_formats,TeX,names,tex_names,dirname)
|
||||
if nvars > nr*nc
|
||||
graph_name = 'MS-Forecast (1)';
|
||||
fig = figure('Name','Forecast (I)');
|
||||
fig = figure('Name','Forecast (I)');
|
||||
else
|
||||
graph_name = 'MS-Forecast';
|
||||
fig = figure('Name','Forecast');
|
||||
end
|
||||
fig = figure('Name','Forecast');
|
||||
end
|
||||
m = 1;
|
||||
n_fig = 1;
|
||||
for j=1:nvars
|
||||
|
|
|
@ -8,8 +8,8 @@ function plot_ms_irf(M_, options_, irf, title_, varlist)
|
|||
% ( horizon x (nvar x nvar) )
|
||||
% title: optional super title
|
||||
%
|
||||
% The element in position (k,i+j*nvars) of ir is the response of the ith
|
||||
% variable to the jth shock at horizon k. Horizon 0 is the contemporaneous
|
||||
% The element in position (k,i+j*nvars) of ir is the response of the ith
|
||||
% variable to the jth shock at horizon k. Horizon 0 is the contemporaneous
|
||||
% response.
|
||||
|
||||
% Copyright (C) 2011-2012 Dynare Team
|
||||
|
@ -32,17 +32,14 @@ function plot_ms_irf(M_, options_, irf, title_, varlist)
|
|||
if nargin < 4
|
||||
title_ = '';
|
||||
end
|
||||
|
||||
nc = 2;
|
||||
nr = 2;
|
||||
|
||||
nvars = M_.endo_nbr;
|
||||
endo_names = M_.endo_names;
|
||||
|
||||
|
||||
if isempty(varlist)
|
||||
var_list = endo_names(1:M_.orig_endo_nbr,:);
|
||||
end
|
||||
|
||||
i_var = [];
|
||||
|
||||
names = {};
|
||||
tex_names = {};
|
||||
m = 1;
|
||||
|
@ -51,7 +48,6 @@ function plot_ms_irf(M_, options_, irf, title_, varlist)
|
|||
if isempty(tmp)
|
||||
error([var_list(i,:) ' isn''t and endogenous variable'])
|
||||
end
|
||||
i_var = [i_var; tmp];
|
||||
tex_name = deblank(M_.endo_names_tex(tmp,:));
|
||||
if ~isempty(tex_name)
|
||||
names{m} = deblank(var_list(i,:));
|
||||
|
@ -68,11 +64,8 @@ function plot_ms_irf(M_, options_, irf, title_, varlist)
|
|||
m = m + 1;
|
||||
end
|
||||
end
|
||||
|
||||
nvar = length(i_var);
|
||||
|
||||
dims = size(irf);
|
||||
|
||||
if (length(dims) == 2)
|
||||
% Point IRF (horizon x (nvarsxnvars) )
|
||||
horizon = dims(1);
|
||||
|
@ -84,11 +77,11 @@ function plot_ms_irf(M_, options_, irf, title_, varlist)
|
|||
else
|
||||
error('The impulse response matrix passed to be plotted does not appear to be the correct size');
|
||||
end
|
||||
|
||||
|
||||
if size(endo_names,1) ~= nvars
|
||||
error('The names passed are not the same length as the number of variables')
|
||||
end
|
||||
|
||||
|
||||
if num_percentiles == 1
|
||||
% loop through the shocks
|
||||
for s=1:nvars
|
||||
|
@ -111,7 +104,6 @@ function plot_ms_irf(M_, options_, irf, title_, varlist)
|
|||
title_, [options_.ms.output_file_tag filesep 'Output' filesep 'IRF'], options_, names, tex_names);
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function [fig] = plot_point_irf_for_shock(irf,nvars,endo_names,shock_name,title_,dirname,options_,names,tex_names)
|
||||
|
@ -142,5 +134,3 @@ function [fig] = plot_banded_irf_for_shock(irf,nvars, endo_names, shock_name,tit
|
|||
dyn_save_graph(dirname,[title_ ' ' shock_name],options_.graph_save_formats, ...
|
||||
options_.TeX,names,tex_names,[title_ ' ' shock_name]);
|
||||
end
|
||||
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ function plot_ms_variance_decomposition(M_, options_, vd, title_, graph_save_for
|
|||
% Example:
|
||||
% plot_historic_decomposition(shocks,'VD','shock_names',shock_names,'series_names',series_names)
|
||||
|
||||
% Copyright (C) 2011 Dynare Team
|
||||
% Copyright (C) 2011-2012 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -48,11 +48,13 @@ function plot_ms_variance_decomposition(M_, options_, vd, title_, graph_save_for
|
|||
m = m + 1;
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
dims = size(vd);
|
||||
if length(dims) == 3
|
||||
[T,K,J] = dims;
|
||||
shocks = vd;
|
||||
T = dims(1);
|
||||
K = dims(2);
|
||||
J = dims(3);
|
||||
shocks = vd;
|
||||
else
|
||||
T = dims(1);
|
||||
K = nvars;
|
||||
|
@ -65,30 +67,25 @@ function plot_ms_variance_decomposition(M_, options_, vd, title_, graph_save_for
|
|||
end
|
||||
shocks = temp_vd;
|
||||
end
|
||||
|
||||
|
||||
for i=1:nvars
|
||||
shock_names{i} = endo_names(i,:);
|
||||
series_names{i} = endo_names(i,:);
|
||||
end
|
||||
|
||||
if nargin < 2
|
||||
title_ = '';
|
||||
end
|
||||
|
||||
x = [1:T]; plot_dates = 0;
|
||||
|
||||
x = [1:T];
|
||||
plot_dates = 0;
|
||||
data = 0;
|
||||
steady = 0;
|
||||
|
||||
colors = [ .1 .1 .75
|
||||
.8 0 0
|
||||
1 .7 .25
|
||||
1 1 0
|
||||
.5 1 .5
|
||||
1 1 0
|
||||
.5 1 .5
|
||||
.7 .7 .1
|
||||
.5 .6 .2
|
||||
.1 .5 .1];
|
||||
|
||||
|
||||
% overide the defaults with optional inputs
|
||||
for i=1:length(varargin)
|
||||
if strcmpi(varargin{i},'data')
|
||||
|
@ -105,11 +102,10 @@ function plot_ms_variance_decomposition(M_, options_, vd, title_, graph_save_for
|
|||
colors = varargin{i+1};
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
% add an extra period to the time series
|
||||
x(T+1) = x(T) + (x(T) - x(T-1));
|
||||
|
||||
|
||||
figure('Name',title_)
|
||||
for k=1:K
|
||||
% Go through each series
|
||||
|
@ -144,13 +140,13 @@ function plot_ms_variance_decomposition(M_, options_, vd, title_, graph_save_for
|
|||
plot(x(2:end)',steady(:,k), '--k','LineWidth',2.25);
|
||||
end
|
||||
if k==K
|
||||
if exist('OCTAVE_VERSION')
|
||||
if exist('OCTAVE_VERSION')
|
||||
legend(shock_names,'Location','SouthOutside');
|
||||
else
|
||||
legend(shock_names,'Location','BestOutside','Orientation','horizontal');
|
||||
else
|
||||
legend(shock_names,'Location','BestOutside','Orientation','horizontal');
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
hold off
|
||||
if plot_dates
|
||||
datetick 'x';
|
||||
|
@ -159,7 +155,6 @@ function plot_ms_variance_decomposition(M_, options_, vd, title_, graph_save_for
|
|||
ylim([0 , 1])
|
||||
grid on
|
||||
title(series_names{k});
|
||||
%suptitle(title_);
|
||||
end
|
||||
dyn_save_graph([options_.ms.output_file_tag filesep 'Output' ...
|
||||
filesep 'Variance_Decomposition'], 'MS-Variance-Decomposition', ...
|
||||
|
|
Loading…
Reference in New Issue