# Ramsey policy(two instruments)

**URL:** <https://forum.dynare.org/t/ramsey-policy-two-instruments/11795>\
**Category:** Optimal Policy\
**Created:** [6 May 2018 06:30 UTC](https://forum.dynare.org/t/ramsey-policy-two-instruments/11795 "2018-05-06T06:30:24Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![petiteelf](https://forum.dynare.org/letter_avatar_proxy/v4/letter/p/bc8723/32.png) [@petiteelf](https://forum.dynare.org/u/petiteelf)\
**Post date:** [6 May 2018 06:30 UTC](https://forum.dynare.org/t/ramsey-policy-two-instruments/11795/1 "2018-05-06T06:30:24Z")

</div>

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’.”?

Thanks  
Esther

---

<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 May 2018 11:37 UTC](https://forum.dynare.org/t/ramsey-policy-two-instruments/11795/2 "2018-05-06T11:37:33Z")

</div>

1. For the first one, I would need to see the codes.
2. 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.

---

<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:** [10 May 2018 10:43 UTC](https://forum.dynare.org/t/ramsey-policy-two-instruments/11795/5 "2018-05-10T10:43:37Z")

</div>

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

```auto
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

```

---

<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:** [10 May 2018 12:15 UTC](https://forum.dynare.org/t/ramsey-policy-two-instruments/11795/7 "2018-05-10T12:15:39Z")

</div>

1. Dynare 4.4.3 had a bug that allowed accepting incorrect steady state files with Ramsey.
2. Yes, you should focus on the first two equations in the mod-file. They are not solved given the steady state file.

---

<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:** [15 May 2018 18:33 UTC](https://forum.dynare.org/t/ramsey-policy-two-instruments/11795/10 "2018-05-15T18:33:12Z")

</div>

1. The first message comes from not having a semicolon at the end of the line. It is not a warning or an error.
2. 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.

---

<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:** [23 May 2018 20:41 UTC](https://forum.dynare.org/t/ramsey-policy-two-instruments/11795/12 "2018-05-23T20:41:57Z")

</div>

1. No, because you did not specify any approximation order.
2. Set `order=2`.
3. Yes, that should work.
4. 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.

---

<div class="post-metadata">

**Author:** ![jojokre](https://forum.dynare.org/letter_avatar_proxy/v4/letter/j/d2c977/32.png) [@jojokre](https://forum.dynare.org/u/jojokre)\
**Post date:** [9 September 2018 22:36 UTC](https://forum.dynare.org/t/ramsey-policy-two-instruments/11795/13 "2018-09-09T22:36:12Z")

</div>

Dear Johannes,

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](https://github.com/DynareTeam/dynare/pull/872/files)).

1. 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?

2. Does the order=2 feature also help with the problem discussed here [Ramsey policy is not optimal](https://forum.dynare.org/t/ramsey-policy-is-not-optimal/5860/1), i.e., the problem of the distorted steady state?

3. 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\_ss_Phi\_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?

Thank you very much for clarification!

---

<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:** [13 September 2018 09:22 UTC](https://forum.dynare.org/t/ramsey-policy-two-instruments/11795/14 "2018-09-13T09:22:52Z")

</div>

Let me try to clarify this:

1. 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`
2. Yes, `order=2` helps here.
3. 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.

---

<div class="post-metadata">

**Author:** ![HelloDynare](https://forum.dynare.org/user_avatar/forum.dynare.org/hellodynare/32/12107_2.png) [@HelloDynare](https://forum.dynare.org/u/HelloDynare)\
**Post date:** [6 May 2020 14:33 UTC](https://forum.dynare.org/t/ramsey-policy-two-instruments/11795/15 "2020-05-06T14:33:56Z")

</div>

> [@jojokre](#):
>
> petiteelf writes  
> welf = -(1/(1-beta)) _C\_ss_ Phi\_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\_ss Phi\_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?

@jojokre I found one post that contains this welfare expression, though I don’t know the exact derivation. [Full.mod](https://forum.dynare.org/uploads/short-url/qcAXqbnj3o0Wxm5105cV7RlcfxX.mod) (5.5 KB) (last few lines). Or you can give me some hints 🙂

> [@Question about welfare calculation in a JME paper](https://forum.dynare.org/t/question-about-welfare-calculation-in-a-jme-paper/5981):
>
> Dear all, I am confused on the calculation method in the paper of “Capital controls and optimal Chinese monetary policy“， which is published on JME 2015. Here I attach the DYNARE CODE and the paper downloaded from the author’s website. And the key part of the code is below: planner\_objective(C + log(C\_ss) - (Phi\_l\*L\_ss^(1+eta)/(1+eta))\*exp((1+eta)\*L)); ramsey\_policy(planner\_discount=1, nograph, noprint, irf=20, periods=1000, instruments=(R)); welf = -(1/(1-beta))\*C\_ss\*Phi\_l\*(eta/2)\*L\_ss^(eta…

---

<div class="post-metadata">

**Author:** ![mbf2020](https://forum.dynare.org/letter_avatar_proxy/v4/letter/m/ecccb3/32.png) [@mbf2020](https://forum.dynare.org/u/mbf2020)\
**Post date:** [10 May 2024 06:02 UTC](https://forum.dynare.org/t/ramsey-policy-two-instruments/11795/16 "2024-05-10T06:02:41Z")

</div>

Hi Pfeifer, i have same trouble about these mod file from author’s website, could you fix them? Thks a lot.

---

<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:** [10 May 2024 07:38 UTC](https://forum.dynare.org/t/ramsey-policy-two-instruments/11795/17 "2024-05-10T07:38:39Z")

</div>

What exactly is your problem?

---

<div class="post-metadata">

**Author:** ![mbf2020](https://forum.dynare.org/letter_avatar_proxy/v4/letter/m/ecccb3/32.png) [@mbf2020](https://forum.dynare.org/u/mbf2020)\
**Post date:** [10 May 2024 09:44 UTC](https://forum.dynare.org/t/ramsey-policy-two-instruments/11795/18 "2024-05-10T09:44:24Z")

</div>

1st question is how to debug this mod. when i try to run this mod, a lot of erros. how to use this mod to compare ramsey welfare gains.  
[kitanotakaku.mod](https://forum.dynare.org/uploads/short-url/7WEq7wNjsBHwzL3etclQcv3TAG8.mod) (2.9 KB)  
[kitanotakaku\_steadystate.m](https://forum.dynare.org/uploads/short-url/sLODsjSE2fKbfEFPjaf70OVeGHl.m) (1.0 KB)

[Kitanu Takaku - Capital Controls and Monetary Policy in a Small Open Economy.pdf](https://forum.dynare.org/uploads/short-url/5yBIH2W964mEy0SzbQrCBDlJgx6.pdf) (228.5 KB)

 ![image](https://forum.dynare.org/uploads/default/original/3X/5/4/544b086599c7496bfe5763fc683572d0e14faef0.png)

---

<div class="post-metadata">

**Author:** ![mbf2020](https://forum.dynare.org/letter_avatar_proxy/v4/letter/m/ecccb3/32.png) [@mbf2020](https://forum.dynare.org/u/mbf2020)\
**Post date:** [10 May 2024 09:53 UTC](https://forum.dynare.org/t/ramsey-policy-two-instruments/11795/19 "2024-05-10T09:53:25Z")

</div>

2nd question is another mod. Chang et al 2015 JME. when i run plot\_irf.m, there are similar error like this:  
**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\_);

[Bench.mod](https://forum.dynare.org/uploads/short-url/i4QArkpPBmKeRTLVVoYSvw9vZUk.mod) (5.4 KB)  
[calib.m](https://forum.dynare.org/uploads/short-url/rT6G8ydG2pUChmr5qSrSXZiWF2Y.m) (3.7 KB)  
[Flex.mod](https://forum.dynare.org/uploads/short-url/u1a03EgkUyz8lfTyqM2CzM8cS7E.mod) (5.4 KB)  
[Full.mod](https://forum.dynare.org/uploads/short-url/qcAXqbnj3o0Wxm5105cV7RlcfxX.mod) (5.5 KB)  
[Oca.mod](https://forum.dynare.org/uploads/short-url/7JVX1vMNTQE1hRdR9Ye78nNq6t9.mod) (5.5 KB)  
[plot\_irfs.m](https://forum.dynare.org/uploads/short-url/9u1nVDnjQqvdTOhKa8KiEn53tUU.m) (3.1 KB)  
[CLS\_Appendix.pdf](https://forum.dynare.org/uploads/short-url/wzXDHOBWc6yaKIShZZ7xxt4uUpJ.pdf) (269.1 KB)

[chang-liu-spiegel-capital-controls-optimal-chinese-monetary-policy.pdf](https://forum.dynare.org/uploads/short-url/jUbOfPLe61nwMPBe0Cy8hjARU3f.pdf) (567.5 KB)

 ![image](https://forum.dynare.org/uploads/default/original/3X/a/d/adaa5e175454f52e862e5e6c927e35360ede6cf7.png)  
 ![image](https://forum.dynare.org/uploads/default/original/3X/c/7/c788337c006018a08fce88c9bdef72a2bd4af6e5.png)

---

<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:** [10 May 2024 14:24 UTC](https://forum.dynare.org/t/ramsey-policy-two-instruments/11795/20 "2024-05-10T14:24:22Z")

</div>

Continue with the following file. You don’t need another steady state file [kitanotakaku2.mod](https://forum.dynare.org/uploads/short-url/kMyyGR2YHODURheaKDAxYLi0ccc.mod) (3.8 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:** [10 May 2024 14:29 UTC](https://forum.dynare.org/t/ramsey-policy-two-instruments/11795/21 "2024-05-10T14:29:15Z")

</div>

> [@mbf2020](#):
>
> 2nd question is another mod. Chang et al 2015 JME. when i run plot\_irf.m, there are similar error like this:

You should delete the `noprint` option. You will see there is a problem with the steady state provided in `Bench.mod`.

---

<div class="post-metadata">

**Author:** ![mbf2020](https://forum.dynare.org/letter_avatar_proxy/v4/letter/m/ecccb3/32.png) [@mbf2020](https://forum.dynare.org/u/mbf2020)\
**Post date:** [11 May 2024 07:09 UTC](https://forum.dynare.org/t/ramsey-policy-two-instruments/11795/22 "2024-05-11T07:09:45Z")

</div>

Thank you so much， Prof Pfeifer，I will follow your suggestion to fix it.

---

<div class="post-metadata">

**Author:** ![Dingx](https://forum.dynare.org/letter_avatar_proxy/v4/letter/d/ecccb3/32.png) [@Dingx](https://forum.dynare.org/u/Dingx)\
**Post date:** [26 March 2025 07:26 UTC](https://forum.dynare.org/t/ramsey-policy-two-instruments/11795/23 "2025-03-26T07:26:11Z")

</div>

Hello, Prof Pfeifer. I have questions about trying to replicate Chang et al. 's 2015 JME. I use Dynare 6.0 version, so I modified the code. I got different residuals from the previous post. I am confused and I wonder if you can provide some debugging suggestions? I cannot upload the calib.m for some bugs in this website. Please consider the file from @mbf2020  
[Bench.mod](https://forum.dynare.org/uploads/short-url/d1M1AQthIVpu0qqJAS8uxvtZtmy.mod) (5.4 KB)

 ![Residual|attachment](https://forum.dynare.org/uploads/default/original/3X/3/4/347185bd1d2602d83f10e36d55df71a8d3b940f6.png)

---

<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:** [28 March 2025 10:11 UTC](https://forum.dynare.org/t/ramsey-policy-two-instruments/11795/24 "2025-03-28T10:11:37Z")

</div>

Can you please upload a zip-file with everything that is required to reproduce the problem.

---

<div class="post-metadata">

**Author:** ![Dingx](https://forum.dynare.org/letter_avatar_proxy/v4/letter/d/ecccb3/32.png) [@Dingx](https://forum.dynare.org/u/Dingx)\
**Post date:** [29 March 2025 23:05 UTC](https://forum.dynare.org/t/ramsey-policy-two-instruments/11795/26 "2025-03-29T23:05:56Z")

</div>

Hello, Prof Pfeifer. I fix the equation with residuals by log linearizing and now they are all 0, but I don’t know why they start with 28. Besides, when I use ramsey\_model, it returns Ramsey: The maximum number of iterations has been reached. Try increasing maxit.. I notice that the model has 27 variables and 26 equations, because R should be decided based on Ramsey optimality. Thus, I want to ask what part shall I change so that this model can run?  
[replication.zip](https://forum.dynare.org/uploads/short-url/axBD8DwKoAReaUG59yZXo4cqWbP.zip) (4.9 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:** [31 March 2025 13:06 UTC](https://forum.dynare.org/t/ramsey-policy-two-instruments/11795/27 "2025-03-31T13:06:23Z")

</div>

Your steady state finding approach is wrong. It is the planner’s job to find the optimal interest rate and all other variables are chosen conditional on that value. Thus, in a steady state, the planner chooses interest rate. But you set parameters and steady state assuming a preset value of the interest rate in steady state.

[Next page](https://forum.dynare.org/t/ramsey-policy-two-instruments/11795.md?page=2)
