# Error:The steady state contains NaN or Inf

**URL:** <https://forum.dynare.org/t/error-the-steady-state-contains-nan-or-inf/12839>\
**Category:** Steady state\
**Created:** [22 November 2018 06:49 UTC](https://forum.dynare.org/t/error-the-steady-state-contains-nan-or-inf/12839 "2018-11-22T06:49:43Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![christineqi](https://forum.dynare.org/letter_avatar_proxy/v4/letter/c/eb9ed0/32.png) [@christineqi](https://forum.dynare.org/u/christineqi)\
**Post date:** [22 November 2018 06:49 UTC](https://forum.dynare.org/t/error-the-steady-state-contains-nan-or-inf/12839/1 "2018-11-22T06:49:43Z")

</div>

Dear all,  
my mod file failed with the error:the steady state contains NaN or Inf.  
I checked for lots of times, but I don’ know why.  
The mod file is attached below.  
Thank you very much.  
Christine[fiscal.mod](https://forum.dynare.org/uploads/default/original/2X/c/c036d40f865fb15bc04332abc142ba8081ce1584.mod) (367 Bytes)

---

<div class="post-metadata">

**Author:** ![jpfeifer](https://forum.dynare.org/user_avatar/forum.dynare.org/jpfeifer/32/5044_2.png) [@jpfeifer](https://forum.dynare.org/u/jpfeifer)\
**Post date:** [22 November 2018 08:58 UTC](https://forum.dynare.org/t/error-the-steady-state-contains-nan-or-inf/12839/2 "2018-11-22T08:58:19Z")

</div>

You did not provide an initval for `c`, so 0 is taken, which is infeasible. You also did not set/define `tau_c` and `tau_k`.

---

<div class="post-metadata">

**Author:** ![christineqi](https://forum.dynare.org/letter_avatar_proxy/v4/letter/c/eb9ed0/32.png) [@christineqi](https://forum.dynare.org/u/christineqi)\
**Post date:** [22 November 2018 12:32 UTC](https://forum.dynare.org/t/error-the-steady-state-contains-nan-or-inf/12839/3 "2018-11-22T12:32:05Z")

</div>

thank you very much! It worked. But I got the another error: Blanchard Kahn conditions are not satisfied: indeterminacy. I’m not sure if it is related to the time. And, how can I simulate the model for 100 periods and plot the results.  
Thank you very much!

---

<div class="post-metadata">

**Author:** ![sebastien](https://forum.dynare.org/user_avatar/forum.dynare.org/sebastien/32/19973_2.png) [@sebastien](https://forum.dynare.org/u/sebastien)\
**Post date:** [22 November 2018 17:16 UTC](https://forum.dynare.org/t/error-the-steady-state-contains-nan-or-inf/12839/4 "2018-11-22T17:16:42Z")

</div>

The Blanchard-Kahn condition is not satisfied because you use the wrong timing convention for the capital stock. Since the capital stock used to produce today is actually decided yesterday, `k(-1)` should enter the production function. You should similarly adapt the other side of the resource constraint, by shifting time indices.

Alternatively, you can keep your existing timing convention, but add `predetermined_variables k;` at the beginning of your mod-file.

For the simulation, if you want the IRFs corresponding to the different shocks, you must declare their variance/standard deviation (using the `shocks` block), and give the `irf=100` option to `stoch_simul`. If you want a more elaborate scenario, combining different shocks, you’ll have to use the `simult_` function (search the forum).

---

<div class="post-metadata">

**Author:** ![christineqi](https://forum.dynare.org/letter_avatar_proxy/v4/letter/c/eb9ed0/32.png) [@christineqi](https://forum.dynare.org/u/christineqi)\
**Post date:** [22 November 2018 17:30 UTC](https://forum.dynare.org/t/error-the-steady-state-contains-nan-or-inf/12839/5 "2018-11-22T17:30:29Z")

</div>

thank you so much! it worked finally!! And how how can I define a time into my code like at t=0 and t=10? thank you again

---

<div class="post-metadata">

**Author:** ![sebastien](https://forum.dynare.org/user_avatar/forum.dynare.org/sebastien/32/19973_2.png) [@sebastien](https://forum.dynare.org/u/sebastien)\
**Post date:** [22 November 2018 17:33 UTC](https://forum.dynare.org/t/error-the-steady-state-contains-nan-or-inf/12839/6 "2018-11-22T17:33:26Z")

</div>

I don’t understand your last question, please be more explicit about what you are trying to achieve.

---

<div class="post-metadata">

**Author:** ![christineqi](https://forum.dynare.org/letter_avatar_proxy/v4/letter/c/eb9ed0/32.png) [@christineqi](https://forum.dynare.org/u/christineqi)\
**Post date:** [22 November 2018 17:35 UTC](https://forum.dynare.org/t/error-the-steady-state-contains-nan-or-inf/12839/7 "2018-11-22T17:35:10Z")

</div>

I got a question that once-and-for-all increase in g at t=10 from 0.2 to 0.4. I don’t know if I should solve like to set a loop in my code.

---

<div class="post-metadata">

**Author:** ![sebastien](https://forum.dynare.org/user_avatar/forum.dynare.org/sebastien/32/19973_2.png) [@sebastien](https://forum.dynare.org/u/sebastien)\
**Post date:** [22 November 2018 17:55 UTC](https://forum.dynare.org/t/error-the-steady-state-contains-nan-or-inf/12839/8 "2018-11-22T17:55:00Z")

</div>

This type of exercise cannot be satisfactorily performed using the so-called stochastic simulations. Those assume that you are solving the model in the vicinity of the (initial) steady state and that shocks are transitory. Moreover, in such a setup, Dynare assumes a steady state of zero for exogenous variables (so your `g=0.2` is not actually honored).

If you are ready to abandon rational anticipations and to embrace perfect foresight, you can simulate a permanent shock using the `perfect_foresight_solver` command of Dynare. See [my slides on deterministic models](https://git.dynare.org/sebastien/perfect-foresight-slides/blob/master/deterministic.pdf) for more details.

---

<div class="post-metadata">

**Author:** ![christineqi](https://forum.dynare.org/letter_avatar_proxy/v4/letter/c/eb9ed0/32.png) [@christineqi](https://forum.dynare.org/u/christineqi)\
**Post date:** [22 November 2018 18:23 UTC](https://forum.dynare.org/t/error-the-steady-state-contains-nan-or-inf/12839/9 "2018-11-22T18:23:05Z")

</div>

it worked again. The information is really useful. And I still want to know how can I plot the equilibrium path and the steady state into one graph.  
Thank you very much.

---

<div class="post-metadata">

**Author:** ![jpfeifer](https://forum.dynare.org/user_avatar/forum.dynare.org/jpfeifer/32/5044_2.png) [@jpfeifer](https://forum.dynare.org/u/jpfeifer)\
**Post date:** [22 November 2018 19:20 UTC](https://forum.dynare.org/t/error-the-steady-state-contains-nan-or-inf/12839/10 "2018-11-22T19:20:04Z")

</div>

You can either use the `rplot`-command or use Matlab’s plotting tools to visualize the contents of `oo_.endo_simul`.

---

<div class="post-metadata">

**Author:** ![christineqi](https://forum.dynare.org/letter_avatar_proxy/v4/letter/c/eb9ed0/32.png) [@christineqi](https://forum.dynare.org/u/christineqi)\
**Post date:** [23 November 2018 06:17 UTC](https://forum.dynare.org/t/error-the-steady-state-contains-nan-or-inf/12839/11 "2018-11-23T06:17:12Z")

</div>

thank you very much! And I also wrote anther one that does’t work well. It seems that there no steady state, I don’t know how to solve it . Thank you again.[twocou.mod](https://forum.dynare.org/uploads/default/original/2X/9/9c5e54e7a98986c712fdc0146951807c2e97dae9.mod) (914 Bytes)
