# ZLB implemention and occbin\_constraints

**URL:** https://forum.dynare.org/t/zlb-implemention-and-occbin-constraints/22173
**Category:** Occbin
**Created:** [28 March 2023 03:12 UTC](https://forum.dynare.org/t/zlb-implemention-and-occbin-constraints/22173 "2023-03-28T03:12:47Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![chuxi](https://forum.dynare.org/letter_avatar_proxy/v4/letter/c/3e96dc/32.png) [@chuxi](https://forum.dynare.org/u/chuxi)
#### Post date: [28 March 2023 03:12 UTC](https://forum.dynare.org/t/zlb-implemention-and-occbin-constraints/22173/1 "2023-03-28T03:12:47Z")

</div>

dear professor,I’m solving a model with ZLB and use occbin\_constraints to implement it.But when I run the model,the shocks seem do not work, so as the ZLB condition.I don’t know why this happenned.Could you please help me to find where the problems are? Thanks and best wishes!  
[test1.mod](https://forum.dynare.org/uploads/short-url/jYX8HaGoMfNooonAeNqxYK5CaLx.mod) (8.3 KB)

 ![test1](https://forum.dynare.org/uploads/default/original/3X/8/7/8723baf25b43c8a302798cb76e97071a385b7930.png)

---

<div class="post-metadata">

### Author: ![chuxi](https://forum.dynare.org/letter_avatar_proxy/v4/letter/c/3e96dc/32.png) [@chuxi](https://forum.dynare.org/u/chuxi)
#### Post date: [28 March 2023 13:54 UTC](https://forum.dynare.org/t/zlb-implemention-and-occbin-constraints/22173/2 "2023-03-28T13:54:47Z")

</div>

I change the shocks as follows:  
shockssequence =[-0.2,-0.2,-0.2];  
shocks(surprise,overwrite);  
var eps\_a;  
periods 1:3;  
values (shockssequence);  
end;

 ![屏幕截图 2023-03-28 214941](https://forum.dynare.org/uploads/default/original/3X/6/9/699790857d9b2f75c69b96797fdb2e9754809931.png)

when I change the shocks,and reach the zero lower bound, the proccess will lead to the error as follow:

> In occbin.mkdatap\_anticipated\_dyn (line 109)  
> In occbin.solve\_one\_constraint (line 189)  
> In occbin.solver (line 78)  
> In test1.driver (line 711)  
> In dynare (line 281)  
> Warning: The matrix is close to singular value, or scaled incorrectly. Results may not be accurate。RCOND = 3.447937e-19。  
> occbin solver:: period 3::  
> Did not converge – increase maxit.

I guess the problem is in the occbin\_solver()，but I don’t konw how to correct it . Could you please help me to find the reason？

---

<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: [29 March 2023 14:35 UTC](https://forum.dynare.org/t/zlb-implemention-and-occbin-constraints/22173/3 "2023-03-29T14:35:28Z")

</div>

You did not provide all files to run your code.

---

<div class="post-metadata">

### Author: ![chuxi](https://forum.dynare.org/letter_avatar_proxy/v4/letter/c/3e96dc/32.png) [@chuxi](https://forum.dynare.org/u/chuxi)
#### Post date: [29 March 2023 14:48 UTC](https://forum.dynare.org/t/zlb-implemention-and-occbin-constraints/22173/4 "2023-03-29T14:48:54Z")

</div>

Thank you for helping me. After changing the shocks,the mod document is  
[test1.mod](https://forum.dynare.org/uploads/short-url/52wcC8RS5BcjFwvacCCZ7iVpCr3.mod) (8.5 KB)

---

<div class="post-metadata">

### Author: ![chuxi](https://forum.dynare.org/letter_avatar_proxy/v4/letter/c/3e96dc/32.png) [@chuxi](https://forum.dynare.org/u/chuxi)
#### Post date: [29 March 2023 14:55 UTC](https://forum.dynare.org/t/zlb-implemention-and-occbin-constraints/22173/5 "2023-03-29T14:55:18Z")

</div>

Today,I also learn from a mod document (  
[baseline\_model.mod](https://forum.dynare.org/uploads/short-url/gZW9WPNnA9eHGp2nefYfy2xXDfG.mod) (5.0 KB))  
and then I wrote a new mod document  
[test2.mod](https://forum.dynare.org/uploads/short-url/gwsBx1TWS1K2epI19uG9ckM5Elk.mod) (12.3 KB)  
I tried to solve the problem that “The matrix is close to singular value, or scaled incorrectly.”. But when run the progress, the new mistake occurred.The results are as follows:  
dynare test2  
Starting Dynare (version 5.3).  
Calling Dynare with arguments: none  
Starting preprocessing of the model file …  
Found 35 equation(s).  
Evaluating expressions…done  
Computing static model derivatives (order 1).  
Computing dynamic model derivatives (order 2).  
Processing outputs …  
done  
Preprocessing completed.

Equation solved.

fsolve completed because the vector of function values is near zero  
as measured by the default value of the function tolerance, and  
the problem appears regular as measured by the gradient.

Residuals of the static equations:

Equation number 1 : -1.7183 : 随机折现因子  
Equation number 2 : -0.0010004 : 消费决定方程  
Equation number 3 : 9.022714515480534e+72 : 有效消费  
Equation number 4 : -0.023819 : 货币供给量决定方程  
Equation number 5 : -10.7823 : 劳动供给方程  
Equation number 6 : 1.7358 : 存款持有决定方程  
Equation number 7 : 3.0983 : 杠杆  
Equation number 8 : 0 : 银行资产迁移  
Equation number 9 : 0.54572 : 辅助方程1  
Equation number 10 : -0.99616 : 辅助方程2  
Equation number 11 : -2.203697026708854e+44 : 银行利润最大化  
Equation number 12 : 2.5627 : 银行部门总的净资产迁移公式  
Equation number 13 : 0.0067353 : 净资产变化率  
Equation number 14 : 2.0166 : 生产函数  
Equation number 15 : 0 : 资本投入  
Equation number 16 : 0.54825 : 工资  
Equation number 17 : 0.19349 : 利息支付  
Equation number 18 : 0.63324 : 净投资  
Equation number 19 : -1.7183 : 投资调整成本  
Equation number 20 : -5.4495 : 最优资本价格  
Equation number 21 : -0.27076 : 最优通胀率  
Equation number 22 : 1.7569 : 辅助方程3  
Equation number 23 : 10.1683 : 辅助方程4  
Equation number 24 : -3.1664 : 通胀与最优通胀  
Equation number 25 : 2.6765 : 市场出清  
Equation number 26 : 0 : 资本转移  
Equation number 27 : -5.7222 : 总体价格  
Equation number 28 : 0.0099498 : 泰勒规则  
Equation number 29 : 0 : Deposite rate  
Equation number 30 : -0.024267 : 政府购买  
Equation number 31 : 0.025468 : 税收收入  
Equation number 32 : 1.001336836798032e+22 : 政府预算约束  
Equation number 33 : 0 : 技术冲击  
Equation number 34 : 0 : 偏好冲击  
Equation number 35 : 0 : 资本冲击

错误使用 print\_info (line 32)  
The steadystate file did not compute the steady state

出错 steady (line 102)  
print\_info(info,options\_.noprint, options\_);

出错 test2.driver (line 657)  
steady;

出错 dynare (line 281)  
evalin(‘base’,[fname ‘.driver’]);

---

<div class="post-metadata">

### Author: ![chuxi](https://forum.dynare.org/letter_avatar_proxy/v4/letter/c/3e96dc/32.png) [@chuxi](https://forum.dynare.org/u/chuxi)
#### Post date: [29 March 2023 15:10 UTC](https://forum.dynare.org/t/zlb-implemention-and-occbin-constraints/22173/7 "2023-03-29T15:10:01Z")

</div>

a clearer version of test2.mod  
[test2.mod](https://forum.dynare.org/uploads/short-url/g0hHZrGsekDwf8SnNfDeTUnteV8.mod) (11.0 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: [29 March 2023 15:48 UTC](https://forum.dynare.org/t/zlb-implemention-and-occbin-constraints/22173/8 "2023-03-29T15:48:25Z")

</div>

The `steady_helper1.m` is still missing.

---

<div class="post-metadata">

### Author: ![chuxi](https://forum.dynare.org/letter_avatar_proxy/v4/letter/c/3e96dc/32.png) [@chuxi](https://forum.dynare.org/u/chuxi)
#### Post date: [29 March 2023 18:21 UTC](https://forum.dynare.org/t/zlb-implemention-and-occbin-constraints/22173/10 "2023-03-29T18:21:46Z")

</div>

My mind is full of how to solve the model, and I forget that I used functions when calculatingthe steady state. Sorry for wasting your time due to my personal negligence, the file has been uploaded. Thank you for helping me so patiently.  
[steady\_helper1.m](https://forum.dynare.org/uploads/short-url/5RLcJNqXQeQiXBgWKuGKXvbyq2o.m) (185 Bytes)

---

<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: [29 March 2023 18:39 UTC](https://forum.dynare.org/t/zlb-implemention-and-occbin-constraints/22173/11 "2023-03-29T18:39:34Z")

</div>

Only do the exp()-substitution once the model works.

---

<div class="post-metadata">

### Author: ![chuxi](https://forum.dynare.org/letter_avatar_proxy/v4/letter/c/3e96dc/32.png) [@chuxi](https://forum.dynare.org/u/chuxi)
#### Post date: [30 March 2023 00:48 UTC](https://forum.dynare.org/t/zlb-implemention-and-occbin-constraints/22173/12 "2023-03-30T00:48:33Z")

</div>

Sorry,i don’t quite understand the meaning of this sentence.I do the exp()-substitution in test2.mod, but the model still not work, I don’t konw how to solve the error “The steadystate file did not compute the steady state” .Could you please describe this more clearly?

---

<div class="post-metadata">

### Author: ![chuxi](https://forum.dynare.org/letter_avatar_proxy/v4/letter/c/3e96dc/32.png) [@chuxi](https://forum.dynare.org/u/chuxi)
#### Post date: [30 March 2023 02:56 UTC](https://forum.dynare.org/t/zlb-implemention-and-occbin-constraints/22173/13 "2023-03-30T02:56:09Z")

</div>

I check the model again,and correct some tpye error,the problem still exists. the newest version is  
[test2.mod](https://forum.dynare.org/uploads/short-url/jEsLablJCmnKJs8lQ3evIJcHhSH.mod) (11.0 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: [30 March 2023 13:55 UTC](https://forum.dynare.org/t/zlb-implemention-and-occbin-constraints/22173/14 "2023-03-30T13:55:04Z")

</div>

You are currently doing an `exp()`-substitution to get the responses in logs. Only do that once the model works. The huge residuals indicate that most probably something went wrong here when replacing variables.

---

<div class="post-metadata">

### Author: ![chuxi](https://forum.dynare.org/letter_avatar_proxy/v4/letter/c/3e96dc/32.png) [@chuxi](https://forum.dynare.org/u/chuxi)
#### Post date: [30 March 2023 16:02 UTC](https://forum.dynare.org/t/zlb-implemention-and-occbin-constraints/22173/17 "2023-03-30T16:02:26Z")

</div>

Now, I return to the original model to make the model work first, but I still get the error like follows:  
In occbin.mkdatap\_anticipated\_dyn (line 109)  
In occbin.solve\_one\_constraint (line 189)  
In occbin.solver (line 78)  
In test1.driver (line 712)  
In dynare (line 281)  
Warning: The matrix is close to singular value, or scaled incorrectly. Results may not be accurate. RCOND = 2.155939e-18。  
Incorrect use of print\_info (line 32)  
Occbin: Simulation did not converge, increase maxit or check\_ahead\_periods.

Error occbin.solver (line 85)  
print\_info(error\_flag, options\_.noprint, options\_)

Error test1.driver (line 712)  
oo\_ = occbin.solver(M\_, oo\_, options\_);

Error dynare (line 281)  
evalin(‘base’,[fname ‘.driver’]);

the model run when there’s only two periods and doesn’t reach ZLB. It seems that once the model reach ZLB,the error occurs.  
[test1.mod](https://forum.dynare.org/uploads/short-url/jna2V4nvFrjZ1LdSk4WlbF4zHMU.mod) (8.6 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: [30 March 2023 16:40 UTC](https://forum.dynare.org/t/zlb-implemention-and-occbin-constraints/22173/18 "2023-03-30T16:40:46Z")

</div>

Are you sure the ZLB and the timing of interest rates are correctly implemented? For one thing, the ZLB needs to specified in terms of the notional interest rate `rnop`. At the ZLB, `R=1`, so the `relax R>1;` will never happen.

Moreover, equations like

```auto
mu_m*(M(-1)/P(-1))^(-mu)+beta*lambda*(P(-1)/P)=lambda(-1);
K(1)=K+In;

```

look rather unusual.

---

<div class="post-metadata">

### Author: ![chuxi](https://forum.dynare.org/letter_avatar_proxy/v4/letter/c/3e96dc/32.png) [@chuxi](https://forum.dynare.org/u/chuxi)
#### Post date: [31 March 2023 13:00 UTC](https://forum.dynare.org/t/zlb-implemention-and-occbin-constraints/22173/20 "2023-03-31T13:00:19Z")

</div>

Dear，Professor！ Finally I done this and make the ZLB works! Thanks to your reminder, I checked the original model again, and fixed some minor bugs, then he problems were solved. Sincerely thanks for your help again！

 ![figure1](https://forum.dynare.org/uploads/default/original/3X/0/1/013b609cc460c98a2e2b36fa6e10edd9219e91c9.png)

---

<div class="post-metadata">

### Author: ![chuxi](https://forum.dynare.org/letter_avatar_proxy/v4/letter/c/3e96dc/32.png) [@chuxi](https://forum.dynare.org/u/chuxi)
#### Post date: [31 March 2023 13:04 UTC](https://forum.dynare.org/t/zlb-implemention-and-occbin-constraints/22173/21 "2023-03-31T13:04:25Z")

</div>

Now I encounter another problem. My model wants to examine the effect of fiscal policy under the zero interest rate floor. And now that I have simulated the zero interest rate lower bound, what function do I use if I want to examine the impact of an increase in fiscal spending? I don’t know if you have some reference materials or codes that I am able to refer to.

---

<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 March 2023 13:57 UTC](https://forum.dynare.org/t/zlb-implemention-and-occbin-constraints/22173/22 "2023-03-31T13:57:00Z")

</div>

You need a fiscal rule and then you need to shock it.

---

<div class="post-metadata">

### Author: ![chuxi](https://forum.dynare.org/letter_avatar_proxy/v4/letter/c/3e96dc/32.png) [@chuxi](https://forum.dynare.org/u/chuxi)
#### Post date: [31 March 2023 15:08 UTC](https://forum.dynare.org/t/zlb-implemention-and-occbin-constraints/22173/23 "2023-03-31T15:08:22Z")

</div>

I have included fiscal spending rules in the model. The current problem is that I have examined the negative impact of technology can form a zero interest rate lower bound, I want to further examine how effective a positive fiscal expenditure shock is in response to negative technology shock . Because there is already a technical shock, add the positive shock of fiscal expenditure G in the mod file, Dynare will only identify it as two independent shocks, so that I cannot examine the effect of fiscal policy.

---

<div class="post-metadata">

### Author: ![chuxi](https://forum.dynare.org/letter_avatar_proxy/v4/letter/c/3e96dc/32.png) [@chuxi](https://forum.dynare.org/u/chuxi)
#### Post date: [31 March 2023 15:11 UTC](https://forum.dynare.org/t/zlb-implemention-and-occbin-constraints/22173/24 "2023-03-31T15:11:43Z")

</div>

[test1.mod](https://forum.dynare.org/uploads/short-url/kih37RwkbcUKmqfn3nM8dBP6uwv.mod) (8.7 KB)  
the courrent mod file is above. I’m thinking that maybe I need to write a .m file ?Actually,I have no ideas now 😭

---

<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 March 2023 16:22 UTC](https://forum.dynare.org/t/zlb-implemention-and-occbin-constraints/22173/25 "2023-03-31T16:22:59Z")

</div>

The `shocks(surprise)`-block allows for doing shock combinations.

[Next page](https://forum.dynare.org/t/zlb-implemention-and-occbin-constraints/22173.md?page=2)
