OCCBIN in newer Dynare versions

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 (86.6 KB) my work.mod (6.3 KB) Replication code from Iacoviello’s website.zip (6.1 KB)

I appreciate any help that you can provide.

When I run your code in Dynare 4.5.7, I get


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

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.

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!

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

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 (1.5 MB) error.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.

Please try the modified Occbin toolkit files
toolkit_files_4.5.zip (20.1 KB)

Thank you so much, Johannes. It works now!

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. and the code attached:

runsim_cgg.m (2.4 KB) cgg.mod (767 Bytes) cgg_zlb.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)

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!

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

1 Like

Hi professor Pfeifer.

I’m using the toolkit above(and the latest one in Occbin_update)

However, when I run runsim_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 , 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?

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,
Error in steady_ (line 55)
[steady_state,params,info] =
Error in steady (line 80)
[oo_.steady_state,M_.params,info] = steady_(M_,options_,oo_);
Error in dnk.driver (line 319)
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)
indent preformatted text by 4 spaces

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

See https://github.com/JohannesPfeifer/Occbin_update/tree/master/model_dnk for the way it’s supposed to be

1 Like

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!

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,” 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)
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 ,8.

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.

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 (204.3 KB)

1 Like

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.


  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.

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!

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 .

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,

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