Q: combining IRFs into subplotted figures & iterating?
Posted: Wed Jan 08, 2014 1:21 pm
Hi all,
I am really frustrated by the following issue but didn't find answers in the forum, so I'm afraid I had to raise the frequently asked problem again. The setup is that I have two models, and want to compare the IRFs of each endogenous variables due to exo shocks. Say, model 1 and 2, both have endo variables y and c, exo shocks ea and em. So, the names of two models' variables are totally the same. Now, I want to plot two IRF figures, one for response of shock ea, another em.Each figure has two subfigures,one for response of y,another c.And each subfigure has two curves, one stands for IRF of model 1, another model 2. By learning from related posts in this forum, I just write the following code, but failed to run it out.
Matlab just stopped by warning"Undefined variable "irf1" or class "irf1.y_ea"."I guess the contents of irf1 are just overlapped by irf2, because all the variable names are the same among the two models. But I don't know how to get rid of the problem.Could anyone kindly give me another hand please?
Many thanks indeed.
GOODLUCK
I am really frustrated by the following issue but didn't find answers in the forum, so I'm afraid I had to raise the frequently asked problem again. The setup is that I have two models, and want to compare the IRFs of each endogenous variables due to exo shocks. Say, model 1 and 2, both have endo variables y and c, exo shocks ea and em. So, the names of two models' variables are totally the same. Now, I want to plot two IRF figures, one for response of shock ea, another em.Each figure has two subfigures,one for response of y,another c.And each subfigure has two curves, one stands for IRF of model 1, another model 2. By learning from related posts in this forum, I just write the following code, but failed to run it out.
- Code: Select all
dynare model1.mod
load('model1_results.mat', 'oo_')
irf1=oo_.irfs;
save irf1
load irf1
dynare model2.mod
load('model2_results.mat', 'oo_')
irf2=oo_.irfs;
save irf2
load irf2
ending_cell={'_ea','_em'};
for ii=1:length(ending_cell)
HOR=1:1:40;
var={'y','c'};
figure
for jj=1:length(var)
subplot(1,2,jj)
eval(['irf1.' var{1,jj},ending_cell{1,ii}]);
eval(['irf2.' var{1,jj},ending_cell{1,ii}]);
hold on
plot(HOR,[eval(['irf1.' var{1,jj},ending_cell{1,ii}])],'LineWidth',1,'-k',HOR,[eval(['irf2.' var{1,jj},ending_cell{1,ii}])],'LineWidth',1,'--r')
title([var{1,jj}] )
end
end
Matlab just stopped by warning"Undefined variable "irf1" or class "irf1.y_ea"."I guess the contents of irf1 are just overlapped by irf2, because all the variable names are the same among the two models. But I don't know how to get rid of the problem.Could anyone kindly give me another hand please?
Many thanks indeed.
GOODLUCK