# Impulse responses don't display when solving to second order

**URL:** <https://forum.dynare.org/t/impulse-responses-dont-display-when-solving-to-second-order/1089>\
**Category:** Dynare help (legacy posts)\
**Created:** [26 June 2009 18:46 UTC](https://forum.dynare.org/t/impulse-responses-dont-display-when-solving-to-second-order/1089 "2009-06-26T18:46:07Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![davidamdur](https://forum.dynare.org/letter_avatar_proxy/v4/letter/d/9de053/32.png) [@davidamdur](https://forum.dynare.org/u/davidamdur)\
**Post date:** [26 June 2009 18:46 UTC](https://forum.dynare.org/t/impulse-responses-dont-display-when-solving-to-second-order/1089/1 "2009-06-26T18:46:07Z")

</div>

I am using 4.0.4, and I have a simple Dynare model that behaves as follows. When I do stoch\_simul(order=1), everything works fine and I see four sets of impulse response graphs. However, when I do stoch\_simul(order=2), Dynare appears to solve the model successfully, but no impulse response graphs appear. Has anyone run into this? Is it (possibly) a bug in 4.0.4? I am new to Dynare, so I may well be missing something.

More details: when I run Dynare on Villaverde’s rbc.mod (from the ‘examples’ section of the website), the impulse response graphs appear both for first order and second order. However, for my model, they appear at first order only. I believe Dynare has solved my model successfully to second order, because I see nonzero coefficients on cross-product terms in the policy and transition functions table. Dynare also displays theoretical moments, variance decomposition, matrix of correlations and coefficients of autocorrelation. Just no impulse response graphs at second order. I can provide my mod file if that would help.

Any help greatly appreciated.

Thanks,  
Dave

---

<div class="post-metadata">

**Author:** ![davidamdur](https://forum.dynare.org/letter_avatar_proxy/v4/letter/d/9de053/32.png) [@davidamdur](https://forum.dynare.org/u/davidamdur)\
**Post date:** [29 June 2009 16:07 UTC](https://forum.dynare.org/t/impulse-responses-dont-display-when-solving-to-second-order/1089/2 "2009-06-29T16:07:39Z")

</div>

Here’s an update. When I look at oo\_.irfs (at second order), I see all NaNs. Also, when I turn the “simul” flag on, all the simulated moments are also NaN. I went a little deeper and stepped through stoch\_simul (and dependent functions) in the debugger. I noticed that my simulated endogenous variables grew very quickly in magnitude with each iterated period. Sure enough, after about five periods, all the simulated variables were NaN.

So it looks like I have an explosive model, at least to second order. What confuses me a bit is that the Blanchard-Kahn condition was satisfied, and Dynare did find a unique solution for the policy and transition functions. I also get well-defined theoretical moments. I thought that if Blanchard-Kahn was satisfied, the resulting solution was theoretically non-explosive?

I do suspect the “cuplrit” here is a near-unit-root in the model. I have a two-country international model with incomplete markets; without any frictions, such models have a unit root in the state variable for (relative) wealth. I’ve imposed a portfolio adjustment cost (similar to Schmitt-Grohe and Uribe (2003)), which should make the model theoretically stationary. However, perhaps it is “close enough” to being nonstationary that the Monte Carlo simulations fail.

So, does anyone out there have experience simulating international models with near-unit-roots in Dynare? Any ideas/workarounds for getting Monte Carlo simulations to work in this type of environment? As a newbie to Dynare, I appreciate any thoughts or advice.

Thanks,  
Dave

---

<div class="post-metadata">

**Author:** ![davidamdur](https://forum.dynare.org/letter_avatar_proxy/v4/letter/d/9de053/32.png) [@davidamdur](https://forum.dynare.org/u/davidamdur)\
**Post date:** [29 June 2009 18:55 UTC](https://forum.dynare.org/t/impulse-responses-dont-display-when-solving-to-second-order/1089/3 "2009-06-29T18:55:04Z")

</div>

I think I fixed my problem. My shock variances were way too high. When I reset the shock variances to something reasonable (0.01^2 instead of 1), everything worked fine. With the variances accidentally that high and the reversion back to steady-state fairly slow, the simulation was probably wandering very far from the steady state, where the dynamics are not very accurate.

It might be nice if MATLAB displayed an error for this case. For example, if the Monte Carlo simulation in simult\_ yields (absolute) values for endogenous variables that are above a certain threshold, error out with a message like “Error simulating the model. The model appears explosive using the shock variances supplied. Ensure that the model is stationary and/or consider trying smaller shock variances.”

Anyway, I’m glad to be back in business (for the moment).

Dave

---

<div class="post-metadata">

**Author:** ![davidamdur](https://forum.dynare.org/letter_avatar_proxy/v4/letter/d/9de053/32.png) [@davidamdur](https://forum.dynare.org/u/davidamdur)\
**Post date:** [2 July 2009 21:14 UTC](https://forum.dynare.org/t/impulse-responses-dont-display-when-solving-to-second-order/1089/4 "2009-07-02T21:14:52Z")

</div>

Just a note that that I found these closely related threads:

> [@Error in output results - what does it mean?](https://forum.dynare.org/t/error-in-output-results-what-does-it-mean/363/1):
>
> I am trying to estimate a DSGE model with monopolistic competition and price rigidity according to Rotemberg (1983). The model, in levels, takes Peter Ireland’s framework. I have attached the mod.file I’m getting the follow output “error”. What does it mean? There is no impulse response functions neither. Can someone have a look and tell me where the problem might be? Merci/Thanks, pycs [Irelandmoney4.mod](https://forum.dynare.org/uploads/default/original/1X/d9b686c867308ecb9461a79c3ea0607afbf5ca47.mod) (1.71 KB)

> [@2nd order decision rule](https://forum.dynare.org/t/2nd-order-decision-rule/1034/1):
>
> Hi, I am solving a relatively big DSGE model using Dynare version 4.0.3: MODEL SUMMARY Number of variables: 260 Number of stochastic shocks: 1 Number of state variables: 86 Number of jumpers: 26 Number of static variables: 154 I did not have problems with the 1st order approximation, when all the irf`s were plotted correctly. Only changing to “order=2”, to run the 2nd approximation, the log file did not report errors, but all the irf 's values are NaN. Since Dynare…

> [@Pruning in Dynare++](https://forum.dynare.org/t/pruning-in-dynare/843/1):
>
> I’m getting explosive IRFs for a second-order approximation to a model in dynare++, which is chracteristic of 3rd and 4th order terms getting introduced from multiplication of 1st and 2nd order ones. Of course, the problem could be with my model somewhere, but it’d be nice to rule out the possibility of higher order terms creeping in. So does anyone know if dynare++ already has a pruning algorithm in it, or if there’s any other diagnostic I could use to see if this is the source of the problem…

and especially (for Dynare 3.0.65):

> [@Pruning algorithm for second order approximation](https://forum.dynare.org/t/pruning-algorithm-for-second-order-approximation/632/1):
>
> Dear all, due to the ongoing difficulties with explosive simulations with second order approximations, I introduced the option for the pruning algorithm in Dynare 3.065 described in Kim, Kim, Schaumburg and Sims (2005): “Calculating and using second order accurate solutions of discrete time dynamic equilibrium models” In order to use it correctly under Windows, please proceed as follows: Download the simult\_pruning.m file in the attachment to the Dynare directory, generally under …\dynare\_v3…

Sounds like an implementation of Chris Sim’s pruning algorithm for version 4 would be a crowd pleaser.

---

<div class="post-metadata">

**Author:** ![davidamdur](https://forum.dynare.org/letter_avatar_proxy/v4/letter/d/9de053/32.png) [@davidamdur](https://forum.dynare.org/u/davidamdur)\
**Post date:** [7 July 2009 15:00 UTC](https://forum.dynare.org/t/impulse-responses-dont-display-when-solving-to-second-order/1089/5 "2009-07-07T15:00:11Z")

</div>

Stephan has now posted a version of Chris Sims’ pruning algorithm for Dynare 4.0.4 here:

> [@Pruning implementation for Dynare 4.0.4?](https://forum.dynare.org/t/pruning-implementation-for-dynare-4-0-4/1096/1):
>
> Does anyone have (or know of) an implementation of Chris Sims’ pruning algorithm that runs in Dynare 4.0.4? I’m interested in a modification of simult\_.m along these lines: [https://forum.dynare.org/t/pruning-algorithm-for-second-order-approximation/632/1](https://forum.dynare.org/t/pruning-algorithm-for-second-order-approximation/632/1) The above implementation was for 3.065 but doesn’t seem to run in 4.0.4. Any pointers appreciated. Thanks, Dave

This may be helpful if you’re encountering explosive IRFs and simulations at second-order, even though your model is stable to first-order. It was very helpful for me. Read Kim, Kim, Schaumberg and Sims (JEDC 2008) for details.

---

<div class="post-metadata">

**Author:** ![ammm](https://forum.dynare.org/letter_avatar_proxy/v4/letter/a/ee7513/32.png) [@ammm](https://forum.dynare.org/u/ammm)\
**Post date:** [29 August 2012 21:02 UTC](https://forum.dynare.org/t/impulse-responses-dont-display-when-solving-to-second-order/1089/6 "2012-08-29T21:02:49Z")

</div>

Thank you for this post, I have the same issue and reducing the shock variances or using the pruning algorithm helps. I just want to add that this algorithm is included in Dynare versions 4.3 and higher. Simply include the option ‘pruning’ into stoch\_simul().
