How to plot multiple IRFs in Dynare

Hi,I am wondering how to plot multiple IRFs in one graph?
e.g. there are 3 shocks: s1 s2 s3;
and 3 endogneous variables: inv y c;
how am I supposed to plot the impact of s1(shock1) on inv and y and c only?
when I first ran the dynare stoch_simul, it plots the endogneous variables in two seperate graphs to all shocks.

thanks in advance

Hi
You will need to create the figure from dynare’s output.
In the filename_results file, you will find a matlab structure called oo_
You will find the irfs in oo_.irfs
and they are named as oo_.irfs.variable_shock…

once you retreive the irfs, you can plot in a standard plot using the hold on/off option to show multiple irfs.

Reuben

Many thanks for your reply! I will try!

also, I know that it’s possible to plot IRFs for endogenous variables of my interests by simply specifying names of them following the stoch_simul command, but is it possible to plot IRFs for shocks of my interests only?

You will need to set the std devs of shocks that you are not interested in, to zero.

Yes, I have tried and succeeded!
do you also know how to make all of them appear in one figure (if no. of endogenous is >9)
, it seems the default in Dynare is 9, is it possible to plot them with names I specified in Dynare?

Hi, as suggested by @punnoosejacob you can use the IRFs data saved by Dynare under oo_.irfs and matlab plotting commands to get the figure you want (search for the plot and subplot functions in the matlab documentation. Also note that:

  1. by default the variance of the innovations are zero (ie if you do not specifiy variance in the shocks block the associated IRFs will not show up).

  2. You can list a subset of endogenous variables after the stoch_simul command. The results for the other endogenous variables will not be displayed (see the Dynare reference manual).

Best,
Stéphane.

thanks for your detailed reply!
I am modifidying the SW codes available online which have specified the variances and AR coefficients for all shocks. Are these values all randomly assigned?

I do not know which file you are referring to… But I suppose the variance of innovations and autoregressive parameters are estimated.

Best,
Stéphane.

also, another way of doing so is by specifying irf_shocks=(eg,ea…) insides the options for stoch_simul .

it’s the new feature added onto the new version of Dynare

Hi, thanks for your reply, but I was asking stuff prior to the estimation block, the initial AR coefficients and the variances of innovations speficied in the “parameters” and “shocks” blocks. How we do assign them initial values?

If these parameters are estimated after, the values you provide before the estimation command do not really matter. If you do not estimate the model, you need to check that the unconditional moments (variance and autocorrelations) are not at odds with what you have in the data (for the observed endogenous variables). Hopefully, others have probably met the same kind problems, so you will surely find sensible values (or initial guesses upon which to improve) in the literature.

Best,
Stéphane.

thanks! it is all clear now!
btw, the mod file for SW(07)has specified the initial AR coefficient for some stochastic process as 0, e.g. the innovation in the Taylor rule, does it matter?

as for plotting IRF inside Matlab using results saved in oo_irfs, could you please provide me with more details? ( e.g. example of matlab code) as I am new to both Matlab and Dynare.

thanks in advance

please post your mod file. what exactly do you want to plot?

Thanks, I have figured it out by myself following the example provided at https://github.com/JohannesPfeifer/DSGE_mod/blob/master/Ireland_2004/Ireland_2004.mod

matlab plot.fig (139.1 KB)
dynare plot.fig (129.0 KB)

However, a new issue I have just noticed is:

using the code below:
stoch_simul(noprint,nofunctions,nomoments,nocorr,irf=50,irf_shocks=(eg))r inve pk kp pinf w c y lab rk;

figure

subplot(4,3,1)
plot([0:options_.irf],[0 oo_.irfs.r_eg])
//axis tight
title(‘interest rate’)

subplot(4,3,2)
plot([0:options_.irf],[0 oo_.irfs.inve_eg])
axis tight
title(‘investment’)

subplot(4,3,3)
plot([0:options_.irf],[0 oo_.irfs.pk_eg])
axis tight
title(‘tobin Q’)

subplot(4,3,4)
plot([0:options_.irf],[0 oo_.irfs.kp_eg])
axis tight
title(‘capital’)

subplot(4,3,5)
plot([0:options_.irf],[0 oo_.irfs.pinf_eg])
axis tight
title(‘inflation’)

subplot(4,3,6)
plot([0:options_.irf],[0 oo_.irfs.w_eg])
axis tight
title(‘wage’)

subplot(4,3,7)
plot([0:options_.irf],[0 oo_.irfs.c_eg])
axis tight
title(‘consumption’)

subplot(4,3,8)
plot([0:options_.irf],[0 oo_.irfs.y_eg])
axis tight
title(‘output’)

subplot(4,3,9)
plot([0:options_.irf],[0 oo_.irfs.lab_eg])
axis tight
title(‘labour’)

subplot(4,3,10)
plot([0:options_.irf],[0 oo_.irfs.rk_eg])
axis tight
title(‘rental rate of capital’)

the plots in matlab and dynare are actually different!
the starting point in all matlab plots are origins.
please could anyone signal me the reason?

Hi, it’s a matter of convention. In the matlab plot the initial point is the initial condition (the steady state or 0 since we consider deviations to the steady state), the shock happens in the following period. While in Dynare the plots start in period one when the shock actually happens.

Best,
Stéphane.

1 Like

That is because in the matlab plots, the plotted vectors start at 0.
plot([0:options_.irf],[0 oo_.irfs.rk_eg])

1 Like

Hi, thanks !
how I am supposed to fix the problem then?
I am more used to the one specified in Dynare ( where the starting point indicates the positive/negative shock).

thanks! how am I supposed to make the matlab plots consistent with the ones from Dynare?