I am receiving a persistent error when estimating a medium-scale DSGE model using Occbin. I am asked to increase check_ahead_periods despite already having set this to a comically high number (20000 quarters). I suspect from previous forum posts that this error is linked to the fact I need “periodic_solution” set as well.

Here is the Occbin setup and estimation call:

model;
// interest and QE rules
[name='interest', bind='ELB']
iSR = 0.001247663;
[name='interest', relax='ELB']
iSR = iT - 1e-06*vr_s1*Ups;
end;
occbin_constraints;
name 'ELB'; bind iT - 1e-06*vr_s1*Ups < 0.001247663; relax iT - 1e-06*vr_s1*Ups > 0.001247663;
end;
occbin_setup(likelihood_max_kalman_iterations = 100, likelihood_check_ahead_periods = 20000, smoother_maxit = 100, smoother_periods = 20000, likelihood_periodic_solution, smoother_periodic_solution);
estimation(datafile=data_Hamilton, mode_compute = 6, mh_nblocks = 2, mh_replic = 20000, mode_check, smoother_redux) y iSR;

iSR is the actual interest rate, iT - 1e-06vr_s1Ups is the shadow rate.

Is there any obvious reason why this might be wrong? I haven’t attached my modfile/code as it is split across seven or eight seperate files, but I can do so if necessary. My model does not have any unit roots (as confirmed by eigenvalues and the check command), but does exhibit very high shock persistence (one important shock decays by about 0.9% per period). It is also worth noting that in my observational data, the interest rate is stuck at the ELB for about 50 quarters (reflecting the UK 2008-2019), which I guess is an unusually long time for Occbin to stay in the alternative regime.

@rattoma Do you have an idea? In any case, we would need to see the files. You can try to use the savemacro=filename-command line option to create one mod-file containing all the code pieces.

One further question - I see from pausing the estimation that Dynare is using the “missing_observations_kalman_filter” despite the fact that my data is complete and not missing any observations. Is this the intended behaviour?

With regards to the error handling, there is an additional issue on line 357 of kalman_update_algo_1.m. The subfunction occbin_kalman_update0 evaluates rank(F)<size(F,1), which sometimes fails with NaN and causes a hard error. On my local copy of Dynare, I have added a try/catch circuit exactly as in model_diagnostics.m lines 155-159 which appears (so far) to resolve the issue.

Thank you for the revised file. Unfortunately, there are still a couple of hard errors which get thrown:

“Make shocks the right size for the output” (setting etahat) needs to be done before all the returns, not only that first try/catch loop. The reason is that etahat naturally has two columns, and is reduced using etahat = etahat(:,2) at the very end of the function. This reduction is not done if the function returns early.

I also sometimes get an error “Error using missing_observations_kalman_filter. Assignment between unlike types is not allowed.”. This seems to be a consequence the way that regimes_ is initialised as [] at the beginning of the function. I have replaced the line regimes=[]; with regimes=[regimes0 regimes0(end)], which seems to have fixed the issue.

Dear Mr. Jpfeifer. Thank you very much.The second problem you pointed out also helped my model run successfully. What I want to ask is, is “bind iT - 1e-06vr_s1Ups <= 0.001247663-1e8” written by mistake? is it “bind iT - 1e-06vr_s1Ups <= 0.001247663-1e-8” that is correct?