# BGG model with OSR

**URL:** https://forum.dynare.org/t/bgg-model-with-osr/1415
**Category:** Dynare help (legacy posts)
**Created:** [6 April 2010 18:29 UTC](https://forum.dynare.org/t/bgg-model-with-osr/1415 "2010-04-06T18:29:09Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![flaminia2010](https://forum.dynare.org/letter_avatar_proxy/v4/letter/f/a4c791/32.png) [@flaminia2010](https://forum.dynare.org/u/flaminia2010)
#### Post date: [6 April 2010 18:29 UTC](https://forum.dynare.org/t/bgg-model-with-osr/1415/1 "2010-04-06T18:29:09Z")

</div>

Hi everyone,  
I am trying to implement the BGG model with an optimal simple rule where the interest rate respond to asset prices, other than output gap, and inflation but I get the following message for each iteration:

## Improvement on iteration … = NaN

* * *

## f at the beginning of new iteration, Inf Predicted improvement: 0.000000000 lambda = 1; f = Inf Norm of dx 0 bad gradient ------------------------ bad gradient ------------------------ bad gradient ------------------------ Cliff. Perturbing search direction. Predicted improvement: 0.000000000 lambda = 1; f = Inf Norm of dx 0

and finally, at the last iteration:

Improvement on iteration 1001 = NaN  
iteration count termination  
OPTIMAL VALUE OF THE PARAMETERS:  
gammax0 0.5

```
  gammac0 1.1

  gammarr 0.8

```

which are the same parameters I put for the initialisation. I am wondering if it is normal. If there is something wrong may I ask what it is?  
I attach the .mod file I wrote for an european calibrated model.  
Thanks  
[BGGEUosr3.mod](https://forum.dynare.org/uploads/default/original/1X/2eefe8cf2be53d4e16c4880041c38941fba8588c.mod) (2.02 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: [7 April 2010 12:33 UTC](https://forum.dynare.org/t/bgg-model-with-osr/1415/2 "2010-04-07T12:33:14Z")

</div>

Apparently, you are using bad starting values. Hence, even the first optimization step fails as the model solution cannot be computed. When trying to find the steady state of your model by using the command

```auto

```

after the shocks statement, I get the error message:

STEADY: numerical initial values incompatible with the following equations 18

Hence, you should check if your model is correct and the initial values you supply lead to a well-defined steady state.

---

<div class="post-metadata">

### Author: ![flaminia2010](https://forum.dynare.org/letter_avatar_proxy/v4/letter/f/a4c791/32.png) [@flaminia2010](https://forum.dynare.org/u/flaminia2010)
#### Post date: [7 April 2010 17:05 UTC](https://forum.dynare.org/t/bgg-model-with-osr/1415/3 "2010-04-07T17:05:40Z")

</div>

Hi, Thank you for your answer.  
I hope you will answer to the following questions too:

1. I cannot use the commmand you wrote, since I get the following message:

??? Error: File: c:\dynare\4.0.4\matlab\BGGEUosr4.m Line: 222 Column: 14  
Missing MATLAB operator.

Error in ==\> dynare at 102  
evalin(‘base’,fname) ;

Why that happens?

1. what starting values do you mean? The ones of the OSR? How can I find the right ones?  
In fact the model seems to work well when it runs with fixed parameters in the Taylor rule (gammaC0 = 0.11 and gammarr = 0.9). Actually I don’t have any problem because in that case the steady state exists.  
thanks again

---

<div class="post-metadata">

### Author: ![flaminia2010](https://forum.dynare.org/letter_avatar_proxy/v4/letter/f/a4c791/32.png) [@flaminia2010](https://forum.dynare.org/u/flaminia2010)
#### Post date: [7 April 2010 19:32 UTC](https://forum.dynare.org/t/bgg-model-with-osr/1415/4 "2010-04-07T19:32:31Z")

</div>

I misunderstood the comand you suggest me, i did it right and i get the same message as you. How is it possible that the model runs with the same fixed values in the taylor rule that i put as initialisation values for the osr, that seems to’ be’ incorrect?  
Thanks and sorry for the misunderstanding

---

<div class="post-metadata">

### Author: ![flaminia2010](https://forum.dynare.org/letter_avatar_proxy/v4/letter/f/a4c791/32.png) [@flaminia2010](https://forum.dynare.org/u/flaminia2010)
#### Post date: [7 April 2010 19:34 UTC](https://forum.dynare.org/t/bgg-model-with-osr/1415/5 "2010-04-07T19:34:18Z")

</div>

I misunderstood the comand you suggest me, i did it right and i get the same message as you. How is it possible that the model runs with the same fixed values in the taylor rule that i put as initialisation values for the osr, that seems to’ be’ incorrect?  
Thanks and sorry for the misunderstanding

---

<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: [8 April 2010 16:43 UTC](https://forum.dynare.org/t/bgg-model-with-osr/1415/6 "2010-04-08T16:43:25Z")

</div>

Sorry, but I am not sure what you mean with “the model runs”? With the wrong initial values, there is no steady state and the model does not run. Try for example using

```auto

```

and you will see that is also gives you an error.

---

<div class="post-metadata">

### Author: ![flaminia2010](https://forum.dynare.org/letter_avatar_proxy/v4/letter/f/a4c791/32.png) [@flaminia2010](https://forum.dynare.org/u/flaminia2010)
#### Post date: [9 April 2010 07:32 UTC](https://forum.dynare.org/t/bgg-model-with-osr/1415/7 "2010-04-09T07:32:51Z")

</div>

You are right, when I add that command there is an error message.  
But here what I meant when I said that the steady state exists when the model runs with fixed parameter in the Taylor rule: I have attached a mod file example in which two discretionary parameters has been put in the TR. As you can see dynare solves it and it gives back the steady state value.  
Thanks again for your help!  
[BGGEUfl.mod](https://forum.dynare.org/uploads/default/original/1X/ff7af881d1485e7ea7eb8c0491fb5ee64903a022.mod) (2.01 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: [9 April 2010 11:01 UTC](https://forum.dynare.org/t/bgg-model-with-osr/1415/8 "2010-04-09T11:01:56Z")

</div>

Apparently, you changed lines 54 and 55 (second and third to last model equations). The latter one is the equation producing the error. So this is the reason why it does not work anymore.

---

<div class="post-metadata">

### Author: ![flaminia2010](https://forum.dynare.org/letter_avatar_proxy/v4/letter/f/a4c791/32.png) [@flaminia2010](https://forum.dynare.org/u/flaminia2010)
#### Post date: [11 April 2010 08:31 UTC](https://forum.dynare.org/t/bgg-model-with-osr/1415/9 "2010-04-11T08:31:24Z")

</div>

Hi,  
I tried to not modify anything of the baseline model, except that the osr command at the end of the file, but I get the following message  
??? Error using ==\> print\_info  
MJDGGES returns the following error code11

Error in ==\> check at 53  
print\_info(info);

Error in ==\> BGGosra at 208  
check;

Error in ==\> dynare at 102  
evalin(‘base’,fname) ;

which should indicate, if I get right from another post, some problem with the 11th eingenvalue. I still don’t understand how it is possible since the steady state of the baseline model exisists and I put as initialisation values of the osr the ones I used for the baseline model (0.11 and 0.9).  
I really appreciate your hel  
[BGGosra.mod](https://forum.dynare.org/uploads/default/original/1X/615eebfdeddbe3862819b616222a4da3df5ffee0.mod) (2.09 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: [12 April 2010 08:27 UTC](https://forum.dynare.org/t/bgg-model-with-osr/1415/10 "2010-04-12T08:27:58Z")

</div>

You still did not solve the underlying problem. If you put the check command that gives you the error after the steady command, you will see that you still have incompatible starting values in your model in the first place.
