Page 1 of 1

Impulse responses with multiple shocks

PostPosted: Tue Sep 28, 2010 8:00 pm
by jsteinberg
I have a simple RBC model with time-varying risk of the form
Code: Select all
// stochastic process
sigma_e = rho_sigma_e*sigma_e(-1) + (1-rho_sigma_e)*mean_sigma_e + sigma_eta*eta;
a = rho_a*a(-1) + sigma_e*e;

where eta and e are exogenous random variables and the neoclassical production function is
Code: Select all
y = exp(a) * k^alpha * l^(1-alpha)

I would like to use Dynare to generate impulse response functions to risk shocks (i.e. impulse responses to eta). I am performing a third-order approximation of the model so the policy functions depend on sigma_e. Thus a shock to risk (sigma_e) should generate temporary divergence from steady state, even if all draws of the exogenous variable e are zero. This is precisely what I would like to do. However, this is not what Dynare does for the impulse responses to eta. Instead, it seems to draw values of e from its given distribution. Here is what the IRF to eta looks like:
Image
You can see that TFP (a) is receiving non-zero shocks. What I want is for TFP to remain at its steady state value (i.e. the shock e should be zero throughout the impulse response) so that the responses of the endogenous variables to risk shocks are clear. Is there a way to do this? I have attached my complete mod file for reference. Thanks in advance.

Re: Impulse responses with multiple shocks

PostPosted: Mon Oct 25, 2010 1:53 am
by macroguy
I have a similar problem. When I shock the volatility (sigma_e), tfp (a) moves around (I assume because shocks e are also being drawn to simulate the IRFs). However, when I shock tfp directly (an e shock), there is no reaction whatsoever in volatility (sigma_e response is exactly zero). Which makes me feel that shocks eta are not being drawn in this case. Why is does this asymmetry happen? I checked the Dynare manual, but the explanation on Monte-Carlo simulations to compute IRFs for higher order approximations is very generic.

Any help is very much appreciated.

Re: Impulse responses with multiple shocks

PostPosted: Mon Oct 25, 2010 6:25 am
by abscissaordinate
Have you figured out how to do this yet, jsteinberg?

Re: Impulse responses with multiple shocks

PostPosted: Tue Oct 26, 2010 6:39 pm
by jsteinberg
No I have not. I would still like to know how to do it. Alternatively, could someone explain to me how to manually run simulations using the third-order decision rules? It's easy for 1st order, but it's not so clear for higher order approximations.

Re: Impulse responses with multiple shocks

PostPosted: Thu Oct 28, 2010 11:14 pm
by jsteinberg
I figured out how to do this by manually calling the simult_ function. One of its inputs is the sequence of exogenous shocks, so I just constructed that sequence like I wanted and called the function. The output is the time series of all the endogenous variables after impulse.

Re: Impulse responses with multiple shocks

PostPosted: Thu Mar 31, 2011 8:14 pm
by abscissaordinate
Can you show me how you did that?

Thanks!

Re: Impulse responses with multiple shocks

PostPosted: Fri Oct 07, 2011 6:20 am
by gazzani.andrea
No news about it? I am doing volatility shocks as well but I am facing the same problem you posted.
Any help would be useful.
Thanks

Re: Impulse responses with multiple shocks

PostPosted: Wed Oct 19, 2011 1:43 pm
by MichelJuillard
In Dynare, we compute the IRF for shock e, for order=2,3 in the following manner:
1) draw a series of random shocks for 140 periods
2) Perform simulation Y1
3) Add one standard deviation to the simulated series for shock e in period 101
4) Perform simuluation Y2
5) The IRF for this experiment is equal to Y2-Y1
6) Results obtained in 5) is affected by idiosyncratic shocks other than the one impulse in period 101. In order to average over the effect of these idiosyncratic shocks, we perform 50 replications of steps 1) to 5) and report the average.

-Initial 100 warming periods is the default value of option DROP
-40 periods for the IRF is the default value of option IRF
-50 replications is the default value of option REPLIC

By following this procedure, we average over the influence of the state point at which the impulse occurs and of future shocks in periods after the impulse. So, we report an average IRF

In the first example in this thread, an impulse on eta has an effect on sigma_e and therefore on a and the other variables of the model. It also creates numerical noise that is very difficult to eliminate by increasing the number of replications.

When jsteinberg says
What I want is for TFP to remain at its steady state value (i.e. the shock e should be zero throughout the impulse response) so that the responses of the endogenous variables to risk shocks are clear.

I think that what you want is the effects on a shock on eta, conditional on the realization of e being always zero. We don't have tool to do that, but, as mentioned by jsteinberg in the thread, it can be done by using function simult_.

I attach an exemple on how to show the IRF for consumption

Best

Michel

Re: Impulse responses with multiple shocks

PostPosted: Thu Oct 20, 2011 2:26 pm
by gazzani.andrea
Thank you very much

Re: Impulse responses with multiple shocks

PostPosted: Fri Oct 21, 2011 11:56 am
by GilBurt
Thanks for good response with multiple stocks.

Re: Impulse responses with multiple shocks

PostPosted: Tue Nov 01, 2011 9:40 pm
by mfer
This was very useful explanation!

I would, however, like to ask a further clarification.
Using the example above *_MJ.mod I tried to do the same exercise at order=3.
The IRFs somewhat differ from what we get at order=2. I attach the figures. In particular what confuses me is:
1.) at order=2, the shock to volatility increases volatility then it returns to its steady state value. However, at order=2, the volatility shock should not have the impact on the path of aggregate variables (only the constant in the policy function).
2.) At order=3, I expect the same behaviour of volatility as at order=2. However, it seems as it drops (after a positive shock) and remains at lower level. This obviously results in strange path of consumption.


Image

The results must come from the line change of simult_ command. With the last argument being order as far as I understand [(function y_=simult_(y0,dr,ex_,iorder)].

I changed
irf2 = simult_(oo_.steady_state,oo_.dr,ex_,2);
to
irf3 = simult_(oo_.steady_state,oo_.dr,ex_,3);

Probably I misinterpreted something. Any ideas or suggestions on this point?
Best


Modified *_MJ.mod code:

Code: Select all
//-----------------------------------------------------------------------------------------------------------------------------------------------
var a,  sigma_e, c, l, x, k, y;
varexo e, eta;

//-----------------------------------------------------------------------------------------------------------------------------------------------
parameters alfa, betta, gamma, mu, delta, phi, rho_a, rho_sigma_e, mean_sigma_e, sigma_eta;

alfa = 0.36; // capital's share of output
betta = 0.99; // discount factor
gamma = -1; // RRA = 1 - gamma
mu = 0.32; // exponent on leisure in Cobb-Douglas part of utility
delta = 0.025; // depreciation
phi = 3; // capital adjustment factor
rho_a = 0.95; // persistence of TFP
rho_sigma_e = 0.97; // persistence of std dev of TFP innovations
mean_sigma_e = 0.008; // unconditional mean of std dev of TFP innovations
sigma_eta = 0.0003; // std dev of innovations to TFP volatility

//-----------------------------------------------------------------------------------------------------------------------------------------------
model(use_dll);

// output
y = exp(a)*(k(-1)^alfa)*(l^(1-alfa));

// labor-leisure
c=mu/(1-mu)*(1-l)*(1-alfa)*exp(a)*(k(-1)^(alfa))*(l^(-alfa));

// budget constraint
c = y - x;

// firm FOC for investment
(((c^mu)*((1-l)^(1-mu)))^(gamma-1))*(mu*(c^(mu-1))*((1-l)^(1-mu)))=(1-2*phi*(x/k(-1)-delta))*betta*(((c(+1)^mu)*((1-l(+1))^(1-mu)))^(gamma-1))*(mu*(c(+1)^(mu-1))*((1-l(+1))^(1-mu)))*( alfa*y(+1)/k + (1-delta + phi*((x(+1)/k)^2 - delta^2))/(1-2*phi*(x(+1)/k-delta)) );

// law of motion for capital
k = (1-delta)*k(-1) + x - phi*k(-1)*(x/k(-1)-delta)^2;

// stochastic process
sigma_e = rho_sigma_e*sigma_e(-1) + (1-rho_sigma_e)*mean_sigma_e + sigma_eta*eta;
a = rho_a*a(-1) + sigma_e*e;

end;

//-----------------------------------------------------------------------------------------------------------------------------------------------
initval;

eta=0;
sigma_e = mean_sigma_e;
a=0;
e=0;
l=0.3;
k=5;
y=(k^alfa)*(l^(1-alfa));
x = delta*k;
c = y - x;

end;

steady;
check;

shocks;
var e = 1;
var eta = 1;
end;


%stoch_simul(order=2);
stoch_simul(order=3, periods=10000, replic=100);

ex_ = zeros(10,2);
ex_(1,2) = 1;




ex_(1,2) = 1;
irf2 = simult_(oo_.steady_state,oo_.dr,ex_,2);
irf3 = simult_(oo_.steady_state,oo_.dr,ex_,3);

irfA2=irf2(1,:)-oo_.steady_state(1);
irfA3=irf3(1,:)-oo_.steady_state(1);


irfSigma2=irf2(2,:)-oo_.steady_state(2);
irfSigma3=irf3(2,:)-oo_.steady_state(2);


cons2=irf2(3,:)-oo_.steady_state(3);
cons3=irf3(3,:)-oo_.steady_state(3);


close all;


figure;
subplot(3,2,1)
plot(irfA2);
legend('A 2nd ord')
subplot(3,2,2)
plot(irfA3);
legend('A 3rd ord')

subplot(3,2,3)
plot(irfSigma2);
legend('sigmae 2nd ord')
subplot(3,2,4)
plot(irfSigma3);
legend('sigmae 3rd ord')

subplot(3,2,5)
plot(cons2);
legend('cons 2nd ord')
subplot(3,2,6)
plot(cons3);
legend('cons 3rd ord')


Re: Impulse responses with multiple shocks

PostPosted: Wed Nov 02, 2011 1:38 pm
by mfer
The solution to my question is in the post: viewtopic.php?f=1&t=3170
Then, everything seems ok.
Please, correct me if you spot that it is not...