# Error: max\_recursion\_depth exceeded

**URL:** <https://forum.dynare.org/t/error-max-recursion-depth-exceeded/14214>\
**Category:** Steady state\
**Created:** [23 July 2019 12:24 UTC](https://forum.dynare.org/t/error-max-recursion-depth-exceeded/14214 "2019-07-23T12:24:50Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![DJINKPO](https://forum.dynare.org/letter_avatar_proxy/v4/letter/d/4491bb/32.png) [@DJINKPO](https://forum.dynare.org/u/DJINKPO)\
**Post date:** [23 July 2019 12:24 UTC](https://forum.dynare.org/t/error-max-recursion-depth-exceeded/14214/1 "2019-07-23T12:24:50Z")

</div>

Dear Professor,  
This follows my previous message which can be discarded. After making few correction on my steady state file, I got the following error message:  
_error: max\_recursion\_depth exceeded_  
How can i set this issue in my steady state file to make the Ramsey code run?  
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:** [25 July 2019 14:09 UTC](https://forum.dynare.org/t/error-max-recursion-depth-exceeded/14214/2 "2019-07-25T14:09:45Z")

</div>

Where exactly does that problem show up, i.e. what is the full error message?

---

<div class="post-metadata">

**Author:** ![DJINKPO](https://forum.dynare.org/letter_avatar_proxy/v4/letter/d/4491bb/32.png) [@DJINKPO](https://forum.dynare.org/u/DJINKPO)\
**Post date:** [25 July 2019 15:35 UTC](https://forum.dynare.org/t/error-max-recursion-depth-exceeded/14214/3 "2019-07-25T15:35:42Z")

</div>

Thank you,  
In fact, the message in as follows:  
_ **Using 32-bit preprocessor** _  
_**Starting Dynare (version 4.5.7).**_  
_ **Starting preprocessing of the model file …** _  
_ **Ramsey Problem: added 12 Multipliers.** _  
_**Found 12 equation(s).**_  
_**Found 27 FOC equation(s) for Ramsey Problem.**_  
_ **Evaluating expressions…done** _  
_ **Computing static model derivatives:** _  
\*\*\* - order 1\*\*\*  
_ **Computing dynamic model derivatives:** _  
\*\*\* - order 1\*\*\*  
\*\*\* - order 2\*\*\*  
_ **Computing static model derivatives:** _  
\*\*\* - order 1\*\*\*  
\*\*\* - order 2\*\*\*  
\*\*\* - order 3\*\*\*  
_ **Processing outputs …** _  
_ **done** _  
_ **Preprocessing completed.** _  
_ **error: max\_recursion\_depth exceeded** _  
I am runing the code on Octave 4.4.1  
I tried the same code on Matlab but I got a different error message as follows:  
_ **Failure in initial objective function evaluation. FSOLVE cannot continue.** _

---

<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 July 2019 15:42 UTC](https://forum.dynare.org/t/error-max-recursion-depth-exceeded/14214/4 "2019-07-25T15:42:55Z")

</div>

Then this is an Octave issue.

---

<div class="post-metadata">

**Author:** ![DJINKPO](https://forum.dynare.org/letter_avatar_proxy/v4/letter/d/4491bb/32.png) [@DJINKPO](https://forum.dynare.org/u/DJINKPO)\
**Post date:** [25 July 2019 16:26 UTC](https://forum.dynare.org/t/error-max-recursion-depth-exceeded/14214/5 "2019-07-25T16:26:55Z")

</div>

Dear Professor,  
I tried on Matlab and got a different error message as follows/  
Using 64-bit preprocessor  
Starting Dynare (version 4.5.7).  
Starting preprocessing of the model file …  
Ramsey Problem: added 12 Multipliers.  
Found 12 equation(s).  
Found 27 FOC equation(s) for Ramsey Problem.  
Evaluating expressions…done  
Computing static model derivatives:

- order 1  
Computing dynamic model derivatives:
- order 1
- order 2  
Computing static model derivatives:
- order 1
- order 2
- order 3  
Processing outputs …  
done  
Preprocessing completed.

Error: File: Benin\_steadystate.m Line: 6 Column: 15  
Invalid expression. Check for missing multiplication operator, missing or unbalanced delimiters, or other  
syntax error. To construct matrices, use brackets instead of parentheses.

Error in evaluate\_steady\_state\_file (line 52)  
[ys,check] = h\_steadystate(ys\_init, exo\_ss);

Error in evaluate\_steady\_state (line 212)  
[ys,params,info] = evaluate\_steady\_state\_file(ys\_init,exo\_ss,M, options,steadystate\_check\_flag);

Error in resol (line 104)  
[dr.ys,M.params,info] = evaluate\_steady\_state(oo.steady\_state,M,options,oo,~options.steadystate.nocheck);

Error in check (line 73)  
[dr,info,M,options,oo] = resol(1,M,options,oo);  
Error in Benin (line 306)  
oo\_.dr.eigval = check(M\_,options\_,oo\_);  
Error in dynare (line 235)  
evalin(‘base’,fname) ;

I checked my steady state code but unable to pin down the error.

---

<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 July 2019 07:33 UTC](https://forum.dynare.org/t/error-max-recursion-depth-exceeded/14214/6 "2019-07-26T07:33:44Z")

</div>

Always provide the latest files.

---

<div class="post-metadata">

**Author:** ![DJINKPO](https://forum.dynare.org/letter_avatar_proxy/v4/letter/d/4491bb/32.png) [@DJINKPO](https://forum.dynare.org/u/DJINKPO)\
**Post date:** [26 July 2019 08:32 UTC](https://forum.dynare.org/t/error-max-recursion-depth-exceeded/14214/7 "2019-07-26T08:32:37Z")

</div>

Dear Professor,  
These are the latest code I ran to get the error message above.  
Regard  
[Fiscal.mod](https://forum.dynare.org/uploads/short-url/rbUII9vreNotOSYse0ctLl5iYnl.mod) (4.0 KB) [Fiscal\_steadystate.m](https://forum.dynare.org/uploads/short-url/jGewdGyFOFsFK86pupHk7UMDlkk.m) (2.8 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:** [26 July 2019 08:46 UTC](https://forum.dynare.org/t/error-max-recursion-depth-exceeded/14214/8 "2019-07-26T08:46:26Z")

</div>

Please be more careful and think about what you are doing before posting.  
Instead of adding a white space in a single line, you did a search and replace. The model structure is still called `M_`. So

```auto
isfield(M_ lgy_.'param_nbr') == 1

```

should for example be

```auto
isfield(M_.'param_nbr') == 1

```

---

<div class="post-metadata">

**Author:** ![DJINKPO](https://forum.dynare.org/letter_avatar_proxy/v4/letter/d/4491bb/32.png) [@DJINKPO](https://forum.dynare.org/u/DJINKPO)\
**Post date:** [26 July 2019 09:34 UTC](https://forum.dynare.org/t/error-max-recursion-depth-exceeded/14214/9 "2019-07-26T09:34:43Z")

</div>

Dear Professor,  
Thank you for your remark. I fixed the error and reran it but got different outcome.  
Here is the error message:  
Failure in initial objective function evaluation. FSOLVE cannot continue.  
Though i’ve written the objective function properly in the code

---

<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 July 2019 16:03 UTC](https://forum.dynare.org/t/error-max-recursion-depth-exceeded/14214/10 "2019-07-26T16:03:51Z")

</div>

Again, please always provide the latest files.

---

<div class="post-metadata">

**Author:** ![DJINKPO](https://forum.dynare.org/letter_avatar_proxy/v4/letter/d/4491bb/32.png) [@DJINKPO](https://forum.dynare.org/u/DJINKPO)\
**Post date:** [31 July 2019 11:37 UTC](https://forum.dynare.org/t/error-max-recursion-depth-exceeded/14214/12 "2019-07-31T11:37:34Z")

</div>

Dear professor,  
I can’t figure out the mistake I am making in the steady state file which leads to the error message sent out by Matlab as follows,  
**Failure in initial objective function evaluation. FSOLVE cannot continue**  
I wonder whether the treatment of the instruments in the steady state file is wrong. I set them as unknowns but with initial values set to 0 as there is no equation for these instruments relating them to other variables in the system. I tried many options for the solver but still getting the same message.

---

<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:** [31 July 2019 12:47 UTC](https://forum.dynare.org/t/error-max-recursion-depth-exceeded/14214/13 "2019-07-31T12:47:14Z")

</div>

In your steady state file, you are calling

```auto
[x,fval,exitflag] = fsolve(@Benin_steadystate, x0,options); % Solving the nonlinear system

```

where does the function `Benin_steadystate` come from? You did not upload it.

---

<div class="post-metadata">

**Author:** ![DJINKPO](https://forum.dynare.org/letter_avatar_proxy/v4/letter/d/4491bb/32.png) [@DJINKPO](https://forum.dynare.org/u/DJINKPO)\
**Post date:** [1 August 2019 15:22 UTC](https://forum.dynare.org/t/error-max-recursion-depth-exceeded/14214/18 "2019-08-01T15:22:33Z")

</div>

Dear professor,\*\*  
You are right. I did rename the file to keep the previous one. The correct names are as follows\*  
[Fiscal.mod](https://forum.dynare.org/uploads/short-url/rbUII9vreNotOSYse0ctLl5iYnl.mod) (4.0 KB) [Benin\_steadystate.m](https://forum.dynare.org/uploads/short-url/p0EWdTKyGoYuuMp54z6LHdPHao3.m) (3.2 KB)  
I am trying to attach the file with the correct names but it still attaching the file with the name Fiscal instead of Benin. I think my windows system might be facing a challenge

---

<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:** [2 August 2019 10:43 UTC](https://forum.dynare.org/t/error-max-recursion-depth-exceeded/14214/19 "2019-08-02T10:43:00Z")

</div>

I think this is your problem. Within your steady state file, you are supposed to call a second file solving a simplified problem. As is, you are simply calling the same file again, leading to an infinite recursion.

---

<div class="post-metadata">

**Author:** ![DJINKPO](https://forum.dynare.org/letter_avatar_proxy/v4/letter/d/4491bb/32.png) [@DJINKPO](https://forum.dynare.org/u/DJINKPO)\
**Post date:** [2 August 2019 10:49 UTC](https://forum.dynare.org/t/error-max-recursion-depth-exceeded/14214/20 "2019-08-02T10:49:42Z")

</div>

Good morning professor,  
I followed the example file on steady state file you posted “blt\_old\_ramsey\_steadystate.m”  
and replicate the file exactly as it is structured by changing the equations and parameters by those in my model. And then I gave the same .mod file name to the steady state file to make sure I followed your instruction. That is how i set the steady state file.  
But it seems not to be the convenient way. Could explain to me how I should structure the steady state file?  
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:** [4 August 2019 12:40 UTC](https://forum.dynare.org/t/error-max-recursion-depth-exceeded/14214/21 "2019-08-04T12:40:43Z")

</div>

I am sure I did not provide an example with an infinite recursion.

---

<div class="post-metadata">

**Author:** ![DJINKPO](https://forum.dynare.org/letter_avatar_proxy/v4/letter/d/4491bb/32.png) [@DJINKPO](https://forum.dynare.org/u/DJINKPO)\
**Post date:** [4 August 2019 13:20 UTC](https://forum.dynare.org/t/error-max-recursion-depth-exceeded/14214/22 "2019-08-04T13:20:21Z")

</div>

Dear Professor,  
I mas talking about a link you provided in a previous post. The link directed me to an example of steady file posted on the forum which I downloaded and used 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:** [7 August 2019 17:38 UTC](https://forum.dynare.org/t/error-max-recursion-depth-exceeded/14214/23 "2019-08-07T17:38:14Z")

</div>

But the way you did it is not correct. Please refer to the `NK_baseline_steadystate.m` in the Dynare examples folder.
