# Error "Steady state contains NaN or Inf" when using external steady state file

**URL:** https://forum.dynare.org/t/error-steady-state-contains-nan-or-inf-when-using-external-steady-state-file/12381
**Category:** Steady state
**Created:** [8 September 2018 03:00 UTC](https://forum.dynare.org/t/error-steady-state-contains-nan-or-inf-when-using-external-steady-state-file/12381 "2018-09-08T03:00:12Z")
**Posts on this page:** 15
**Page:** 1

<div class="post-metadata">

### Author: ![GraceWang](https://forum.dynare.org/letter_avatar_proxy/v4/letter/g/9dc877/32.png) [@GraceWang](https://forum.dynare.org/u/GraceWang)
#### Post date: [8 September 2018 03:00 UTC](https://forum.dynare.org/t/error-steady-state-contains-nan-or-inf-when-using-external-steady-state-file/12381/1 "2018-09-08T03:00:12Z")

</div>

Dear all,

I am learning Dynare to solve DSGE problems. Now I am trying to use external Matlab file to compute steady state, with the help of the example “NK\_baseline\_steadystate.m”.

I have try my best to linearized the .m file. But the mod file failed to run with error message"Error using print\_info (line 90) The steady state contains NaN or Inf Error in steady (line 104) print\_info(info,options\_.noprint, options\_); Error in DynareStudystochastic (line 147) steady; Error in dynare (line 235) evalin(‘base’,fname) ;".

However, when I try to use the equations to compute steady state by another .m file, it works.

I have no idea what’s wrong with my ‘DynareStudystochastic.m’ file.

Could anyone here help me with that?[DynareStudystochastic\_seadystate.m](https://forum.dynare.org/uploa!%5BDynareStudy_model%7C387x500%5D(upload://aePwTPxzKwUHDFOdfHekVfWut8r.png)%20ds/default/original/2X/e/e1b4ef759ae5aa46ee4f1a741e2e4c8e096d34fc.m) (1.5 KB)  
[DynareStudystochastic.mod](https://forum.dynare.org/uploads/default/original/2X/1/107dab3763f9666482104edb8c1c5b6d054679b4.mod) (841 Bytes)

Thanks in advance!

Grace

---

<div class="post-metadata">

### Author: ![GraceWang](https://forum.dynare.org/letter_avatar_proxy/v4/letter/g/9dc877/32.png) [@GraceWang](https://forum.dynare.org/u/GraceWang)
#### Post date: [8 September 2018 03:01 UTC](https://forum.dynare.org/t/error-steady-state-contains-nan-or-inf-when-using-external-steady-state-file/12381/2 "2018-09-08T03:01:26Z")

</div>

![DynareStudy_model](https://forum.dynare.org/uploads/default/original/2X/4/47c2ed70e87a27072afd2d5a07dae50b8d2bcc8f.png)  
The model I am using is attached. Thanks!

---

<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: [8 September 2018 13:40 UTC](https://forum.dynare.org/t/error-steady-state-contains-nan-or-inf-when-using-external-steady-state-file/12381/3 "2018-09-08T13:40:41Z")

</div>

You have a typo in the naming of the steady state file. If you do not obey the naming convention, Dynare will not be able to detect it.

---

<div class="post-metadata">

### Author: ![GraceWang](https://forum.dynare.org/letter_avatar_proxy/v4/letter/g/9dc877/32.png) [@GraceWang](https://forum.dynare.org/u/GraceWang)
#### Post date: [8 September 2018 14:15 UTC](https://forum.dynare.org/t/error-steady-state-contains-nan-or-inf-when-using-external-steady-state-file/12381/4 "2018-09-08T14:15:07Z")

</div>

Thank you Prof. Pfeifer! 😀

This mistake is stupid. haha

---

<div class="post-metadata">

### Author: ![Chloe](https://forum.dynare.org/letter_avatar_proxy/v4/letter/c/839c29/32.png) [@Chloe](https://forum.dynare.org/u/Chloe)
#### Post date: [25 May 2023 16:17 UTC](https://forum.dynare.org/t/error-steady-state-contains-nan-or-inf-when-using-external-steady-state-file/12381/5 "2023-05-25T16:17:24Z")

</div>

sorry to bother, may I ask how you resolved it?

---

<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: [25 May 2023 17:34 UTC](https://forum.dynare.org/t/error-steady-state-contains-nan-or-inf-when-using-external-steady-state-file/12381/6 "2023-05-25T17:34:18Z")

</div>

`seadystate` must be `steadystate`.

---

<div class="post-metadata">

### Author: ![Chloe](https://forum.dynare.org/letter_avatar_proxy/v4/letter/c/839c29/32.png) [@Chloe](https://forum.dynare.org/u/Chloe)
#### Post date: [26 May 2023 02:42 UTC](https://forum.dynare.org/t/error-steady-state-contains-nan-or-inf-when-using-external-steady-state-file/12381/8 "2023-05-26T02:42:59Z")

</div>

Thank you professor, I really appreciate your reply~ your memory is really good hahaha!  
I would like to further inquire about the result of my code running,

> > dynare trans.mod  
> > Starting Dynare (version 5.2).  
> > Calling Dynare with arguments: none  
> > Starting preprocessing of the model file …  
> > Found 30 equation(s).  
> > Evaluating expressions…done  
> > Computing static model derivatives (order 1).  
> > Computing dynamic model derivatives (order 1).  
> > Processing outputs …  
> > done  
> > Preprocessing completed.

Randomize initial guess…

Residuals of the static equations:

Equation number 1 : NaN : c  
Equation number 2 : NaN : 2  
Equation number 3 : NaN : 3  
Equation number 4 : NaN : k  
Equation number 5 : NaN : zt  
Equation number 6 : NaN : kt  
Equation number 7 : NaN : ft  
Equation number 8 : NaN : labt  
Equation number 9 : NaN : mt  
Equation number 10 : NaN : nt  
Equation number 11 : NaN : wt  
Equation number 12 : NaN : zg  
Equation number 13 : NaN : kg  
Equation number 14 : NaN : fg  
Equation number 15 : NaN : labg  
Equation number 16 : NaN : mg  
Equation number 17 : NaN : ng  
Equation number 18 : NaN : wg  
Equation number 19 : NaN : 19  
Equation number 20 : NaN : pt  
Equation number 21 : NaN : m  
Equation number 22 : NaN : n  
Equation number 23 : NaN : w  
Equation number 24 : NaN : ce  
Equation number 25 : NaN : g  
Equation number 26 : NaN : y  
Equation number 27 : NaN : 27  
Equation number 28 : NaN : 28  
Equation number 29 : NaN : 29  
Equation number 30 : NaN : 30

Error using print\_info (line 32)  
The steady state has NaNs or Inf.  
Error in steady (line 102)  
print\_info(info,options\_.noprint, options\_);  
Error in trans.driver (line 380)  
steady;  
Error in dynare (line 281)  
evalin(‘base’,[fname ‘.driver’]);

——————  
when this happens, what is the likely cause of the problem?

---

<div class="post-metadata">

### Author: ![Chloe](https://forum.dynare.org/letter_avatar_proxy/v4/letter/c/839c29/32.png) [@Chloe](https://forum.dynare.org/u/Chloe)
#### Post date: [26 May 2023 02:58 UTC](https://forum.dynare.org/t/error-steady-state-contains-nan-or-inf-when-using-external-steady-state-file/12381/9 "2023-05-26T02:58:12Z")

</div>

[trans\_0526.mod](https://forum.dynare.org/uploads/short-url/pJL08H4Yc0zZjiuL0vv1mOZbhd6.mod) (2.6 KB)  
this is my code~ thank you in advance!

---

<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: [26 May 2023 13:55 UTC](https://forum.dynare.org/t/error-steady-state-contains-nan-or-inf-when-using-external-steady-state-file/12381/10 "2023-05-26T13:55:03Z")

</div>

For starters, you should initialize all variables.

---

<div class="post-metadata">

### Author: ![Chloe](https://forum.dynare.org/letter_avatar_proxy/v4/letter/c/839c29/32.png) [@Chloe](https://forum.dynare.org/u/Chloe)
#### Post date: [26 May 2023 16:56 UTC](https://forum.dynare.org/t/error-steady-state-contains-nan-or-inf-when-using-external-steady-state-file/12381/11 "2023-05-26T16:56:28Z")

</div>

Thanks for your reply, but I don’t quite understand. I assigned initial values to endogenous variables in the “initval” block. Do I need to assign initial values to all types of variables in the “initval” block?

---

<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: [26 May 2023 16:58 UTC](https://forum.dynare.org/t/error-steady-state-contains-nan-or-inf-when-using-external-steady-state-file/12381/12 "2023-05-26T16:58:11Z")

</div>

You have 30 endogenous variables, but way fewer lines in `initval`.

---

<div class="post-metadata">

### Author: ![Chloe](https://forum.dynare.org/letter_avatar_proxy/v4/letter/c/839c29/32.png) [@Chloe](https://forum.dynare.org/u/Chloe)
#### Post date: [26 May 2023 17:18 UTC](https://forum.dynare.org/t/error-steady-state-contains-nan-or-inf-when-using-external-steady-state-file/12381/13 "2023-05-26T17:18:19Z")

</div>

What I think is that once the values of some endogenous variables are determined, the values of the remaining endogenous variables can be determined using the formula in the “model” block. I don’t know if this understanding is correct ?

---

<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: [26 May 2023 18:13 UTC](https://forum.dynare.org/t/error-steady-state-contains-nan-or-inf-when-using-external-steady-state-file/12381/14 "2023-05-26T18:13:19Z")

</div>

No, Dynare takes initial values as the pure numbers you put in. It does not fill in the gaps from the `model`-block. After all, the model is a simultaneous equation system.

---

<div class="post-metadata">

### Author: ![Chloe](https://forum.dynare.org/letter_avatar_proxy/v4/letter/c/839c29/32.png) [@Chloe](https://forum.dynare.org/u/Chloe)
#### Post date: [27 May 2023 08:00 UTC](https://forum.dynare.org/t/error-steady-state-contains-nan-or-inf-when-using-external-steady-state-file/12381/15 "2023-05-27T08:00:21Z")

</div>

Thank you Professor. Based on the problem you pointed out, I have also assigned values to the remaining endogenous variables according to the equation in the “model” block. However, dynare is currently unable to calculate the steady-state value. Can you help me see where the problem lies?

[trans\_0526.mod](https://forum.dynare.org/uploads/short-url/roOxS9INKZ6uWe0Jkvcp8QItshx.mod) (3.4 KB)

---

<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: [28 May 2023 14:25 UTC](https://forum.dynare.org/t/error-steady-state-contains-nan-or-inf-when-using-external-steady-state-file/12381/16 "2023-05-28T14:25:41Z")

</div>

None of the solvers seems to be able to find the steady state. Are you sure there is a unique steady state that can be computed analytically? Have you tried computing the steady state analytically? Often that is the only way to properly debug the model.
