Discretionary policy

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

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)

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

I attach here my code. What should I change?
Thank you in advance
edsingle.m (8.61 KB)

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)

Sorry this is the correct file.
ed.mod (2.93 KB)

Your objective contains


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

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

Please provide the updated mod-file

This is the updated file-
Thank you
ed.mod (2.92 KB)


is still linear

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

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

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…

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

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!

Nb also I cannot enter lagged or lead variables into the discretionary_policy command…

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

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

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.

1 Like