# Discretionary policy

**URL:** <https://forum.dynare.org/t/discretionary-policy/6247>\
**Category:** Optimal Policy\
**Created:** [5 June 2017 21:16 UTC](https://forum.dynare.org/t/discretionary-policy/6247 "2017-06-05T21:16:57Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![marlenemaya](https://forum.dynare.org/letter_avatar_proxy/v4/letter/m/3bc359/32.png) [@marlenemaya](https://forum.dynare.org/u/marlenemaya)\
**Post date:** [5 June 2017 21:16 UTC](https://forum.dynare.org/t/discretionary-policy/6247/1 "2017-06-05T21:16:57Z")

</div>

Hi!  
I’m running a new keynesian stochastic model.I’m evaluating the welfare loss with a ramsey\_policy rule. Then I switched to discretionary\_policy, but I meet some errors messages. In particular

```auto
Error using discretionary_policy_1 (line 71)
discretionary_policy: the objective function must have zero first order derivatives

Error in stoch_simul (line 76)
    [oo_.dr,ys,info] = discretionary_policy_1(oo_,options_.instruments);

Error in discretionary_policy (line 25)
info = stoch_simul(var_list);

Error in ed (line 231)
discretionary_policy(var_list_);

Error in dynare (line 223)
evalin('base',fname) ;
 
```

I attach here my code. What should I change?  
Thank you in advance  
[edsingle.m](https://forum.dynare.org/uploads/default/original/2X/b/b5413bc141ace84005d89841aafc64a59d212243.m) (8.61 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:** [6 June 2017 07:00 UTC](https://forum.dynare.org/t/discretionary-policy/6247/2 "2017-06-06T07:00:39Z")

</div>

You need to provide the mod-file, not the m-file. My guess is that your objective function is not written in terms of centered second moments, but rather contains a linear term as well (e.g. if there is a distorted steady state)

---

<div class="post-metadata">

**Author:** ![marlenemaya](https://forum.dynare.org/letter_avatar_proxy/v4/letter/m/3bc359/32.png) [@marlenemaya](https://forum.dynare.org/u/marlenemaya)\
**Post date:** [6 June 2017 10:23 UTC](https://forum.dynare.org/t/discretionary-policy/6247/3 "2017-06-06T10:23:28Z")

</div>

Sorry this is the correct file.  
[ed.mod](https://forum.dynare.org/uploads/default/original/2X/b/b367f8956f6de2da387be4f7946643cf74c149e7.mod) (2.93 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 June 2017 06:24 UTC](https://forum.dynare.org/t/discretionary-policy/6247/4 "2017-06-07T06:24:37Z")

</div>

Your objective contains

```auto
((1-n)/kappa_f)*pp_f
```

at the end. This is a linear term, not a quadratic one.

---

<div class="post-metadata">

**Author:** ![marlenemaya](https://forum.dynare.org/letter_avatar_proxy/v4/letter/m/3bc359/32.png) [@marlenemaya](https://forum.dynare.org/u/marlenemaya)\
**Post date:** [11 June 2017 21:40 UTC](https://forum.dynare.org/t/discretionary-policy/6247/5 "2017-06-11T21:40:16Z")

</div>

Thank you!  
That was a mistake!  
The problem, anyway,remains. When I try to run the code I receive an error message saying that the objective function should have zero first order derivative. I don’t really know how to get out of it…  
Thank you

---

<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 June 2017 18:05 UTC](https://forum.dynare.org/t/discretionary-policy/6247/6 "2017-06-12T18:05:54Z")

</div>

Please provide the updated mod-file

---

<div class="post-metadata">

**Author:** ![marlenemaya](https://forum.dynare.org/letter_avatar_proxy/v4/letter/m/3bc359/32.png) [@marlenemaya](https://forum.dynare.org/u/marlenemaya)\
**Post date:** [12 June 2017 18:42 UTC](https://forum.dynare.org/t/discretionary-policy/6247/7 "2017-06-12T18:42:01Z")

</div>

This is the updated file-  
Thank you  
[ed.mod](https://forum.dynare.org/uploads/default/original/2X/6/6970d2cd0b341f2cb184e0a47e4e035860905bad.mod) (2.92 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 June 2017 18:50 UTC](https://forum.dynare.org/t/discretionary-policy/6247/8 "2017-06-12T18:50:09Z")

</div>

```auto
(n*sigmas)/2)*(s-sb)
```

is still linear

---

<div class="post-metadata">

**Author:** ![marlenemaya](https://forum.dynare.org/letter_avatar_proxy/v4/letter/m/3bc359/32.png) [@marlenemaya](https://forum.dynare.org/u/marlenemaya)\
**Post date:** [12 June 2017 19:52 UTC](https://forum.dynare.org/t/discretionary-policy/6247/9 "2017-06-12T19:52:15Z")

</div>

Yes ist’s true. Anyway also correcting the code (every element at ^2), I receive te following error message:

> [@](#):
>
> Error using print\_info (line 133)  
> Discretionary policy: NaN elements are present in the solution. Procedure failed.
> 
> Error in stoch\_simul (line 94)  
> print\_info(info, options\_.noprint, options\_);
> 
> Error in discretionary\_policy (line 25)  
> info = stoch\_simul(var\_list);
> 
> Error in ed (line 236)  
> discretionary\_policy(var\_list\_);
> 
> Error in dynare (line 223)  
> evalin(‘base’,fname) ;

---

<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:** [14 June 2017 16:30 UTC](https://forum.dynare.org/t/discretionary-policy/6247/10 "2017-06-14T16:30:48Z")

</div>

There must still be a fundamental timing error in the model. model\_diagnostics says:

`MODEL_DIAGNOSTICS: The following endogenous variables aren't present at the current period in the model:
w `

---

<div class="post-metadata">

**Author:** ![marlenemaya](https://forum.dynare.org/letter_avatar_proxy/v4/letter/m/3bc359/32.png) [@marlenemaya](https://forum.dynare.org/u/marlenemaya)\
**Post date:** [15 June 2017 15:26 UTC](https://forum.dynare.org/t/discretionary-policy/6247/11 "2017-06-15T15:26:47Z")

</div>

The problem is that if I specify the expression for the losses in the model(that is linear), it cannot be solved because is not linear.  
I don’t really know what to do…

---

<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:** [16 June 2017 08:57 UTC](https://forum.dynare.org/t/discretionary-policy/6247/12 "2017-06-16T08:57:46Z")

</div>

Those are two different things. The objective function does not belong in the model-block. But when a variable does not appear with contemporaneous timing, it indicates a timing error in the model. That variable would otherwise not be determined by your model

---

<div class="post-metadata">

**Author:** ![marlenemaya](https://forum.dynare.org/letter_avatar_proxy/v4/letter/m/3bc359/32.png) [@marlenemaya](https://forum.dynare.org/u/marlenemaya)\
**Post date:** [16 June 2017 14:34 UTC](https://forum.dynare.org/t/discretionary-policy/6247/13 "2017-06-16T14:34:02Z")

</div>

thank, you…maybe I’ve found what’s wrong…the welfare losses w(the objective function), are the infinite summation of the welfare losses from 0 to infinitive. I should find a way to include this summation into the expression, but I’ve read that on dynare is not possible. I should transform the sum in a recursive expression (since I cannot linearize the objective function) but I don’t know exactly how to do it…  
Thank you for the big help until now!

---

<div class="post-metadata">

**Author:** ![marlenemaya](https://forum.dynare.org/letter_avatar_proxy/v4/letter/m/3bc359/32.png) [@marlenemaya](https://forum.dynare.org/u/marlenemaya)\
**Post date:** [16 June 2017 14:38 UTC](https://forum.dynare.org/t/discretionary-policy/6247/14 "2017-06-16T14:38:37Z")

</div>

Nb also I cannot enter lagged or lead variables into the discretionary\_policy command…

---

<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:** [17 June 2017 15:17 UTC](https://forum.dynare.org/t/discretionary-policy/6247/15 "2017-06-17T15:17:57Z")

</div>

The planner\_objective takes a period utility function, not the intertemporal one. If you need leads or lags in the objective, you need to define an auxiliary variable defining the lag in the model block and then use that auxiliary variable

---

<div class="post-metadata">

**Author:** ![Seungcheol\_Lee](https://forum.dynare.org/letter_avatar_proxy/v4/letter/s/57b2e6/32.png) [@Seungcheol\_Lee](https://forum.dynare.org/u/Seungcheol_Lee)\
**Post date:** [17 August 2017 13:06 UTC](https://forum.dynare.org/t/discretionary-policy/6247/16 "2017-08-17T13:06:47Z")

</div>

Dear jpfeifer

Hello. I have a question about the objective funciton in discretionary policy procedure.

Can I use a centered second moment in the objective function?

When I write a centered second moment in objective function, I meet the following error message.

# ================================================================= Error using discretionary\_policy\_1 (line 71) discretionary\_policy: the objective function must have zero first order derivatives

The objective function that I like to minize is (1-KSI)_(cco-1)^2 + KSI_(ccr-1)^2, but I think it doesn’ work with discretionary\_policy.

I tried by adding equations such as co = cco-1, cr = ccr-1, and changed my objective function as (1-KSI)_(co)^2 + KSI_(cr)^2, then I met the following error message.

# ======================================================================== Error using discretionary\_policy\_1 (line 91) discretionary\_policy: the model must be written in deviation form and not have constant terms

If I write my objective function just as (1-KSI)_(cco)^2 + KSI_(ccr)^2, then I can get impulse response functions, but that’s not what I exactly like to do.

Is there a way to write a centered second moment in the objective function?

Thank you.

Best regards  
Seungcheol

---

<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:** [17 August 2017 13:52 UTC](https://forum.dynare.org/t/discretionary-policy/6247/17 "2017-08-17T13:52:45Z")

</div>

Unfortunately, that is not possible. If you look at the Dennis (2007) paper underlying the discretionary policy solution algorithm, you will see that only pure quadratic forms are permitted.
