# Stochastic simulations with OccBin

Hello, I need to perform some volatility analysis between different models for my thesis.
I understood that I can do this using the stoch_simul command, with the periods option specified. The simulated series will then be found in the oo_.endo_simul matrix.
However, some of the models I am analyzing have occasionally binding constraints (a zero lower bound on deposits’ interest rates) and I don’t understand how to retrieve from those models what is usually found in the oo_.endo_simul matrix. Since IRFs are computed and displayed for both models (constrained and unconstrained), I think that performing a stochastic simulation should be possible too. What I need are the simulated time series for both models, the constrained and unconstrained one.
Anyone has a hint on how I could solve this problem?

Thank you

1 Like

Have a look at the manual under point 4.14.

The output from the occbin_solver; is stored in
oo_.occbin.linear and oo_.occbin.piecewise.

Hello Max1,

Unfortunately, there’s are no such outputs defined as oo_.occbin.linear and oo_.occbin.piecewise. The oo_.endo_simul matrix is empty and the oobase_.endo_simul matrix stores the simulated time series only for the baseline model without the OBC. In zdatalinear and zdatapiecewise are stored the time series generated from the IRFs, with only one shock hitting the economy in the first period.

If you use the OccBin Toolkit from the G&I (2015) paper then you can feed in the matrix of all unexpected shocks. The Output zdatalinear and zdatapiecewise will contain the simulated series conditional on the unexpected shock matrix shockssequence,

If you use the most recent version of the Dynare 4.7-Beta, you can use the OccBin Toolkit which is implemented in Dynare.
All you need to do is outlined in the manual under point 4.14.
Basically, you have to

1. tag your equations belonging to different regimes,
2. define your constraints with a occbin_constraints-block,
3. define your matrix of shocks using a shocks(surprise)-block,
4. specify all your settings with occbin_setup;
5. and finally run your OccBin simulation with occbin_solver;

Examples are at tests/occbin · master · Dynare / dynare · GitLab

1 Like

I am currently using the OccBin Toolkit. So, if I understood correctly, I have to fill the shockssequence matrix with a shock sequence of my choice. Correct?
If yes, this shock sequence should be the one I obtain in oo_.exo_simul after running stoch_simul?

Yes, you can enter a shocksequence of your choice. For instance, set shockssequence = oo_.exo_simul and irfshock = M_.exo_names to obtain the OccBin counterpart of stoch_simul(periods =xy,...);

Hi @Max1. I have a sort of related question. I am using Dynare 4.7 beta and running a model following the manual.

If the constraints are not binding, then the simulations are supposed to be the same as the usual stoch_simul? I am asking this because a simple technology shock in shocks(surpirse) in my model one time at period 1 gives no change from the occbin_setup, occbin_solver, and occbin_graph. But the same shock has a usual impulse response if I use stoch_simul.

Is this because in my model technology shock is not directly related to the potentially binding constraint?

Thanks very much Max1, now it works

I will post the steps I followed here in case someone needs them in the future

• Run the stochastic simulation (using stoch_simul with the periods option specified) of the baseline model without the ZLB;

• Save two objects that contain M_.exo_names and oo_.exo_simul;

• Run the model with the ZLB;

• Run the .m file that calls the Occbin toolkit;

• Retrieve the simulated time series in zdatalienar and zdatapiecewise.

Can you provide the mod-file?
I would expect that you should obtain the same results in oo_.occbin.linear with occbin_solver; as in oo_.irfs or oo_.endo_simul with stoch_simul; if you have the same shock.

Thanks for the reference! One quick typo I just found in the latex notation in borrowing constraint example is

    b_hat ${\hat c}$


Thank you for clarification! I will try to make sure if that is the case in my model. Maybe the why how I formulate the constraint is not right. I guess I have to look at the examples. I will come back if things don’t work and need help. Thanks again!

Hello Max1, I have a question regarding the series that result from this procedure.

I noticed that the simulated series from stoch_simul are moving around the steady state, while the ones obtained from the OccBin toolkit following the procedure I reported are moving around 0. The two series are identical, but one is shifted with respect to the other. Is this because OccBin linearizes the model and, therefore, the steady state of variables is set to be 0?

If you use stoch_simul(order=1) the model is linearized around the steady state in both cases.
The only different between zdatalinear from the OccBin Toolkit and oo_.endo_simul from stoch_simul(order=1,periods=xy,...) is that zdatalinear will store the simulated variables in deviation from steady state and oo_.endo_simul will store the simulated variables without subtracting the steady state.
Thanks Max1, I have tried to verify the consistency of my results by subtracting the steady states from the simulated series stored in oo_.endo_simul and plotting them on the same graph with the simulated series stored in zdatalinear, obviously for the same model. They coincide perfectly, thank for the clarification!