What exactly are you trying to do? A ZLB example is e.g. at https://github.com/JohannesPfeifer/DSGE_mod/blob/master/Gali_2015/Gali_2015_chapter_5_commitment_ZLB.mod

# A Model with Segmented Bond Market

**sp1589**#22

Chen et al.'s ZLB commitment is implemented through a perfect foresight solution method. I simply want to implement the ZLB as well in a perfect foresight setup with the very basic setup that I have based on their framework.

**sp1589**#23

So in this example of Gali, this FOC \xi_{2,t}\frac{1}{\sigma} = 0 has to hold whenever the non-negativity constraint i>0 doesn’t bind. In other words, from what I understand, this FOC has to hold whenever the economy is at a point that may imply negative nominal rate. Hence, we set it equal to 0? In this example, the goal is to prevent the possibility of a negative nominal rate and the minimum value is imposed at 0.

What I am trying to figure out is how to impose a ZLB for a certain number of periods T (say from period 0 to period T=4) and then observe the behavior of the economy subject to another shock in the presence of the ZLB. Basically, I want to introduce a peg for a certain number of periods T

**jpfeifer**#24

Regarding the tag, see Deterministic model with linearized equations

I am not sure I understand the full logic here. The ZLB is an occasionally binding constraint. You hit it whenever a shock brings you there. You seem to be suggesting that you want the central bank to deliberately choose a value for the interest rate instead of following a Taylor rule. That seems more a matter of specifying an exogenous process then of an endogeneous constraint.

**sp1589**#25

I know it is an endogenous constraint. Sorry if that was confusing. Implicitly, I was thinking more along the lines of a series of news shocks whose value is set such that the response of the nominal interest rate is zero for a particular number of periods T.

Let me just restate. Let’s assume there is a fiscal shock that hits the economy at period 0. There is also a series of shocks that “peg” the interest rate for a number of periods T. Hence, the goal of the exercise is say to observe the behavior of the economy in response to that fiscal shock while also the ZLB is binding for a certain number of periods T. My question is how can I do that in Dynare.

**jpfeifer**#26

Yes, you can do that, but you need to compute the sequence of news shocks that keep the ZLB binding. Essentially, you need to write a loop of `perfect_foresight_solver`

while adjusting `oo_.exo_simul`

. You may be able to even put this into an objective function and then call a solver to find the shocks in `oo_.exo_simul`

that give you the desired outcome.

**sp1589**#27

Intuitively, the way this mechanism works makes perfect sense. However, I am having trouble envisioning how to code this up. Let’s say I want a four period peg. I have a Taylor rule of the form:

i=i*+phi_pi(pi-pi*)+epsilon1+epsilon2(-1)+epsilon3(-2)+epsilon4(-3).

That is one way the peg can be written. Let’s suppose that I just want one period peg. I can just leave epsilon1 and the other news shocks are zero. Now, let’s assume there is some shock (let’s say fiscal) that hits the economy from period 0 to 5. That shock (absent any news shock) would lead to a change in the nominal rate in period 0,1 and so on before the economy returns to steady state. Introducing, epsilon1 I have to solve for this shock, such that this shock is essentially equal to the deviation of the nominal rate from its steady state (following the fiscal shock) in order to “peg” the nominal rate for one period, which in this case is period 0.

I am not sure if that is something you had done, but can you give me a rough guideline on how the code should look like.

**jpfeifer**#28

This is an equations solving problem: you input a putative value for `epsilon1`

, write it to `oo_.exo_simul`

and run the `perfect_foresight_solver`

. The output is the deviation of the simulated interest rate given this guessed shock from its target value (the ZLB). Then you run a numerical solver over `epsilon1`

to find the value that makes this difference 0.

**sp1589**#29

What do you mean by write it to oo_.exo.simul? I am a bit confused with the sequence of events here. oo_.exo_simul is generated by the shocks block. Can I write on oo_.exo_simul within the dynare mod file, before I call the perfect foresight solver and after the shocks block?

Technically, I already have a fiscal shock so my exo.simul vector is T by 1(since I have one shock). If I were to specify another shock epsilon hitting the system, then exo.simul would have to be T by 2 and if the shock is supposed to peg the rate in period 0, I will have a value say x for epsilon1 in period 0 and then 0 thereafter. Given some value y for the fiscal shock, then I have to find the value x in period 0 that makes R=R*.

**sp1589**#30

A separate question. If i were to write something like R=R*+(1-epsilon1)*(phi_pi*pi) where epsilon1 is a shock equal to 1 in period 0 and 0 thereafter. This will technically peg the interest rate for period 0 to the steady state value, but that is technically incorrect, since it doesn’t take into account the behavior of the other variables in the economy given that the nominal interest rate doesn’t move. Is that logic right? I guess I am not quite how this shock interacts with the agent expectations in determining the dynamics of the model in period 0.

If I were to not care about the exact value of these news shocks that peg the value of the interest rate each period, is there a simpler way to model the peg in a perfect foresight model.

**sp1589**#31

I figured out how to model the peg. A simple “dummy” shock for the duration of the peg does the trick.

Just to wrap this thread up. Chen et al.'s paper does have a unit root, but only for certain parameterizations possibly due to the specification of their fiscal policy. However, the framework is well defined and this model can be used for studying relevant questions. In their case, my guess is that since they estimate the model, even if they get a unit root for certain number of simulations, as long as that number is small enough they still get convergence.

**at1234**#32

Hi everyone,

I also started an attempt to replicate this paper by Chen et al. (2012) with no success so far. As written above, I also received the original codes after some time of struggel, trying to get the right equations. However, even when using the exact same equations as in the original code, the same parameters (posterior medians) and copying the authors´ exogenously determined path for the market value of long-term bonds (with detrministic simulation), I am not able to get this model running properly.

I attach my codes below. What I do in detail is:

- List item Copy the authors´ equations and parameter values
- List item Add the original deterministic shock path for the market value of long-term bonds
- List item Set rhoB equal to zero to make BLMVz_t = eBL_t (variable equal shock)
- List item Create variables to be plotted equal to the authors` definition and scaling

With this code, I would like to replicate the NO ZLB case, depicted in figure 4 in the paper. When you run my code, you will see that the results seem to match quite well. However: extending the number of simulation periods from 29 (as in original paper) to say 300, the model reveals weird negative output response and is obviously not working properly.

I also encounter the unit root problem which you have been talking about before, but don´t know if this influences my problem.

Do you have any idea, what the problem might be? Are you aware of any succesfull replication of the Chen et al. (2012) paper?

Thanks a lot in advance for your help!

run.m (2.9 KB)

replication_july18.mod (8.6 KB)

**sp1589**#33

Hi at1234,

I was never able to figure out the issue with the model. I had extended their model to do something I had in mind, which got rid of the unit root issue. However, in their original model that always remained an issue. I believe that their is a technical issue associated with the interaction of the three euler equations and how long-term bonds are specified as an exogenous shock process.

As you probably know, their model is based on Andres et al. (2004), which is the original paper that specifies this segmented bond market model specification. Theoretically, there is no issue with the model, but computationally there seems to be. Eventually, I modified my question and stopped working with this model.

I am not sure why you want to replicate this paper, but here is my suggestion. Since there are only 2 papers (in history) using this specific model, and given that there is this underlying issue that a lot of people have experienced, I would suggest that you try to modify your question in order to avoid using this model.

However, if your intention is to extend this model in a certain respect, I would suggest that you try that. It is possible that this issue would disappear once you modify it. That was the case with what I was doing.

**at1234**#34

Thanks a lot for your reply!

My plan was to do only minor changes to make the model comparable to others in terms ofasset purchases. Unfortunately this does not remove the issue. I guess I will have to focus on other models.

Wouls you tell me which kind of changes you did to get rid of the unit root?

Thanks!

**sp1589**#35

Hi,

Sorry for the late reply. I was mostly “messing around” with the utility function actually. I was adding bonds in the utility, which breaks ricardian equivalence separately from the segmented markets model, but having both present eliminated the unit root issue.