# A Model with Segmented Bond Market

**URL:** <https://forum.dynare.org/t/a-model-with-segmented-bond-market/10786>\
**Category:** Replication Attempts\
**Created:** [25 September 2017 01:24 UTC](https://forum.dynare.org/t/a-model-with-segmented-bond-market/10786 "2017-09-25T01:24:47Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![sp1589](https://forum.dynare.org/letter_avatar_proxy/v4/letter/s/57b2e6/32.png) [@sp1589](https://forum.dynare.org/u/sp1589)\
**Post date:** [25 September 2017 01:24 UTC](https://forum.dynare.org/t/a-model-with-segmented-bond-market/10786/1 "2017-09-25T01:24:47Z")

</div>

Hello,

I am trying to run a simplified version of the model by Chen et al. (2012). In basic terms, there are two types of agents. The first type called “u” can buy both short and long-term bonds, but they have to pay a transaction cost to buy the long-term bonds. The second type called “r” can only buy long-term bonds, but don’t have to pay transaction costs. Basically, this modification makes the long-term interest rate matter separately from the short-term.

I am getting a unit root, which is also generating a collinearity between my two consumption variables for the two types of agents. (or is it the other way around?). I am posting the code. I am getting a collinearity between my three euler equations (for short-term bonds, long-term if type “r” and long-term if type “u”) and my gov. budget constraint plus the tax and long-term bond rules and the transaction cost equation. I am not quite sure if there is a misspecification in the model. I would appreciate it if someone can check the code and see if there is something obvious that I have missed.

Code provided in the reply below.

Thanks

---

<div class="post-metadata">

**Author:** ![sp1589](https://forum.dynare.org/letter_avatar_proxy/v4/letter/s/57b2e6/32.png) [@sp1589](https://forum.dynare.org/u/sp1589)\
**Post date:** [25 September 2017 04:07 UTC](https://forum.dynare.org/t/a-model-with-segmented-bond-market/10786/2 "2017-09-25T04:07:28Z")

</div>

I have updated the code to make it easier to look at the problematic equations. I have also reduced their number, but still can’t see the issue.

Here is the updated version.

[seg\_bonds\_market.mod](https://forum.dynare.org/uploads/default/original/2X/a/a817252b570306c2ae5dd86df3dfa258b4c39e6d.mod) (3.1 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:** [25 September 2017 16:10 UTC](https://forum.dynare.org/t/a-model-with-segmented-bond-market/10786/3 "2017-09-25T16:10:43Z")

</div>

I talked to some friends who worked on that model and they report that this is a problem/mistake in the original paper, i.e. not a mistake you did. There is a unit root together with a fundamental singularity in the model reported in the paper. It has been suggested you should try to contact Andrea Ferrero about the issue if you want to keep working on this model. I have not verified this issue. You also might want to check out the other posts related to this model:

> [@Deterministic Linear Model](https://forum.dynare.org/t/deterministic-linear-model/4591):
>
> Hello, I just learned using Dynare a few weeks ago and I have this very simple question for which I haven’t found an answer. I have a stochastic linear model with a normal stochastic shock and need to change it to a deterministic model, where the economy is shocked for the first 4 periods and then an endogenous variable is held fixed for the following 8 periods. The model starts from the steady state, which is 0 for all variables since it’s a linear model. So, am I right that there are no va…

> [@From one type to two types of agents](https://forum.dynare.org/t/from-one-type-to-two-types-of-agents/5673):
>
> Hi all, Problems occur when I try to extend the basic NK model from one agent to two agents model. Codes are attached. It’s a basic NK model with positive inflation target. The price rigidity is governed by Calvo, and it’s indexed to the target inflation. The only shock is the discount factor shock “e\_m”. I can run the mod file “NK1” successfully. However, when I try to extend it to two agents model, it doesn’t work. The two agents model is extended by assuming only a fraction of households …

---

<div class="post-metadata">

**Author:** ![sp1589](https://forum.dynare.org/letter_avatar_proxy/v4/letter/s/57b2e6/32.png) [@sp1589](https://forum.dynare.org/u/sp1589)\
**Post date:** [25 September 2017 17:11 UTC](https://forum.dynare.org/t/a-model-with-segmented-bond-market/10786/4 "2017-09-25T17:11:14Z")

</div>

Thank you Johannes. I would have likely wasted a lot of time trying to figure out what is causing the issue. I e-mailed Andrea Ferrero. I will post his reply to this thread, so that everyone can benefit from it.

---

<div class="post-metadata">

**Author:** ![sp1589](https://forum.dynare.org/letter_avatar_proxy/v4/letter/s/57b2e6/32.png) [@sp1589](https://forum.dynare.org/u/sp1589)\
**Post date:** [29 September 2017 22:51 UTC](https://forum.dynare.org/t/a-model-with-segmented-bond-market/10786/5 "2017-09-29T22:51:24Z")

</div>

Hi All,

I did not get a response from Andrea Ferrero. This model will be an ongoing issue.

---

<div class="post-metadata">

**Author:** ![sp1589](https://forum.dynare.org/letter_avatar_proxy/v4/letter/s/57b2e6/32.png) [@sp1589](https://forum.dynare.org/u/sp1589)\
**Post date:** [9 October 2017 20:09 UTC](https://forum.dynare.org/t/a-model-with-segmented-bond-market/10786/6 "2017-10-09T20:09:37Z")

</div>

Hi All,

I am still not sure what the issue is, but I am beginning to wonder whether it may have something to do with the Blanchard-Kahn method of solving DSGE models. Han Chen sent me a link to all of their codes for this paper. The model is solved in Matlab through Sims’ Expectational Errors method and his gensys algorithm, which he wrote in order to put his method in practice. This method is more general than Blanchard-Kahn and now I am wondering if there is something in the Blanchard-Kahn framework which dynare uses compared to Sims’ method.

Does anyone have any thoughts on this?

---

<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:** [11 October 2017 07:33 UTC](https://forum.dynare.org/t/a-model-with-segmented-bond-market/10786/7 "2017-10-11T07:33:58Z")

</div>

You should not confuse the Blanchard-Kahn algorithm for solving models with the Blanchard-Kahn conditions. The latter describe the conditions for a unique bounded solution.  
The Blanchard-Kahn solution algorithm is indeed less general than `gensys`, because you cannot have static variables. Dynare does not use Blanchard-Kahn to obtain the solution. But once you have the solution and the eigenvalues, the same conditions on uniqueness and existence apply.

That being said: when you have their code, you should be able to trace any difference. Is their entered model (before solving) the same as yours and do you get the same steady state?

---

<div class="post-metadata">

**Author:** ![sp1589](https://forum.dynare.org/letter_avatar_proxy/v4/letter/s/57b2e6/32.png) [@sp1589](https://forum.dynare.org/u/sp1589)\
**Post date:** [11 October 2017 19:35 UTC](https://forum.dynare.org/t/a-model-with-segmented-bond-market/10786/8 "2017-10-11T19:35:53Z")

</div>

I did not want to mix up the BK conditions with the BK algorithm. It is not as easy to compare at the moment, since my model is not 1 to 1 with theirs, plus their code has a whole bunch of functions and it will take a while for me to disentangle things.

Update: I thought the issue might be that Dynare can’t handle singular G\_0 matrices, but then I read that it uses Klein’s method, which handles singular matrices. Then I wonder if Klein’s and Sims’ method differ in other ways that might make this model solvable in gensys as opposed to Dynare. I am reading more on that.

---

<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 October 2017 07:09 UTC](https://forum.dynare.org/t/a-model-with-segmented-bond-market/10786/9 "2017-10-12T07:09:43Z")

</div>

The model still has one degree of freedom left. No algorithm will give you a unique solution in this case, because there is nothing that would pin down the remaining expectational error. That is the reason why I am asking whether their model in their code features the same problem - and if not, where it differs from your implementation.

---

<div class="post-metadata">

**Author:** ![sp1589](https://forum.dynare.org/letter_avatar_proxy/v4/letter/s/57b2e6/32.png) [@sp1589](https://forum.dynare.org/u/sp1589)\
**Post date:** [19 October 2017 01:13 UTC](https://forum.dynare.org/t/a-model-with-segmented-bond-market/10786/10 "2017-10-19T01:13:55Z")

</div>

Ok, so I solved Chen et al. (2012)'s model on my own with gensys. To make sure that my output is correct, I solved the simple 2 period NK model in dynare and then in Gensys to make sure that I get equivalent results. Their model does output a unique equilibrium. My model which gives me the unit root in dynare does not yield unique equilibria. Hence, their is something wrong in my setup, which I have to identify.

I find it puzzling, because this model is a reduced form of theirs. What I differ in their specification is that I exclude sticky wages, capital utilization and I used Rotemberg AC instead of Calvo pricing. Something about the segmentation must be interfering with my specification.

In any case though, there doesn’t appear to be a fundamental problem with their model.

---

<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:** [20 October 2017 12:13 UTC](https://forum.dynare.org/t/a-model-with-segmented-bond-market/10786/11 "2017-10-20T12:13:54Z")

</div>

@sp1589 That is not entirely clear, unless you verified that their coded equilibrium conditions really coincide with the actual equilibrium conditions. It may be that in the additional features added, there is something weird happening and your approach is actually correct. That is the tricky part if results do not match in a replication study. You do not really know who made the mistake. A priori, it is more likely you were the one doing something wrong, but given that many people seem to have tried to replicate the paper and failed, I would say the probability is closer to 50:50. Thus, I would not blindly trust their code being correct.

---

<div class="post-metadata">

**Author:** ![sp1589](https://forum.dynare.org/letter_avatar_proxy/v4/letter/s/57b2e6/32.png) [@sp1589](https://forum.dynare.org/u/sp1589)\
**Post date:** [20 October 2017 14:09 UTC](https://forum.dynare.org/t/a-model-with-segmented-bond-market/10786/12 "2017-10-20T14:09:01Z")

</div>

Deleted Post. Updated post below.

---

<div class="post-metadata">

**Author:** ![sp1589](https://forum.dynare.org/letter_avatar_proxy/v4/letter/s/57b2e6/32.png) [@sp1589](https://forum.dynare.org/u/sp1589)\
**Post date:** [22 October 2017 02:18 UTC](https://forum.dynare.org/t/a-model-with-segmented-bond-market/10786/13 "2017-10-22T02:18:31Z")

</div>

Okay, I actually solved Chen et al.(2012)'s model in Dynare. Since, I have their code i copied their equations in dynare and made the necessary modifications. Their model does exhibit a unit root. In fact there are two of them.

Now my issue is this. Is this model supposed to generate a unit root or the unit roots in the model are present due to a misspecified model. I am not sure how I can figure that out unless any of the coauthors respond to my e-mails. I will e-mail them again. I will also appreciate any suggestions. I would really prefer not to give up on using this model if I can.

---

<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:** [23 October 2017 07:37 UTC](https://forum.dynare.org/t/a-model-with-segmented-bond-market/10786/14 "2017-10-23T07:37:43Z")

</div>

Are there only unit roots or is there also the singularity issue? And which variables does not the unit affect? You should be able to see this as the theoretical moments of the variables will be NaN.

---

<div class="post-metadata">

**Author:** ![sp1589](https://forum.dynare.org/letter_avatar_proxy/v4/letter/s/57b2e6/32.png) [@sp1589](https://forum.dynare.org/u/sp1589)\
**Post date:** [23 October 2017 16:55 UTC](https://forum.dynare.org/t/a-model-with-segmented-bond-market/10786/15 "2017-10-23T16:55:17Z")

</div>

There are both unit roots and the singularity issue. By that I suppose you refer to whether the Jacobian matrix of the static model is singular. Yes, it is and it leads to a collinearity issue. Non of the theoretical moments of the variables are NaN. I have attached the dynare files for both their model and mine. The only difference is that my model has only one unit root, while theirs has two. For both models, the Jacobian is singular. Is that what you mean by singularity?

Can you please take a look and let me know what you think Johannes?

[chen\_et\_al\_dynare.mod](https://forum.dynare.org/uploads/default/original/2X/f/fc7789bb6064c5a1d259e2605921d97aaf26a65e.mod) (8.0 KB)

[reduced\_form\_version\_Chen.mod](https://forum.dynare.org/uploads/default/original/2X/1/1ecb0e8cd8e49450b87a43c572562ee809ee0dba.mod) (3.9 KB)

---

<div class="post-metadata">

**Author:** ![sp1589](https://forum.dynare.org/letter_avatar_proxy/v4/letter/s/57b2e6/32.png) [@sp1589](https://forum.dynare.org/u/sp1589)\
**Post date:** [26 October 2017 13:04 UTC](https://forum.dynare.org/t/a-model-with-segmented-bond-market/10786/16 "2017-10-26T13:04:46Z")

</div>

Vasco Curdia said that there is a unit root, because of the way they defined fiscal policy. I am working on alternative forms to try to get rid of the unit root, but i am still not one hundred percent certain that is the issue.

A unrelated question. How can I get the original input matrices of my model in dynare? That is in a model of the form:

Ax\_t=Bx\_(t-1)+Cz\_t I would like to recover the matrices A and B. That is, I want to recover the original input matrices of the state space form and not the solution: x\_t=Gx\_t-1+Dz\_t.

---

<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:** [28 October 2017 01:09 UTC](https://forum.dynare.org/t/a-model-with-segmented-bond-market/10786/17 "2017-10-28T01:09:46Z")

</div>

But then the question is how they solved that unit root issue in their Dynare replication codes.  
What do you mean with “original input matrices”? Because what you wrote down is the solution as it is purely backward-looking.

---

<div class="post-metadata">

**Author:** ![sp1589](https://forum.dynare.org/letter_avatar_proxy/v4/letter/s/57b2e6/32.png) [@sp1589](https://forum.dynare.org/u/sp1589)\
**Post date:** [28 October 2017 01:33 UTC](https://forum.dynare.org/t/a-model-with-segmented-bond-market/10786/18 "2017-10-28T01:33:54Z")

</div>

Sorry, my timing was supposed to be at t+1 and t. I simply meant the matrices that describe the equilibrium system before a solution method is applied.

I found an issue in how I was defining the market value of long-term debt. That was causing my unit root under a standard environment where the short-term nominal rate adjusts. The unit root is still present when I try to incorporate the ZLB for T periods. Perhaps that is what Vasco Curdia was referring to since they have a 4 period peg in their model. I am using the same definition of their peg in a simple setup, but the unit root does not go away. I am working on figuring that out.

---

<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:** [28 October 2017 01:35 UTC](https://forum.dynare.org/t/a-model-with-segmented-bond-market/10786/19 "2017-10-28T01:35:46Z")

</div>

There is currently no way to get those matrices. You would have to get them manually from `dyn_first_order_solver.m`

---

<div class="post-metadata">

**Author:** ![sp1589](https://forum.dynare.org/letter_avatar_proxy/v4/letter/s/57b2e6/32.png) [@sp1589](https://forum.dynare.org/u/sp1589)\
**Post date:** [30 October 2017 23:13 UTC](https://forum.dynare.org/t/a-model-with-segmented-bond-market/10786/20 "2017-10-30T23:13:21Z")

</div>

Okay got it. Thank you. It is surprising that this part hasn’t been automated yet, because looking at those matrices might help with identifying problems in a model.

As a separate question, can you refer me to an existing relatively comprehensive deterministic model in Dynare? I haven’t solved one of those in Dynare before and I am not very familiar with the code/notation. Also, how would one incorporate an interest rate peg in a deterministic setup?

Thanks

[Next page](https://forum.dynare.org/t/a-model-with-segmented-bond-market/10786.md?page=2)
