# OCCBIN in newer Dynare versions

**URL:** <https://forum.dynare.org/t/occbin-in-newer-dynare-versions/15172>\
**Category:** Dynare contributions and examples\
**Created:** [12 February 2020 08:25 UTC](https://forum.dynare.org/t/occbin-in-newer-dynare-versions/15172 "2020-02-12T08:25:02Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![mxw](https://forum.dynare.org/letter_avatar_proxy/v4/letter/m/e8c25b/32.png) [@mxw](https://forum.dynare.org/u/mxw)\
**Post date:** [12 February 2020 08:25 UTC](https://forum.dynare.org/t/occbin-in-newer-dynare-versions/15172/1 "2020-02-12T08:25:03Z")

</div>

Hi all,

I am working on Iacoviello (2017), “Collateral Constraints and Macroeconomic Asymmetries,” and try to add a search and matching mechanism on to the impatient households (which also act as entrepreneurs/managers in Iacoviello’s model). The search and matching mechanism I adopted is a very simple one (pls see the attached), so I add 5 new endogenous variables and treat the wage of impatient households (variable w1) as a parameter. The first six equations in the model module in my Dynare core is what I added on. Due to the nonlinear equations, I could not compute the analytical steady state manually, so I turn to the initval value strategy. But the Dynare core ends up with ‘Impossible to find the steady state. Either the model doesn’t have a unique steady state of the guess values are too far from the solution’. I have tried different timing for predetermined variables and different starting values for steady states but still couldn’t solve it. I know the reason behind might be complicated. Most starting values stay the same with those in Iacoviello (2017), as I think I do not change too much. Does someone have an idea how to overcome this problem?[matchingmodelp.pdf](https://forum.dynare.org/uploads/short-url/9rEAgVgRoXgKaRv94lpn3qDow7G.pdf) (86.6 KB) [my work.mod](https://forum.dynare.org/uploads/short-url/lBxd8M4kqM2t7lnMDPG36rMR56F.mod) (6.3 KB) [Replication code from Iacoviello’s website.zip](https://forum.dynare.org/uploads/short-url/b70y6mP6YZOMw0Fl7eSZBGmAfHP.zip) (6.1 KB)

I appreciate any help that you can provide.

---

<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:** [14 February 2020 08:09 UTC](https://forum.dynare.org/t/occbin-in-newer-dynare-versions/15172/2 "2020-02-14T08:09:10Z")

</div>

When I run your code in Dynare 4.5.7, I get

> STEADY-STATE RESULTS:
> 
> u 0.821066  
> lmft 0.00653788  
> v 0.000165155  
> g 0.0215365  
> p 0.000754318  
> aj 1  
> ak 1  
> ap 1  
> arr 1  
> az 1  
> b 1.71697  
> bnot 1.71697  
> c 0.463378  
> c1 0.257497  
> data\_ctot -0.000160347  
> data\_dp 4.44089e-16  
> data\_ik 0  
> data\_ntot 0  
> data\_q 0  
> data\_r 6.66134e-16  
> data\_rnot 6.66134e-16  
> dp 1.005  
> dp1 1.005  
> dp2 1.005  
> dp3 1.005  
> h1 0.3423  
> ik 0.189534  
> k 7.58136  
> lm 0.00895216  
> maxlev 0  
> n 0.75606  
> n1 0.178934  
> q 5.63635  
> qk 1  
> r 1.01005  
> rk 0.0300251  
> rnot 1.01005  
> uc 2.15806  
> uc1 3.88353  
> uh 0.060818  
> uh1 0.116856  
> w 0.350342  
> xp 1.2  
> y 0.910526  
> z\_j 0
> 
> EIGENVALUES:  
> Modulus Real Imaginary
> 
> ```
> 0 0 0
> 0 -0 0
> 0 -0 0
> 7.304e-14 7.304e-14 0
> 0.04494 -0.04494 0
> 0.05439 0.05439 0
> 0.2759 0.2759 0
> 0.5862 0.5824 0.06637
> 0.5862 0.5824 -0.06637
> 0.6232 0.6232 0
> 0.6782 -0.6782 0
> 0.6839 0.6839 0
> 0.7556 0.7556 0
> 0.7859 0.7859 0
> 0.8875 0.8875 0
> 0.905 0.9022 0.07078
> 0.905 0.9022 -0.07078
> 0.946 0.946 0
> 0.9835 0.9835 0
> 1.005 1.005 0
> 1.024 1.024 0
> 1.088 1.088 0
> 1.101 1.098 0.08382
> 1.101 1.098 -0.08382
> 1.106 1.098 0.1369
> 1.106 1.098 -0.1369
> 1.429 1.429 0
> 1.472 1.472 0
> 3.65e+15 3.65e+15 0
> Inf Inf 0
> Inf Inf 0
> Inf Inf 0
> Inf Inf 0
> Inf Inf 0
> 
> ```
> 
> There are 15 eigenvalue(s) larger than 1 in modulus  
> for 16 forward-looking variable(s)
> 
> The rank condition ISN’T verified!
> 
> Error using print\_info (line 45)  
> Blanchard Kahn conditions are not satisfied: indeterminacy

So a steady state is found, but the timing is most probably wrong.

---

<div class="post-metadata">

**Author:** ![mxw](https://forum.dynare.org/letter_avatar_proxy/v4/letter/m/e8c25b/32.png) [@mxw](https://forum.dynare.org/u/mxw)\
**Post date:** [14 February 2020 17:40 UTC](https://forum.dynare.org/t/occbin-in-newer-dynare-versions/15172/3 "2020-02-14T17:40:57Z")

</div>

Dear Johannes,

Thank you so much for your response. I’ve fixed the timing problem, now the mod file can be run under Dynare 4.5.6 and 4.5.7 versions, but not under 4.3.1. As I want to apply the Iacoviello’s occbin toolkit, a new problem arisen is the toolkit for two constraints does not work under Dynare 4.5.6. I have tried Iacoviello’s original codes, they are also incompatible with Dynare 4.5.6, but the difference is his single mod file can be run under 4.3.1, so the whole occbin can be run under 4.3.1. Under 4.5.6, the error is ‘Reference to non-existent field ‘nstatic’. The error is located in one toolkit file ‘get\_pq’, there is dr\_.nstatic. Do you have an idea how to solve it?

Many thanks for your help!

---

<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:** [15 February 2020 08:12 UTC](https://forum.dynare.org/t/occbin-in-newer-dynare-versions/15172/4 "2020-02-15T08:12:41Z")

</div>

In such cases, please provide the full error message and the code where it occurs. From what I can see, the problem comes from Dynare moving the model information like the number of static variables from the decision rule structure `oo_.dr.` to the model structure `M_`. So you need to replace this occurrence with `M_.nstatic`

---

<div class="post-metadata">

**Author:** ![mxw](https://forum.dynare.org/letter_avatar_proxy/v4/letter/m/e8c25b/32.png) [@mxw](https://forum.dynare.org/u/mxw)\
**Post date:** [16 February 2020 21:49 UTC](https://forum.dynare.org/t/occbin-in-newer-dynare-versions/15172/5 "2020-02-16T21:49:34Z")

</div>

Dear Johannes,

Many thanks for your advice. I have tried the M\_.nstatic, but it still does not work. I paste the error message and code in the attachment ‘error’. Another attachment is the full set code I tried, I first run the ‘setpathdynare4.m’ to set path (linked to 4.5.6 or 4.3.1), and then run the m file ‘runsim\_plot\_figure3 ’. Then the error occurs. [replication\_figure3\_4 - w1 - initval2.zip](https://forum.dynare.org/uploads/short-url/2h3JlcPmSPBsGB99XeoPVwSTaBQ.zip) (1.5 MB) [error.zip](https://forum.dynare.org/uploads/short-url/pAzz0IV7iqpooXew7Ohykvvji1m.zip) (57.8 KB)

The four mod files, baby00, baby01, baby10, baby11, are for the setup of two constraints, relaxing or binding. The single mod file, baby00 can be run under 4.5.6.

I really appreciate all your help.

---

<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:** [17 February 2020 14:27 UTC](https://forum.dynare.org/t/occbin-in-newer-dynare-versions/15172/6 "2020-02-17T14:27:36Z")

</div>

Please try the modified Occbin toolkit files  
[toolkit\_files\_4.5.zip](https://forum.dynare.org/uploads/short-url/5rZoZPx7Nt8QjsiYTrDxeylEvMy.zip) (20.1 KB)

---

<div class="post-metadata">

**Author:** ![mxw](https://forum.dynare.org/letter_avatar_proxy/v4/letter/m/e8c25b/32.png) [@mxw](https://forum.dynare.org/u/mxw)\
**Post date:** [17 February 2020 17:49 UTC](https://forum.dynare.org/t/occbin-in-newer-dynare-versions/15172/7 "2020-02-17T17:49:44Z")

</div>

Thank you so much, Johannes. It works now!

---

<div class="post-metadata">

**Author:** ![Rahul](https://forum.dynare.org/letter_avatar_proxy/v4/letter/r/f14d63/32.png) [@Rahul](https://forum.dynare.org/u/Rahul)\
**Post date:** [26 August 2020 02:15 UTC](https://forum.dynare.org/t/occbin-in-newer-dynare-versions/15172/8 "2020-08-26T02:15:48Z")

</div>

Hi professor Pfeifer:

Hope this message finds you well. I am using the modified Occbin toolkit under dynare 4.6.1, running a simple three equation NK model. And the code is downloaded from [https://github.com/lucaguerrieri/occbin](https://github.com/lucaguerrieri/occbin). and the code attached:

[runsim\_cgg.m](https://forum.dynare.org/uploads/short-url/1eHAX6hry85RKPemmV2Xt7vb76u.m) (2.4 KB) [cgg.mod](https://forum.dynare.org/uploads/short-url/5xxn4aoB6wBGhhIKyvotrhFfXOv.mod) (767 Bytes) [cgg\_zlb.mod](https://forum.dynare.org/uploads/short-url/rEWVqKsK0SeG9CQU6DfQzucdYRC.mod) (517 Bytes)

However, when i run it it reports:

Error using eval  
Must be a string scalar or character vector.

Error in solve\_one\_constraint (line 44)  
eval([Mbase\_.param\_names(i\_indx\_,:),’= M\_.params(i\_indx\_);’]);

Error in runsim\_cgg (line 45)  
solve\_one\_constraint(modnam,modnamstar,…

Error in run (line 91)  
evalin(‘caller’, strcat(script, ‘;’));

I guess it’s still because of the occbin is not adaptable to new version dynare. May i know where i can get the new modified version occbin or how to modify it?

Thanks a lot!

---

<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 September 2020 08:50 UTC](https://forum.dynare.org/t/occbin-in-newer-dynare-versions/15172/9 "2020-09-02T08:50:37Z")

</div>

I have created a GIT repository for maintaining inofficial updated versions at

> **[JohannesPfeifer/Occbin\_update](https://github.com/JohannesPfeifer/Occbin_update)**
>
> Contribute to JohannesPfeifer/Occbin\_update development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![Haa](https://forum.dynare.org/letter_avatar_proxy/v4/letter/h/ea5d25/32.png) [@Haa](https://forum.dynare.org/u/Haa)\
**Post date:** [1 December 2020 02:46 UTC](https://forum.dynare.org/t/occbin-in-newer-dynare-versions/15172/10 "2020-12-01T02:46:27Z")

</div>

Hi professor Pfeifer.

I’m using the toolkit above(and the latest one in Occbin\_update)

However, when I run [runsim\_dnk](https://github.com/lucaguerrieri/occbin/tree/3cdb4b98dec77e0a0d288e018e2f667a69c86609/occbin_20130531/model_dnk) in dynare 4.6.1, I got the error message related to the number of inputs (for steady state?). I guess this is similar to the problem of [this one](https://forum.dynare.org/t/code-not-working-after-updating-dynare-to-4-6-0/15254) , but your modified toolbox code in github seems to be up-to-date, and I checked the path is set for modified toolbox rightly.

How can I run [this NK model](https://github.com/lucaguerrieri/occbin/tree/3cdb4b98dec77e0a0d288e018e2f667a69c86609/occbin_20130531/model_dnk)?

> Error using dnk\_steadystate  
> Too many input arguments.  
> Error in evaluate\_steady\_state\_file (line 49)  
> [ys,params1,check] = h\_steadystate(ys\_init, exo\_ss,M,options);  
> Error in evaluate\_steady\_state (line 210)  
> [ys,params,info] = evaluate\_steady\_state\_file(ys\_init,exo\_ss,M,  
> options,steadystate\_check\_flag);  
> Error in steady\_ (line 55)  
> [steady\_state,params,info] =  
> evaluate\_steady\_state(oo\_.steady\_state,M\_,options\_,oo\_,~options\_.steadystate.nocheck);  
> Error in steady (line 80)  
> [oo\_.steady\_state,M\_.params,info] = steady\_(M\_,options\_,oo\_);  
> Error in dnk.driver (line 319)  
> steady;  
> Error in dynare (line 293)  
> evalin(‘base’,[fname ‘.driver’]) ;  
> Error in solve\_one\_constraint (line 37)  
> eval(['dynare ‘,modnam\_,’ noclearall nolog '])  
> Error in runsim\_dnk (line 41)  
> solve\_one\_constraint(modnam,modnamstar,…  
> indent preformatted text by 4 spaces

---

<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:** [1 December 2020 14:02 UTC](https://forum.dynare.org/t/occbin-in-newer-dynare-versions/15172/11 "2020-12-01T14:02:28Z")

</div>

@Haa Why are you interested in those files? They violate all Dynare best-practices.

---

<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:** [1 December 2020 14:32 UTC](https://forum.dynare.org/t/occbin-in-newer-dynare-versions/15172/12 "2020-12-01T14:32:38Z")

</div>

See [https://github.com/JohannesPfeifer/Occbin\_update/tree/master/model\_dnk](https://github.com/JohannesPfeifer/Occbin_update/tree/master/model_dnk) for the way it’s supposed to be

---

<div class="post-metadata">

**Author:** ![Haa](https://forum.dynare.org/letter_avatar_proxy/v4/letter/h/ea5d25/32.png) [@Haa](https://forum.dynare.org/u/Haa)\
**Post date:** [2 December 2020 07:12 UTC](https://forum.dynare.org/t/occbin-in-newer-dynare-versions/15172/13 "2020-12-02T07:12:47Z")

</div>

Thank you very much!!  
I wanted to check how Occbin really works using some examples.

I managed to run your code! I will be able to simulate other models. Thank you!

---

<div class="post-metadata">

**Author:** ![Haa](https://forum.dynare.org/letter_avatar_proxy/v4/letter/h/ea5d25/32.png) [@Haa](https://forum.dynare.org/u/Haa)\
**Post date:** [11 December 2020 13:11 UTC](https://forum.dynare.org/t/occbin-in-newer-dynare-versions/15172/14 "2020-12-11T13:11:38Z")

</div>

Hi professor Pfeifer.

I’m using your modified Occbin toolkit and trying to replicate Guerrieri, Luca, and Matteo Iacoviello (2017), “[Collateral Constraints and Macroeconomic Asymmetries](https://www.matteoiacoviello.com/research_files/ASYMMETRIES_PAPER.pdf),” _Journal of Monetary Economics_ , vol. 90, October, pp.28-49.

However, It seems that solve\_two\_constraint in the modified toolkit is not working well.  
I tried the modifications below.

・deleting “deblank” in solve\_two\_constraint so that eval can work well (following the way of solve\_one\_constraint)  
・deleting external steady state file because the the way of external steady state file is changed but the source code in Guerrieri is not changed.

However, when I run the runsim\_estimation.m , I got the error message below.

> Reference to non-existent field ‘ghx’.  
> Error in get\_pq (line 3)  
> nvars = size(dr\_.ghx,1);  
> Error in solve\_two\_constraints (line 141)  
> [decrulea,decruleb]=get\_pq(oo00\_.dr,M00\_);  
> Error in runsim\_plot\_figure3 (line 79)  
> [zdatal zdatap zdatass oobase\_ Mbase\_] = solve\_two\_constraints(…

How can I fix this error code? I know what dr\_ghx is, but I couldn’t understand why the field is empty.

The source code is [here](https://www.matteoiacoviello.com/research.htm) ,8.

---

<div class="post-metadata">

**Author:** ![Max1](https://forum.dynare.org/letter_avatar_proxy/v4/letter/m/e99b99/32.png) [@Max1](https://forum.dynare.org/u/Max1)\
**Post date:** [11 December 2020 19:15 UTC](https://forum.dynare.org/t/occbin-in-newer-dynare-versions/15172/15 "2020-12-11T19:15:57Z")

</div>

Unfortunately, the replication files are of very poor quality.  
I spend a lot of time with the code and there are multiple reasons why it can crash.  
There is also an issue with changes made in Dynare itself.

Due to changes in the preprocessor you have to tag the equation `lm=0` within the regimes 10 and 11.  
Otherwise, the function `get_deriv` will not behave as expected.  
According to @jpfeifer tagging this static equation is the only workaround.

> [@Haa](#):
>
> Error in runsim\_plot\_figure3 (line 79)

A will attach a replication for figure 3 in Guerrieri and Iacoviello (2017) that runs on the updated toolkit and dynare 4.6.3.

[replication\_figure\_3.zip](https://forum.dynare.org/uploads/short-url/h6RYO6kTmvYrHmo4MZi0JTERzfr.zip) (204.3 KB)

---

<div class="post-metadata">

**Author:** ![Haa](https://forum.dynare.org/letter_avatar_proxy/v4/letter/h/ea5d25/32.png) [@Haa](https://forum.dynare.org/u/Haa)\
**Post date:** [12 December 2020 01:23 UTC](https://forum.dynare.org/t/occbin-in-newer-dynare-versions/15172/16 "2020-12-12T01:23:00Z")

</div>

Thank you very much!! Your comment was very helpful and I managed to replicate Figures on matlab 4.6.3!  
If you have modified other files (estimation, filtering, replication\_figure\_2\_basic, replication\_figure\_4), I’m sorry if this sounds rude but could you show me your code?  
I tried to run other files by modifying toolkits and runsimfile, but it doesn’t seem to work completely well. (I managed to replication\_figure\_2 to some degree, but other file didn’t work.)

I would appreciate your help.

---

<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:** [12 December 2020 09:04 UTC](https://forum.dynare.org/t/occbin-in-newer-dynare-versions/15172/17 "2020-12-12T09:04:10Z")

</div>

@Haa

1. The deblank issue in my repository was fixed two days ago
2. Deleting steady state file is not a good idea as the files may now fail to solve for the steady state. In that case, the decision rule structure will be empty, resulting in crashes like the one you mentioned. As @Max1 indicated, the replication files do not contain a proper error handling to deal with such issues. I have pushed a proper version of those file with a `steady_state_model-`-block to my repository.
3. The tagging issue is indeed a problem in Dynare 4.6.3. When running plain Occbin from my repository, you will get an error message in my codes when calling `solve_two_constraints.m`. The problem is that the estimation routines never call that file, but rather a different one.

---

<div class="post-metadata">

**Author:** ![Max1](https://forum.dynare.org/letter_avatar_proxy/v4/letter/m/e99b99/32.png) [@Max1](https://forum.dynare.org/u/Max1)\
**Post date:** [12 December 2020 13:55 UTC](https://forum.dynare.org/t/occbin-in-newer-dynare-versions/15172/18 "2020-12-12T13:55:40Z")

</div>

> [@jpfeifer](#):
>
> I have pushed a proper version of those file with a `steady_state_model-`-block to my repository.

Using the Macro processing language is a very nice way to handle the mod-files when using the OccBin toolkit! No longer copy and paste everything from one mod-file to the other. Therefore, reducing the point of failure. Nice!

---

<div class="post-metadata">

**Author:** ![yoy85](https://forum.dynare.org/letter_avatar_proxy/v4/letter/y/eada6e/32.png) [@yoy85](https://forum.dynare.org/u/yoy85)\
**Post date:** [18 April 2021 23:56 UTC](https://forum.dynare.org/t/occbin-in-newer-dynare-versions/15172/19 "2021-04-18T23:56:58Z")

</div>

Dear @jpfeifer,

I want to ask a question related to the code for CGG at [Occbin\_update/cgg\_common\_equations.inc at master · JohannesPfeifer/Occbin\_update · GitHub](https://github.com/JohannesPfeifer/Occbin_update/blob/master/cgg_common_equations.inc) .

the first equation is : y = y(+1) - PHI\*(r + p(+1)) + g . I think it seems wrong or I miss something. It should be y = y(+1) - PHI\*(r - p(+1)) + g .

Best Regards,  
Yilmaz

---

<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:** [19 April 2021 09:57 UTC](https://forum.dynare.org/t/occbin-in-newer-dynare-versions/15172/20 "2021-04-19T09:57:25Z")

</div>

Yes, you are right. I fixed the equation and notified the original authors.
