Hello, dear Prof. Jpfeifer. I am currently running an optimal ramsey policy. when I use only R(taylor rule) instrument, it works. But when I add the tax(two instruments), there are error messages.

(1) When i use the version 4.5.4, the erroe message is as follow; Reference to non-existent field ‘ghx’.
Error in evaluate_planner_objective (line 44)
Gy = dr.ghx(nstatic+(1:nspred),:);
Error in ramsey_policy (line 57)
oo_.planner_objective_value = evaluate_planner_objective(M_,options_,oo_);
Error in sample (line 901)
ramsey_policy(var_list_);
Error in dynare (line 223)
evalin(‘base’,fname) ;
Error in sample_plot (line 4)
dynare sample.mod

(2) When i use unstable version 4.6-unstable-9e06eb8e65e710412467f5044954a87b11c65a7c, the erroe message is as follow;
Error using clear Cannot redefine class ‘dates’ without a call to ‘clear classes’.
Error in sample (line 8)
clear all
Error in dynare (line 271)
evalin(‘base’,fname) ;
Error in sample_plot (line 4)
dynare sample.mod

Could you please help me to solve this problem about messages “Reference to non-existent field ‘ghx’.”, “Cannot redefine class ‘dates’ without a call to ‘clear classes’.”?

The second problem is a path conflict between 4.5 and 4.6. Due to the dates-module now working differently, you have to restart Matlab when you switch between Dynare versions.

When you type resid into the command windows after the crash, you will see the two problematic equations:

Residuals of the static equations:
Equation number 1 : 1
Equation number 2 : -0.66809
Equation number 3 : 0
Equation number 4 : 0
Equation number 5 : 0
Equation number 6 : 0
Equation number 7 : 0
Equation number 8 : 0
Equation number 9 : 0
Equation number 10 : 0
Equation number 11 : 0
Equation number 12 : 0
Equation number 13 : 0
Equation number 14 : 0
Equation number 15 : 0
Equation number 16 : 0
Equation number 17 : 0
Equation number 18 : 0
Equation number 19 : 0
Equation number 20 : 0
Equation number 21 : 0
Equation number 22 : 0
Equation number 23 : 0
Equation number 24 : 0
Equation number 25 : 0
Equation number 26 : 0
Equation number 27 : 0
Equation number 28 : 0
Equation number 29 : 0
Equation number 30 : 0
Equation number 31 : 0
Equation number 32 : 0
Equation number 33 : 0
Equation number 34 : 0
Equation number 35 : 0
Equation number 36 : 0
Equation number 37 : 0
Equation number 38 : 0
Equation number 39 : 0
Equation number 40 : 0

The first message comes from not having a semicolon at the end of the line. It is not a warning or an error.

You can get the correct Ramsey policy at second order. But what is not yet implemented is the evaluation of the planner_objective. The values reported are still only valid at first order.

No, because you did not specify any approximation order.

Set order=2.

Yes, that should work.

What does not work, as indicated above, is using the oo_.planner_objective provided at second order. But in your code above, you compute welfare analytically based on the variance of the endogenous variables. That works.

I was reading through many of the Ramsey-posts and also the documentation. So, as I understand, it is a relatively new feature, that the order=2 option can be used, as it is not documented yet (see https://github.com/DynareTeam/dynare/pull/872/files).

If I can make a suggestion, I think the explanations in lines 6725ff are not entirely clear. Yes, the Dynare command ramsey_policy with order=1 should not be confused with the LQ approach. However, I think that for the order=1 option it is not necessarily true that “the second order terms that are required for a second-order correct welfare evaluation are preserved.” (as it is stated in lines 6731f). This is at least how I understand SGU (2007, p. 1704) where they state that “any plausible departure from the set of simplifying assumptions … would require approx. the equilibrium conditions to second order.” And this is probably also the reason why the order=2 option was implemented in Dynare?

Does the order=2 feature also help with the problem discussed here Ramsey policy is not optimal, i.e., the problem of the distorted steady state?

What does it mean “what is not yet implemented is the evaluation of the planner_objective . The values reported are still only valid at first order.”? That I cannot not get the 2nd order welfare for Ramsey policy, i.e., that I cannot conduct an analysis of the welfare losses from using optimal simple rules instead as in SGU (2007)?
petiteelf writes
welf = -(1/(1-beta))C_ssPhi_l*(eta/2)*L_ss^(eta-1)oo_.var(2,2);
and jpfeifer replies to that “in your code above, you compute welfare analytically based on the variance of the endogenous variables”.
I see that (1/(1-beta))C_ssPhi_l(eta/2)*L_ss^(eta-1) is the steady state of welfare. But which variance is oo_.var(2,2)? And which kind of welfare would be calculated here? Unconditional?

I have to look deeper into this. It is still on my to-do list. I am also not sure about that description, but it was based on discussions with @MichelJuillard Maybe he has something to add. My current understanding is that with a distorted steady state, you need order=2

Yes, order=2 helps here.

Yes, the problem is that the policy computed at order=2 is indeed the optimal one, but that the planner objective values reported are not the full second-order approximation. What @petiteelf did above was manually compute the required second-order approximation to the welfare function and then taking unconditional expectations. This results in the variances of the variables entering the welfare function showing up. The welfare measure then is unconditional welfare.

@jojokre I found one post that contains this welfare expression, though I don’t know the exact derivation. Full.mod (5.5 KB) (last few lines). Or you can give me some hints