# Ramsey Policy

**URL:** https://forum.dynare.org/t/ramsey-policy/5447
**Category:** Optimal Policy
**Created:** [16 April 2016 13:59 UTC](https://forum.dynare.org/t/ramsey-policy/5447 "2016-04-16T13:59:42Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![jd1090](https://forum.dynare.org/user_avatar/forum.dynare.org/jd1090/32/5086_2.png) [@jd1090](https://forum.dynare.org/u/jd1090)
#### Post date: [16 April 2016 13:59 UTC](https://forum.dynare.org/t/ramsey-policy/5447/1 "2016-04-16T13:59:42Z")

</div>

Hi,

I’m trying to work out how to run the Ramsey\_Policy in dynare. The problem that I am having is that I do not quite understand what it means to specify the steady state of the model CONDITIONAL on the instruments used. I tried to follow the Michel Juillard’s set of notes and implement his example (see attached file).

The code for a generic model provided in the notes is as follows:

[code]var pai, c, n, r, a;  
varexo u;  
parameters beta, rho, epsilon, omega, phi, gamma;

beta=0.99;  
gamma=3;  
omega=17;  
epsilon=8;  
phi=1;  
rho=0.95;  
model;  
a = rho_a(-1)+u;  
1/c = beta_r/(c(+1)_pai(+1));  
pai_(pai-1)/c = beta_pai(+1)_(pai(+1)-1)/c(+1)+epsilon_phi_n^(gamma+1)/omega-exp(a)_n_(epsilon-1)/(omega\*c);  
exp(a)_n = c+(omega/2)_(pai-1)^2;  
end;  
initval;  
r=1;  
end;

steady\_state\_model;  
a = 0;  
pai = beta_r;  
c = find\_c(0.96,pai,beta,epsilon,phi,gamma,omega);  
n = c+(omega/2)_(pai-1)^2;  
end;  
shocks;  
var u; stderr 0.008;  
end;

planner\_objective(ln©-phi\*((n^(1+gamma))/(1+gamma)));  
ramsey\_policy(planner\_discount=0.99,order=1,instruments=®);

function c = find\_c(c0,pai,beta,epsilon,phi,gamma,omega)  
c = csolve(@nk\_ss,c0,],1e-8,100,pai,beta,epsilon,phi,gamma,omega);  
function r = nk\_ss(c,pai,beta,epsilon,phi,gamma,omega)  
r = pai\*(pai-1)/c - beta_pai_(pai-1)/c-epsilon_phi_(c+(omega/2)_(pai-1)^2)^(gamma+1)/omega+(c+(omega/2)_(pai-1)^2)_(epsilon-1)/(omega_c);[/code]

The problem is that dynare does not recognise the command @nk\_ss and the code cannot be implemented (see error message below) even if I name the .mod file as nk\_ss:

Starting Dynare (version 4.4.3).  
Starting preprocessing of the model file …  
ERROR: nk\_ss.mod: line 35, col 12: character unrecognized by lexer

Error using dynare (line 174)  
DYNARE: preprocessing failed

I have read the dynare manual and I understand that you need to omit he Taylor rule in the model (if it applies), that commands “steady” are incompatible with ramsey\_policy, I know how the policy objective is specified and what the ramsey\_policy options are. The only thing I do not understand is how the steady state has to be specified (hence the example above cannot be implemented, and I am using unstable version of dynare 4.4.3). I tried looking into other topics on similar issues, but running my model with just initval doesn’t work. Then specifying the instrument in the initval, whereas the rest of the model in steady\_state\_model block leads to singularity (as in other topics here). So I could really use some help in trying to find these conditional steady states, because I am sure that this is the root of all problems. There isn’t a lot of material out there. Andy Levin’s codes are also outdated and don’t work on recent versions of Dynare.

Thank you.  
[nk\_ss.mod](https://forum.dynare.org/uploads/default/original/2X/1/17700649fda36191f41991e7cab3790e06aea288.mod) (993 Bytes)  
[Ramsey Policy.pdf](https://forum.dynare.org/uploads/default/original/2X/e/e3f1f0ff7fce1498cedd3883f9eeed11236218d7.pdf) (175 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: [18 April 2016 20:48 UTC](https://forum.dynare.org/t/ramsey-policy/5447/2 "2016-04-18T20:48:30Z")

</div>

You can find an example here: [github.com/DynareTeam/dynare/blob/master/tests/optimal\_policy/Ramsey/ramsey\_ex.mod](https://github.com/DynareTeam/dynare/blob/master/tests/optimal_policy/Ramsey/ramsey_ex.mod). The find\_c.m file you also need in the same folder is at [github.com/DynareTeam/dynare/blob/master/tests/optimal\_policy/Ramsey/find\_c.m](https://github.com/DynareTeam/dynare/blob/master/tests/optimal_policy/Ramsey/find_c.m)  
r is declared as an instrument. Given any value of the instrument entered to the steady\_state\_model-block, an analytical steady state is provided. If you want, you can implement something similar within a proper steady state file. An example here is the NK\_baseline.mod in the Dynare examples folder. Note that you should use the current unstable version (soon to be 4.5) for Ramsey with instruments as several bugs related to this have been fixed.

---

<div class="post-metadata">

### Author: ![jd1090](https://forum.dynare.org/user_avatar/forum.dynare.org/jd1090/32/5086_2.png) [@jd1090](https://forum.dynare.org/u/jd1090)
#### Post date: [21 April 2016 13:02 UTC](https://forum.dynare.org/t/ramsey-policy/5447/3 "2016-04-21T13:02:26Z")

</div>

Following your guidance, I can now run the example without any problems. However, I still don’t think I quite understand what the software is doing, because I can’t apply it to any other models (I always get an error message that says either “too many input arguments” or “not enough input arguments”).

The way I understand it is as follows. The line in the steady\_state\_model block of the mod file

```auto

```

Returns a non-zero value for c, which is found numerically from the find\_c.m file. This is done because the steady state value of the instrument r is ex ante not known and thus the analytical solution to the steady state of c is not possible. Then the find\_c.m file has the following:

```auto
function c = find_c(c0,pai,beta,epsilon,phi,gamma,omega)
c = csolve(@nk_ss,c0,],1e-8,100,pai,beta,epsilon,phi,gamma,omega);
end

function r = nk_ss(c,pai,beta,epsilon,phi,gamma,omega)
r = pai*(pai-1)/c - beta*pai*(pai-1)/c-epsilon*phi*(c+(omega/2)*(pai-1)^2)^(gamma+1)/omega +(c+(omega/2)*(pai-1)^2)*(epsilon-1)/(omega*c);
end
```

Where c0 is the initial value (=0.96 in the mod file). The next part is less clear. The arguments inside find\_c, are they ALL the model parameters (except for technological progress persistence) or are they only the parameters that would affect c from equation 3?

```auto

```

Why is one of the endogenous variables (i.e. pai) in the find\_c function? Is it because the steady state value of pai directly depends on the value of the instrument and it is recursively used in the steady state of c?

Then in the second line where csolve is used

```auto
c=csolve(@nk_ss,c0,],1e-8,100....
```

@nk\_ss applies some sort of numerical optimisation algorithm (does @ indicate a model local variable?), where c0 is the initial value, ] specifies the gradient, 1e-8 is the terminal condition (i.e. ad hoc value for when the gradient is sufficiently small) and 100 is the maximum number of iterations to be used. So, the values of (ALL?) the model parameters are specified at this step because they influence the value of the steady state of c?

Then the last part is specifying the instrument:

```auto
r = nk_ss(c,pai,beta,epsilon,phi,gamma,omega)
```

Again, I’m not sure what nk\_ss stands for so I can only guess that its a numerical optimisation algorithm (some sort of “FUN” from dynare internals). Why does the value of c or anything else enter the specification of nk\_ss (its important to know if it is to be applied in other contexts)? And is this the policy makers constraint (which is the recursive solution of equation 3 equated to the value of the instrument)?:

```auto
r = pai*(pai-1)/c - beta*pai*(pai-1)/c-epsilon*phi*(c+(omega/2)*(pai-1)^2)^(gamma+1)/omega +(c+(omega/2)*(pai-1)^2)*(epsilon-1)/(omega*c);
```

As always, thank you very much for the help and support.

---

<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: [21 April 2016 18:55 UTC](https://forum.dynare.org/t/ramsey-policy/5447/4 "2016-04-21T18:55:47Z")

</div>

A steady state file is always recursive as you solve for one variable after another. We have

`a = 0;
pai = beta*r;
c = find_c(0.96,pai,beta,epsilon,phi,gamma,omega);
n = c+(omega/2)*(pai-1)^2;`  
That is, we first find the steady state for a, then for pai, then for c, and last for n. That is the reason we can use pai when solving for c. As you can see, the value for pai is therefore handed over to the find\_c.m function.  
The problem with the model is that even if you know the value of the instrument, the particular nonlinear structure of the model makes it impossible to solve for c. You need to use a root finder for this. The function find\_c does exactly this. Given the value of pai and the values of the parameter appearing in the consumption equation after substituting out labor (therefore there is no need to pass all parameters), we search for the root of this equation.  
Looking at the find\_c.m file, you can see that it contains a nested function `nk_ss` in line 5 following. This function could have been a separate m-file, but here it is nested. This function computes the residual of the consumption FOC after labor has been substituted out. That is, with the correct value for consumption, the residual will be 0. That is what is done with csolve: starting with c0 find the value that returns a zero residual. The @ is used by Matlab to create a function handle, i.e. tell the solver that nk\_ss is the function we need to solve.

---

<div class="post-metadata">

### Author: ![jd1090](https://forum.dynare.org/user_avatar/forum.dynare.org/jd1090/32/5086_2.png) [@jd1090](https://forum.dynare.org/u/jd1090)
#### Post date: [24 April 2016 12:38 UTC](https://forum.dynare.org/t/ramsey-policy/5447/5 "2016-04-24T12:38:25Z")

</div>

I think I understand the find\_ and nk\_ss commands better now. I applied similar logic to my model, but I think I ran into a similar problem as in this topic: [[Problems with Ramsey policy](http://forum.dynare.org/t/problems-with-ramsey-policy/4003/1)).

Please see the code attached to this message. I specify the nominal interest rate (r) as an instrument, which appears in the stochastic discount factor (LAMBDA). The CPI inflation (PI\_CPI) is thus a function of LAMBDA and beta (the time invariant discount factor), which must be obtained using find\_ command:

`function PI_CPI = find_PI_CPI(PI_CPI0, LAMBDA, beta)
PI_CPI = csolve(@nk_ss,PI_CPI0,],1e-8,100, LAMBDA, beta);
end`

Then I specify the function for the residuals of the instrument (i.e. the Euler equation):

`function r = nk_ss(PI_CPI, LAMBDA, beta)
r = (PI_CPI*LAMBDA)/beta;
end`

The steady\_state\_model block is solved recursively and it is conditional on the instrument value. However, when I run the code I obtain quite a number of rank deficiency warnings such as:

[code]Warning: Rank deficient, rank = 0, tol = NaN.

> In dyn\_ramsey\_static\_dyn\_ramsey\_static\_1 (line 152)  
> In dyn\_ramsey\_static\>@(x)dyn\_ramsey\_static\_1(x,M,options\_,oo) (line 40)  
> In csolve (line 112)  
> In dyn\_ramsey\_static (line 55)  
> In evaluate\_steady\_state (line 55)  
> In resol (line 104)  
> In stoch\_simul (line 88)  
> In ramsey\_policy (line 25)  
> In FINOP\_RAMSEY (line 650)  
> In dynare (line 180) [/code]

Until Matlab stops and gives another error at the end:

`Attempted to access ys_(50); index out of bounds because numel(ys_)=40.
Error in FINOP_RAMSEY_steadystate2 (line 44)
ys_(80)=ys_(50)*(-(ys_(18)*1/(ys_(26)*ys_(15))));
Error in evaluate_steady_state_file (line 54)
        [ys,params1,check] = h_steadystate(ys_init, exo_ss, params);
Error in dyn_ramsey_static (line 61)
    [xx,params,check] = evaluate_steady_state_file(ys,exo_ss,M,options_);
Error in evaluate_steady_state (line 55)
        [ys,params] = dyn_ramsey_static(ys_init,M,options,oo);
Error in resol (line 104)
[dr.ys,M.params,info] = evaluate_steady_state(oo.steady_state,M,options,oo,0);
Error in stoch_simul (line 88)
    [oo_.dr,info,M_,options_,oo_] = resol(0,M_,options_,oo_);
Error in ramsey_policy (line 25)
info = stoch_simul(var_list);
Error in FINOP_RAMSEY (line 650)
ramsey_policy(var_list_);
Error in dynare (line 180)
evalin('base',fname) `

Hence, there are only 40 equation in the model, so ys(50) and ys(80) are auxiliary equations (as the steady state file suggests). There should not be any division by zero. I can run the model smoothly using different versions of Taylor rules with various parameter specifications. Is there still something wrong with the way I specify the steady state?

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: [25 April 2016 08:37 UTC](https://forum.dynare.org/t/ramsey-policy/5447/6 "2016-04-25T08:37:52Z")

</div>

Please use the current unstable version of Dynare, where a bug related to auxiliary variables when using instruments has been fixed. There you will get

[quote]evaluate\_steady\_state: The steady state file computation for the Ramsey problem resulted in NaNs.  
evaluate\_steady\_state: The steady state was computed conditional on the following initial instrument values:  
r 1.000000  
evaluate\_steady\_state: The problem occured in the following equations:  
Equation(s): 1, 2, 3, 4, 5, 6, 7, 10, 11, 14, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 30, 31, 32, 33, 34, 35, 38, 40,  
evaluate\_steady\_state: If those initial values are not admissable, change them using an initval-block.[/quote]

I manually executed the parameter definitions, the setting of r and then the equations in the steady\_state\_model-block using F9 in Matlab. I turns out that your steady state file is not properly recursive. You use

`PHI2=(Y*UC)/(1-pi*beta*(PI_CPI^(varepsilon-1)));
PHI1=((Y*UC)/(1-pi*beta*(PI_CPI^(varepsilon))))*(varepsilon/(varepsilon-1))*MC;
`  
but Y is only define later.

---

<div class="post-metadata">

### Author: ![jd1090](https://forum.dynare.org/user_avatar/forum.dynare.org/jd1090/32/5086_2.png) [@jd1090](https://forum.dynare.org/u/jd1090)
#### Post date: [25 April 2016 09:46 UTC](https://forum.dynare.org/t/ramsey-policy/5447/7 "2016-04-25T09:46:11Z")

</div>

Thanks for the prompt response. I have now fixed the steady state block.

I am using the current unstable version of dynare for windows (i.e. dynare 2016-04-24 downloaded from here:[dynare.org/snapshot/windows-zip/](http://www.dynare.org/snapshot/windows-zip/)).

I’m not sure if that’s a problem but I also have the unstable 4.4.3 in the C drive. It used to be ok to have different versions simultaneously. I set the path in the folder of the most recent dynare version on the site.

I execute the parameter values, the instrument and the steady state model equations in this precise order using F9.

I then run dynare FINOP\_RAMSEY.mod in the command window and get an identical outcome (i.e. lots of warnings and eventually the auxiliary variable problem).

Any further comments are greatly appreciated.

P.S. Apologies for the incompetence.

---

<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: [25 April 2016 11:42 UTC](https://forum.dynare.org/t/ramsey-policy/5447/8 "2016-04-25T11:42:23Z")

</div>

Check that you are using the correct version. The preprocessor should show

[quote]dynare FINOP\_RAMSEY

Configuring Dynare …  
[mex] Generalized QZ.  
[mex] Sylvester equation solution.  
[mex] Kronecker products.  
[mex] Sparse kronecker products.  
[mex] Local state space iteration (second order).  
[mex] Bytecode evaluation.  
[mex] k-order perturbation solver.  
[mex] k-order solution simulation.  
[mex] Quasi Monte-Carlo sequence (Sobol).  
[mex] Markov Switching SBVAR.

Using 64-bit preprocessor  
Starting Dynare (version 2016-04-16).[/quote]

If the last line above says 4.4.3 then you are using the wrong path. I now get

[quote]evaluate\_steady\_state: The steady state file does not solve the steady state for the Ramsey problem.  
evaluate\_steady\_state: Conditional on the following instrument values:  
r 1.000000  
evaluate\_steady\_state: the following equations have non-zero residuals:  
Equation number 3: -2900105745041947900000.000000  
Equation number 10: 6117457973423583000000.000000  
Equation number 11: -4.324949  
Equation number 14: 7.785978  
Equation number 16: -2.646347  
Equation number 21: 179102810608.442600  
Equation number 24: -76677505772.973389  
Equation number 29: -1.000000  
Equation number 31: -1.000000  
[/quote]

---

<div class="post-metadata">

### Author: ![jd1090](https://forum.dynare.org/user_avatar/forum.dynare.org/jd1090/32/5086_2.png) [@jd1090](https://forum.dynare.org/u/jd1090)
#### Post date: [25 April 2016 14:05 UTC](https://forum.dynare.org/t/ramsey-policy/5447/9 "2016-04-25T14:05:41Z")

</div>

Thanks. I uninstalled 4.4.3 and I managed to get to the same stage as you did. I will try to workout the steady state once more, since it appears that something is going horribly wrong.

Its strange given that it runs with alternative policy rules. I’m probably still making instinctive errors given that I’m used to solving everything in the context of a zero inflation steady state.

---

<div class="post-metadata">

### Author: ![jd1090](https://forum.dynare.org/user_avatar/forum.dynare.org/jd1090/32/5086_2.png) [@jd1090](https://forum.dynare.org/u/jd1090)
#### Post date: [27 April 2016 13:54 UTC](https://forum.dynare.org/t/ramsey-policy/5447/10 "2016-04-27T13:54:12Z")

</div>

So I managed to resolve most of the abnormalities in the steady state, but I find it hard to grind out this last step which is to do with the residual in the Euler equation:

`evaluate_steady_state: The steady state file does not solve the steady state for the Ramsey problem.
evaluate_steady_state: Conditional on the following instrument values: 
	 r 0.010050 
evaluate_steady_state: the following equations have non-zero residuals: 
	 Equation number 16: -1.000000
	 Equation number 29: -1.000000`

`PI_CPI(+1)=beta*(UC(+1)/UC)*(1/LAMBDA); //(16) EULER EQUATION
PI_CPI=CPI/CPI(-1); //(29) CPI INFLATION IDENTITY
`

Where the instrument r=-log(beta)=~0.010050. The steady state of LAMBDA when r=-log(beta) is equal to beta itself and by definition UC(+1)=UC in the steady state, so I don’t see what could be wrong.

As usual, the files are attached below. 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: [28 April 2016 09:05 UTC](https://forum.dynare.org/t/ramsey-policy/5447/11 "2016-04-28T09:05:27Z")

</div>

Sidenote: I am not sure what you are doing. It seems the function you are solving numerically can be easily solved for inflation. So why do you use solver?  
Now to the problem:  
You have the function

`r = (PI_CPI*LAMBDA)/beta;
`  
you want to solve. Setting r=0, we see that PI\_CPI=0 is the solution. But

```auto

```

implies that

```auto

```

in steady state

---

<div class="post-metadata">

### Author: ![jd1090](https://forum.dynare.org/user_avatar/forum.dynare.org/jd1090/32/5086_2.png) [@jd1090](https://forum.dynare.org/u/jd1090)
#### Post date: [3 May 2016 08:59 UTC](https://forum.dynare.org/t/ramsey-policy/5447/12 "2016-05-03T08:59:42Z")

</div>

Well the reason I used csolve to begin with was because the example above used it and I wasn’t sure what it meant to specify the steady state conditional on the instruments. I thought that it was the only way, but I suppose the only reason it was used in the example was because there are multiple steady states of inflation unlike in my model.

I now realise that I don’t need the find\_ file at all, but the initial value of the instrument must be very precise for dynare to solve for the steady state of the model. That is, initval r=-log(beta)=0.010050 does not solve the model and gives rise to small residuals:

`evaluate_steady_state: The steady state for the Ramsey problem could not be computed.
evaluate_steady_state: The steady state computation stopped with the following instrument values:: 
	 r 0.010050 
evaluate_steady_state: The following equations have non-zero residuals: 
	 Equation number 17: -0.000079
	 Equation number 26: 0.000114
	 Equation number 29: -0.000171
	 Equation number 30: -0.000040`

but r=-log(beta)=0.01005033585 does solve the model, because it is more accurate. However, to make it even more ironic, I am now struggling with the Blanchard Kahn conditions.

[code]Error using print\_info (line 42)  
Blanchard Kahn conditions are not satisfied: no stable equilibrium

Error in stoch\_simul (line 94)  
print\_info(info, options\_.noprint, options\_);

Error in ramsey\_policy (line 25)  
info = stoch\_simul(var\_list);

Error in FINOP\_RAMSEY (line 660)  
ramsey\_policy(var\_list\_);

Error in dynare (line 223)  
evalin(‘base’,fname) ;[/code]

Which really puzzles me, because the model runs smoothly with other Taylor rules (the IRFs look smooth and non-oscillating). Is there anything in particular that I should keep in my when running ramsey\_policy with regard to the time subscripts or predetermined variables that would otherwise not be a problem?

---

<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 2016 08:11 UTC](https://forum.dynare.org/t/ramsey-policy/5447/13 "2016-05-06T08:11:49Z")

</div>

First off,

> [@](#):
>
> initval r=-log(beta)=0.010050 does not solve the model and gives rise to small residuals

makes no sense. You are providing a steady state condition on the value of the instruments. Thus, it must work for any instrument! If it doesn’t, you are not taking the value of the instrument correctly into account. When you change the planner discount factor, your steady state file suddenly does not work anymore.

Regarding timing: the same rules apply as for stoch\_simul. My guess is that there is an economic reason for the error message.

---

<div class="post-metadata">

### Author: ![jd1090](https://forum.dynare.org/user_avatar/forum.dynare.org/jd1090/32/5086_2.png) [@jd1090](https://forum.dynare.org/u/jd1090)
#### Post date: [7 May 2016 15:47 UTC](https://forum.dynare.org/t/ramsey-policy/5447/14 "2016-05-07T15:47:17Z")

</div>

You may be right that my model contains an economic problem (I cannot guarantee that). For this reason, I took the most well known open economy framework (Gali & Monacelli(2005)) and wrote the mod file for the non-linear version of the model (i.e. I do not log-linearise by hand). I also include capital and define the net exports in a slightly different way, but these changes make no real difference to the end result. There are no further frictions.

I also wrote the .tex file (see pdf below and .tex code at the very bottom) with all the equilibrium conditions and detailed derivations of the conditional steady state. I suspect that the problem may arise do the misspecification of the price level steady state, but I’m not sure (which is why I keep pestering you on this blog post to begin with 🙂 ).

In this case, the error message is different:

[code]  
Warning: Rank deficient, rank = 0, tol = NaN.

> In dyn\_ramsey\_static\_dyn\_ramsey\_static\_1 (line 152)  
> In dyn\_ramsey\_static\>@(x)dyn\_ramsey\_static\_1(x,M,options\_,oo) (line 43)  
> In csolve (line 112)  
> In dyn\_ramsey\_static (line 58)  
> In evaluate\_steady\_state (line 120)  
> In resol (line 104)  
> In stoch\_simul (line 83)  
> In ramsey\_policy (line 25)  
> In GM\_2005 (line 542)  
> In dynare (line 223)

evaluate\_steady\_state: The steady state computation for the Ramsey problem resulted in NaNs.  
evaluate\_steady\_state: The steady state computation resulted in the following instrument values:  
i 0.010050  
evaluate\_steady\_state: The problem occured in the following equations:  
Equation(s): 1, 33, 34,  
Error using print\_info (line 140)  
Ramsey: The steady state computation resulted in NaN in the static first order conditions for optimal policy  
Error in stoch\_simul (line 94)  
print\_info(info, options\_.noprint, options\_);  
Error in ramsey\_policy (line 25)  
info = stoch\_simul(var\_list);  
Error in GM\_2008 (line 542)  
ramsey\_policy(var\_list\_);  
Error in dynare (line 223)  
evalin(‘base’,fname) ; [/code]

P.S. Apologies for yet another question on this, but this is really bothering me. Hopefully we can figure this out and you can put this example on github, so that others in the future would not have to struggle as much as I am.

> [@](#):
>
> \documentclass[11pt]{article}  
> \usepackage{amsmath, amssymb}  
> \usepackage{mathtools}  
> \usepackage{graphicx}  
> \usepackage{float}  
> \usepackage{natbib}  
> \bibliographystyle{agsm}  
> \begin{document}
> 
> \title{Running the Ramsey Policy on a Non-Linear\ Gali & Monacelli (2005) Model using Dynare}  
> \author{Justas Dainauskas\footnote{University of York, Department of Economics and Related Studies, Heslington, York, YO10 5DD, United Kingdom. E-Mail: [jd1090@york.ac.uk](mailto:jd1090@york.ac.uk)}}  
> \maketitle
> 
> \section{The Model}  
> Consider the ubiquitous \cite{GaliMonacelli(2005)} model of a small open economy in its non-linear form. The only real difference here is that the capital stock is present in the model and the dynamics of inflation are summarised in a recursive way similar to the \texttt{NK\_baseline.mod} in the dynare example folder. The trade balance is specified in a slightly different way, but it makes no real difference. There are no additional frictions introduced into the model and the notation used is consistent with \cite{GaliMonacelli(2005)} as much as possible, so all of the equilibrium conditions are standard:  
> \begin{equation}  
> Y\_t=C\_t+I\_t+NX\_t  
> \end{equation}  
> \begin{equation}  
> NX\_t=X\_t-M\_t  
> \end{equation}  
> \begin{equation}  
> X\_t=\alpha\left(\frac{P\_{H,t}}{E\_tP\_{F,t}}\right)^{-\eta}C\_t^\*  
> \end{equation}  
> \begin{equation}  
> M\_t=\alpha\left(\frac{E\_tP\_{F,t}}{P\_t}\right)^{-\eta}C\_t  
> \end{equation}  
> \begin{equation}  
> C\_{H,t}=(1-\alpha)\left(\frac{P\_{H,t}}{P\_{t}}\right)^{-\eta}C\_t  
> \end{equation}  
> \begin{equation}  
> C\_{F,t}=\alpha\left(\frac{E\_tP\_{F,t}}{P\_{t}}\right)^{-\eta}C\_t  
> \end{equation}  
> \begin{equation}  
> C\_t+I\_t+\mathbb{E}_t\left[D_{t+1} \mathit{\Lambda}_{t,t+1} \mathit{\Pi}_{t+1}\right]=\frac{D\_t}{P\_t}+\frac{W\_tN\_t}{P\_t}+\frac{R\_tK\_{t-1}}{P\_t}+\frac{\mathit{\Xi}_t}{P\_t}  
> \end{equation}  
> \begin{equation}  
> \mathit{\Xi}t=P{H,t}Y\_t-W\_tN\_t-R\_tK_{t-1}  
> \end{equation}  
> \begin{equation}  
> \mathbb{E}_t\left\mathit{\Lambda}_{t,t+1}\right]=\exp(-i\_t)  
> \end{equation}  
> \begin{equation}  
> \mathbb{E}_t\left\mathit{\Pi}_{t+1}\right]=\mathbb{E}_t\left\frac{P_{t+1}}{P\_t}\right]  
> \end{equation}  
> \begin{equation}  
> \frac{W\_t}{P\_t}=\frac{N^\varphi}{\mathbb{U}_{c,t}}  
> \end{equation}  
> \begin{equation}  
> \mathbb{U}_{c,t}=C^{-\sigma}  
> \end{equation}  
> \begin{equation}  
> \mathbb{E}_t\left\mathit{\Lambda}_{t,t+1}\mathit{\Pi}_{t+1}\right]=\beta\left\frac{\mathbb{U}_{c,t+1}}{\mathbb{U}_{c,t}}\right]  
> \end{equation}  
> \begin{equation}  
> \frac{R_{t+1}}{P\_{t+1}}=\mathbb{E}_t\left\left(\frac{\mathbb{U}_{c,t+1}}{\mathbb{U}_{c,t}}\right)\left(\frac{1}{\beta}-(1-\delta)\right)\right]  
> \end{equation}  
> \begin{equation}  
> Y=\frac{A\_tK_{t-1}^\gamma N\_t^{1-\gamma}}{\mathit{\Theta}_t}  
> \end{equation}  
> \begin{equation}  
> \frac{W\_t}{P\_t}=(1-\gamma)MC\_t\left(\frac{Y\_t}{N\_t}\right)  
> \end{equation}  
> \begin{equation}  
> \frac{R\_t}{P\_t}=\gamma MC\_t\left(\frac{Y\_t}{K_{t-1}}\right)  
> \end{equation}  
> \begin{equation}  
> K\_t=(1-\delta)K\_{t-1}+I\_t  
> \end{equation}  
> \begin{equation}  
> MC\_t=\frac{1}{P\_tA\_t}\left(\frac{R\_t}{\gamma}\right)^\gamma\left(\frac{W\_t}{1-\gamma}\right)^{1-\gamma}  
> \end{equation}  
> \begin{equation}  
> P\_{H,t}=\left(1-\pi),\hat{P}_{H,t}^{1-\varepsilon}+\pi,P_{H,t-1}^{1-\varepsilon}\right]^{\frac{1}{1-\varepsilon}}  
> \end{equation}  
> \begin{equation}  
> \hat{P}_{H,t}=\frac{P\_t \mathit{\Phi}_{t,1}}{\mathit{\Phi}_{t,1}}  
> \end{equation}  
> \begin{equation}  
> \mathit{\Phi}_{t,1}=\left(\frac{\varepsilon}{\varepsilon-1}\right)Y\_t \mathbb{U}_{c,t} MC_{t}+\theta\beta,\mathbb{E}_t \left\mathit{\Pi}_{t+1}^\varepsilon,\mathit{\Phi}_{t+1,1}\right]  
> \end{equation}  
> \begin{equation}  
> \mathit{\Phi}_{t,2}=Y\_t \mathbb{U}_{c,t}+\theta\beta,\mathbb{E}t\left\mathit{\Pi}{t+1}^{\varepsilon-1},\mathit{\Phi}_{t+1,2}\right]  
> \end{equation}  
> \begin{equation}  
> \mathit{\Theta}_{t}=\pi\mathit{\Pi}_{H,t}^\varepsilon\mathit{\Theta}_{t-1}+(1-\pi)\left(\frac{\widehat{P}_{H,t}}{P\_{t}}\right)^{-\varepsilon}  
> \end{equation}  
> \begin{equation}  
> \mathbb{E}_t\left\mathit{\Pi}_{H,t+1}\right]=\mathbb{E}_t\left\frac{P_{t+1}}{P\_t}\right]  
> \end{equation}  
> \begin{equation}  
> \mathbb{U}_{c,t}^=C^{ -\sigma}  
> \end{equation}  
> \begin{equation}  
> P\_t=\left(1-(1-\mu)\alpha),(P_{H,t})^{1-\eta}+(1-\mu)\alpha(P\_{F,t})^{1-\eta}\right]^{\frac{1}{1-\eta}}  
> \end{equation}  
> \begin{equation}  
> Q\_t=\frac{\mathbb{U}_{c,t}^\*}{\mathbb{U}_{c,t}}  
> \end{equation}  
> \begin{equation}  
> E\_t=\frac{Q\_t P\_t}{P\_{F,t}}  
> \end{equation}  
> \begin{equation}  
> \log(A\_t)=\rho\_a,\log(A\_{t-1})+e\_{a,t},,,,,,\rho\_a\in(0,1),,,,,,e\_{a,t} \sim,iid(0,\sigma\_{a}^2)  
> \end{equation}  
> \begin{equation}  
> \log(C\_t^_)=(1-\rho\_{c})\log(C)+\rho\_{c},\log(C\_{t-1}^_)+e\_{c,t},,,e\_{c,t} \sim,iid(0,\sigma\_{c}^2)  
> \end{equation}  
> And for non-Ramsey policy case, the single mandate Taylor rule:  
> \begin{equation}  
> i\_t=-\log(\beta)+\phi,\log(\mathit{\Pi}\_{t})  
> \end{equation}  
> Given the assumption that the policy \texttt{instrument} is i\_t and the \texttt{planner\_objective} is given by the CRRA preferences:  
> \begin{equation}  
> \frac{C\_t^{1-\sigma}}{1-\sigma}-\frac{N\_t^{1+\varphi}}{1+\varphi}  
> \end{equation}
> 
> \section{Conditional Steady State}  
> Derivations of the real variable steady state values must be conditional on the instrument used for the Ramsey policy, which is chosen to be the nominal interest rate i\_t. The nominal instrument affects the demand side of the economy via the Euler equation. Specifically, it is the reciprocal of the stochastic discount factor:  
> $$\mathit{\Lambda}=\exp(-i)$$  
> The stochastic discount factor affects the CPI inflation:  
> $$\mathit{\Pi}=\frac{\beta}{\mathit{\Lambda}}$$  
> The specification of the price levels is less clear, because the steady state must be consistent with any value of the instrument, which means that there may be non-zero inflation steady state. This implies that the price level is rising over time. For this reason, I specify the CPI level as equivalent to the CPI inflation rate (which implicitly assumes that the CPI level in the previous period is always equal to unity and I’m not sure how to specify this in any other way):  
> $$P\equiv\mathit{\Pi}$$  
> Then it follows that the real marginal costs of production must equal to the inverse mark-up:  
> $$MC=\frac{1}{PA}\left(\frac{R}{\zeta}\right)^\zeta\left(\frac{W}{(1-\zeta)}\right)^{1-\zeta}=\frac{\varepsilon-1}{\varepsilon}$$  
> $$\mathit{\Phi}_{1}=\mathit{\Phi}_{2}=\frac{Y C^{-\sigma}}{1-\mathit{\Pi}\pi\beta}$$  
> $$\widehat{P}_H=\frac{\mathit{P \Phi}_{1}}{\mathit{\Phi}\_{2}}\equiv \mathit{\Pi}$$  
> Then note that the trade balance holds in the steady state:  
> $$X=M=\alpha C\Rightarrow NX=0$$  
> Where the above follows from the symmetry of preferences and the consumption risk-sharing relationship:  
> $$Q=\left(\frac{C}{C^_}\right)^{\sigma}\equiv\frac{E P\_F}{P}=1 \Rightarrow C=C^_$$  
> Therefore the aggregate resource constraint is given by:  
> $$Y=C+I$$  
> Where aggregate investment is obtained from the capital accumulation equation:  
> $$I=\delta K$$  
> In order to find the market clearing steady state of capital stock, consider the demand and supply schedules of capital:  
> $$R=\frac{1-\beta(1-\delta)}{\beta}$$  
> $$R=\frac{\zeta MC Y}{K}\equiv \left(\frac{\varepsilon-1}{\varepsilon}\right)\frac{\zeta Y}{K}$$  
> Then solving the above two equations for capital stock gives:  
> $$K=\left\left(\frac{\varepsilon-1}{\varepsilon}\right)\left(\frac{\zeta\beta}{1-\beta(1-\delta)}\right)\right]Y\equiv\mathit{\Delta}\_1 Y$$  
> Then substitute the above into the production function and solve for output:  
> $$Y=K^\zeta N^{1-\zeta}\equiv N \mathit{\Delta}\_1^{\frac{\zeta}{1-\zeta}}$$  
> Then the aggregate investment is equivalent to:  
> $$I=\delta K=\delta \mathit{\Delta}\_1 Y= \delta N \mathit{\Delta}\_1^{\frac{1}{1-\zeta}}$$  
> Substituting out output and investment from the aggregate budget constraint identifies the steady state of aggregate consumption:  
> $$C=Y-I=N\left\mathit{\Delta}\_1^{\frac{\zeta}{1-\zeta}}+\delta \mathit{\Delta}\_1^{\frac{1}{1-\zeta}}\right]\equiv \mathit{\Delta}\_2 N$$  
> The labour demand schedules defines real wage:  
> $$\frac{W}{P}=\left(\frac{\varepsilon-1}{\varepsilon}\right)(1-\zeta)\mathit{\Delta}\_1^{\frac{\zeta}{1-\zeta}}$$  
> Thus the aggregate hours can therefore be identified from the inverse labour supply schedule:  
> $$\frac{W}{P}=N^\varphi C^\sigma$$  
> $$\Rightarrow \left(\frac{\varepsilon-1}{\varepsilon}\right)(1-\zeta)\mathit{\Delta}\_1^{\frac{\zeta}{1-\zeta}}=N^{\varphi+\sigma} \mathit{\Delta}\_2^\sigma$$  
> $$\Rightarrow N=\left\mathit{\Delta}\_2^{-\sigma}\left(\frac{\varepsilon-1}{\varepsilon}\right)(1-\zeta)\mathit{\Delta}\_1^{\frac{\zeta}{1-\zeta}}\right]^{\frac{1}{\varphi+\sigma}}$$  
> Then the consumption allocation between the domestic goods and foreign goods is given by:  
> $$C\_H=(1-\alpha)C$$  
> $$C\_F=\alpha C$$  
> And finally, the amount of assets held by the domestic households in the steady state is obtained from the budget constraint:  
> $$PC+PI+\beta D=D+WN+RK+\mathit{\Xi}$$  
> $$\mathit{\Xi}=P\_H Y-W N-RK$$  
> $$(\beta-1)D=0$$  
> $$\Rightarrow D=0$$
> 
> \section{Dynare Code}  
> See \texttt{GM\_2005.mod} attached.
> 
> \bibliography{references}
> 
> \end{document}

[GM\_2005.pdf](https://forum.dynare.org/uploads/default/original/2X/0/0e43fc3f29c4f92371daec299c9c221cbd8dbe47.pdf) (208 KB)  
[GM\_2005.mod](https://forum.dynare.org/uploads/default/original/2X/5/5b7cd90ad7085668df05a51855e68099eadf9895.mod) (13.5 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 May 2016 13:49 UTC](https://forum.dynare.org/t/ramsey-policy/5447/15 "2016-05-09T13:49:13Z")

</div>

But do you know whether the Gali Monacelli model you enter works with steady state inflation, i.e. correctly accounts for a steady state nominal interest rate bigger than the real interest rate?

---

<div class="post-metadata">

### Author: ![jd1090](https://forum.dynare.org/user_avatar/forum.dynare.org/jd1090/32/5086_2.png) [@jd1090](https://forum.dynare.org/u/jd1090)
#### Post date: [9 May 2016 15:07 UTC](https://forum.dynare.org/t/ramsey-policy/5447/16 "2016-05-09T15:07:38Z")

</div>

When running the model with a simple Taylor rule, the real interest rate is equal to the nominal interest rate in the zero inflation steady state (see code attached), where the gross real interest rate is defined by the usual Fisher equation:

```auto
RI=(exp(i))/PI_CPI;
```

And the resulting IRFs are smooth and well behaved.

Unless you were asking me if the model really works for anything other than the zero inflation steady state, to which the answer is probably - no, but I’m not quite sure how one should incorpotate that into the model and why that would be a sensible solution in this scenario. Is there a simple example available at hand?  
[GM\_2005.mod](https://forum.dynare.org/uploads/default/original/2X/3/3540bc1544a187fc37650d20d734ae0ed79117b4.mod) (13.6 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 2016 09:14 UTC](https://forum.dynare.org/t/ramsey-policy/5447/17 "2016-05-10T09:14:07Z")

</div>

What I am saying: you use the nominal interest rate as your instrument. Optimal policy entails among other things selecting the steady state of the nominal interest rate. If this steady state is smaller or bigger than the real interest rate, this implies non-zero steady state inflation via the Fisher equation. If your model cannot handle this, you are in trouble.  
Why this is sensible: when you look at simple classical monetary models with money in the utility function, the Friedman rule is optimal (0 nominal interest rate). As Schmitt-Grohe/Uribe have shown in a series of papers in the mid-2000s, in New Keynesian models with frictions, there are other mechanisms at work, but 0 inflation is typically not the efficient steady state. So you have to think about this possibility and potentially account for it in your model.

---

<div class="post-metadata">

### Author: ![jd1090](https://forum.dynare.org/user_avatar/forum.dynare.org/jd1090/32/5086_2.png) [@jd1090](https://forum.dynare.org/u/jd1090)
#### Post date: [15 July 2016 09:37 UTC](https://forum.dynare.org/t/ramsey-policy/5447/18 "2016-07-15T09:37:30Z")

</div>

Hello again,

After months of focusing on other projects, I’ve decided to give this problem another go. I managed to specify the steady state of the model conditional on any rate of inflation/deflation (it works with stoch simul), but now I receive an error related to the planner discount:

[quote]dynare gm\_ramsey.mod

Configuring Dynare …  
[mex] Generalized QZ.  
[mex] Sylvester equation solution.  
[mex] Kronecker products.  
[mex] Sparse kronecker products.  
[mex] Local state space iteration (second order).  
[mex] Bytecode evaluation.  
[mex] k-order perturbation solver.  
[mex] k-order solution simulation.  
[mex] Quasi Monte-Carlo sequence (Sobol).  
[mex] Markov Switching SBVAR.

Using 64-bit preprocessor  
Starting Dynare (version 2016-04-24).  
Starting preprocessing of the model file …  
WARNING: in the ‘steady\_state\_model’ block, variable ‘PI’ is not assigned a value  
Ramsey Problem: added 34 Multipliers.  
Substitution of endo leads \>= 2: added 1 auxiliary variables and equations.  
Substitution of endo lags \>= 2: added 1 auxiliary variables and equations.  
Found 34 equation(s).  
Found 71 FOC equation(s) for Ramsey Problem.  
Evaluating expressions…done  
Computing static model derivatives:

- order 1  
Computing dynamic model derivatives:
- order 1
- order 2  
Computing static model derivatives:
- order 1
- order 2
- order 3  
Processing outputs …  
done  
Preprocessing completed.

Warning: Some of the parameters have no value (optimal\_policy\_discount\_factor) when using model\_diagnostics. If  
these parameters are not initialized in a steadystate file or a steady\_state\_model-block, Dynare may not be able  
to solve the model…  
Warning: Either you have not correctly initialized planner\_discount or you are calling a command like steady or  
stoch\_simul that is not allowed in the context of ramsey\_policy  
MODEL\_DIAGNOSTICS: The steady state cannot be computed  
Warning: Rank deficient, rank = 33, tol = 2.498569e-12.

> In dyn\_ramsey\_static\_dyn\_ramsey\_static\_1 (line 152)  
> In dyn\_ramsey\_static\>@(x)dyn\_ramsey\_static\_1(x,M,options\_,oo) (line 43)  
> In csolve (line 60)  
> In dyn\_ramsey\_static (line 58)  
> In evaluate\_steady\_state (line 120)  
> In resol (line 104)  
> In stoch\_simul (line 83)  
> In ramsey\_policy (line 25)  
> In gm\_ramsey (line 582)  
> In dynare (line 223)  
> Warning: Rank deficient, rank = 33, tol = 2.498583e-12.  
> In dyn\_ramsey\_static\_dyn\_ramsey\_static\_1 (line 152)  
> In dyn\_ramsey\_static\>@(x)dyn\_ramsey\_static\_1(x,M,options\_,oo) (line 43)  
> In csolve (line 80)  
> In dyn\_ramsey\_static (line 58)  
> In evaluate\_steady\_state (line 120)  
> In resol (line 104)  
> In stoch\_simul (line 83)  
> In ramsey\_policy (line 25)  
> In gm\_ramsey (line 582)  
> In dynare (line 223)  
> Warning: Rank deficient, rank = 33, tol = 2.498605e-12.  
> In dyn\_ramsey\_static\_dyn\_ramsey\_static\_1 (line 152)  
> In dyn\_ramsey\_static\>@(x)dyn\_ramsey\_static\_1(x,M,options\_,oo) (line 43)  
> In csolve (line 112)  
> In dyn\_ramsey\_static (line 58)  
> In evaluate\_steady\_state (line 120)  
> In resol (line 104)  
> In stoch\_simul (line 83)  
> In ramsey\_policy (line 25)  
> In gm\_ramsey (line 582)  
> In dynare (line 223)  
> Warning: Rank deficient, rank = 33, tol = 2.498605e-12.  
> In dyn\_ramsey\_static\_dyn\_ramsey\_static\_1 (line 152)  
> In dyn\_ramsey\_static\>@(x)dyn\_ramsey\_static\_1(x,M,options\_,oo) (line 43)  
> In dyn\_ramsey\_static (line 70)  
> In evaluate\_steady\_state (line 120)  
> In resol (line 104)  
> In stoch\_simul (line 83)  
> In ramsey\_policy (line 25)  
> In gm\_ramsey (line 582)  
> In dynare (line 223)  
> Error using print\_info (line 54)  
> One of the eigenvalues is close to 0/0 (the absolute value of numerator and denominator is smaller than 1e-06!  
> If you believe that the model has a unique solution you can try to reduce the value of qz\_zero\_threshold.

Error in stoch\_simul (line 94)  
print\_info(info, options\_.noprint, options\_);

Error in ramsey\_policy (line 25)  
info = stoch\_simul(var\_list);

Error in gm\_ramsey (line 582)  
ramsey\_policy(var\_list\_);

Error in dynare (line 223)  
evalin(‘base’,fname) ;[/quote]

Note that I am not using neither steady nor stoch\_simul anywhere in my .mod file. It also gives rise to eigenvalue problems (none of which are encountered in stoch\_simul with any Taylor rule), so I’m hoping this is something trivial.

Thanks ever so much in advance (.mod file is attached as usual).  
[gm\_ramsey.mod](https://forum.dynare.org/uploads/default/original/2X/4/4b3b23f55368cd88ab47d2b5274c3a0c48154a01.mod) (18.2 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: [15 July 2016 17:25 UTC](https://forum.dynare.org/t/ramsey-policy/5447/19 "2016-07-15T17:25:02Z")

</div>

You cannot easily use the model\_diagnostics-command (which calls steady) with Ramsey. That is where the message appears. Please focus on

> [@](#):
>
> WARNING: in the ‘steady\_state\_model’ block, variable ‘PI’ is not assigned a value

Maybe that is already the reason.

---

<div class="post-metadata">

### Author: ![jd1090](https://forum.dynare.org/user_avatar/forum.dynare.org/jd1090/32/5086_2.png) [@jd1090](https://forum.dynare.org/u/jd1090)
#### Post date: [15 July 2016 18:15 UTC](https://forum.dynare.org/t/ramsey-policy/5447/20 "2016-07-15T18:15:14Z")

</div>

Yes I have tried running it without the model diagnostics, but it still gives rise to 0/0 eigenvalue problem (but only with Ramsey!). Let me try to explain my approach a little bit better. PI stands of inflation. Inflation is the chosen instrument (replacing the Taylor rule). The steady state is conditional on the value of the instrument (meaning, it will work for any value of PI). When running the Ramsey version of this model, the initial value for PI is set in the initval block (as instructed before) and it is free to move around as the Ramsey algorithm sees fit (with a Taylor rule, it is specified in the steady\_state\_model block). Any further comments would be much appreciated.

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