modified varlist_indices

time-shift
Michel Juillard 2010-03-23 06:38:39 +01:00
parent c5bc424dd4
commit 436fdf97c6
3 changed files with 23 additions and 24 deletions

View File

@ -1,7 +1,7 @@
function []=graph_decomp(z,shock_names,varlist,initial_date)
function []=graph_decomp(z,shock_names,endo_names,i_var,initial_date)
%function []=graph_decomp(z,varlist,initial_period,freq)
% Copyright (C) 2009 Dynare Team
% Copyright (C) 2010 Dynare Team
%
% This file is part of Dynare.
%
@ -18,7 +18,6 @@ function []=graph_decomp(z,shock_names,varlist,initial_date)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
global M_
% number of components equals number of shocks + 1 (initial conditions)
comp_nbr = size(z,2)-1;
@ -27,7 +26,8 @@ freq = initial_date.freq;
initial_period = initial_date.period + initial_date.sub_period/freq;
x = initial_period-1/freq:(1/freq):initial_period+(gend-1)/freq;
[i_var,nvar] = varlist_indices(varlist);
nvar = length(i_var);
for j=1:nvar
z1 = squeeze(z(i_var(j),:,:));
xmin = x(1);
@ -39,7 +39,7 @@ for j=1:nvar
if ymax-ymin < 1e-6
continue
end
figure('Name',M_.endo_names(i_var(j),:));
figure('Name',endo_names(i_var(j),:));
ax=axes('Position',[0.1 0.1 0.6 0.8]);
axis(ax,[xmin xmax ymin ymax]);
plot(ax,x(2:end),z1(end,:),'k-','LineWidth',2)

View File

@ -37,7 +37,11 @@ endo_nbr = M_.endo_nbr;
nshocks = M_.exo_nbr;
% indices of endogenous variables
[i_var,nvar] = varlist_indices(varlist);
if size(varlist,1) == 0
varlist = M_.endo_names(M_.orig_endo_nbr);
end
[i_var,nvar] = varlist_indices(varlist,M_.endo_names);
% reduced form
dr = oo_.dr;
@ -91,4 +95,4 @@ options_.initial_date.freq = 1;
options_.initial_date.period = 1;
options_.initial_date.sub_period = 0;
graph_decomp(z,M_.exo_names,varlist,options_.initial_date)
graph_decomp(z,M_.exo_names,i_var,options_.initial_date)

View File

@ -1,9 +1,10 @@
function [i_var,nvar] = varlist_indices(varlist)
% function [i_var,nvar] = varlist_indices(varlist)
function [i_var,nvar] = varlist_indices(sublist,list)
% function [i_var,nvar] = varlist_indices(sublist,list)
% returns the indices of a list of endogenous variables
%
% INPUT
% varlist: (character area) list of variables
% sublist: sublist of variables
% list: list of variables
%
% OUTPUT
% i_var: variable indices in M_.endo_names
@ -12,7 +13,7 @@ function [i_var,nvar] = varlist_indices(varlist)
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2009 Dynare Team
% Copyright (C) 2010 Dynare Team
%
% This file is part of Dynare.
%
@ -29,19 +30,13 @@ function [i_var,nvar] = varlist_indices(varlist)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
global M_
endo_nbr = M_.endo_nbr;
[check,i_var] = ismember(sublist,list,'rows');
if isempty(varlist)
varlist = M_.endo_names(1:M_.orig_endo_nbr,:);
end
i_var = [];
for i=1:size(varlist,1)
tmp = strmatch(varlist(i,:),M_.endo_names,'exact');
if isempty(tmp)
error([tmp ' isn''t an endogenous variable'])
end
i_var = [i_var; tmp];
end
nvar = length(i_var);
if ~all(check)
k =find(check);
error(strcat(sublist(k,:),' hasn''t been declared'))
end