Problem Solving Ramsey Policy Problem

Hello all,

I have an open econ model whose private equilibrium solution based on simple rules for policy instruments works fine.

Now, I want to solve the cooperative Ramsey model. For that I am commenting the rules and adding:

//Coop:

planner_objective nc*(Cc^(1-sigmma)/(1-sigmma) - Hc^(1+pssi)/(1+pssi)) + na*(Ca^(1-sigmma)/(1-sigmma) - Ha^(1+pssi)/(1+pssi)) + nb*(Cb^(1-sigmma)/(1-sigmma) - Hb^(1+pssi)/(1+pssi)) ;

ramsey_model(instruments=(tauc, taua, taub), planner_discount=betta);

However, the model cannot be solved. Particularly the Steady State.

How can I fix it?

I am attaching the files (I am using an external SS file)

These are the errors for my static eqs:

Residuals of the static equations and associated error prompt:

Equation number 1 : 9.9506e-06
Equation number 2 : 4.155e-05
Equation number 3 : -1.9845e-05
Equation number 4 : -1.6481e-05
Equation number 5 : 6.6635e-06
Equation number 6 : -2.9347e-05
Equation number 7 : 0
Equation number 8 : -1.7612e-06
Equation number 9 : 2.1726e-07
Equation number 10 : -1.0377e-07
Equation number 11 : 1.8547e-06
Equation number 12 : -6.5419e-05
Equation number 13 : 6.1709e-05
Equation number 14 : -5.4146e-05
Equation number 15 : 8.9604e-05
Equation number 16 : -0.00014363
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.00058798
Equation number 24 : 0.0021149
Equation number 25 : -0.0023462
Equation number 26 : -2.0432e-05
Equation number 27 : 7.3494e-05
Equation number 28 : -8.153e-05
Equation number 29 : 0
Equation number 30 : 0
Equation number 31 : 0
Equation number 32 : -1.4996e-06
Equation number 33 : -1.1858e-06
Equation number 34 : -1.2173e-06
Equation number 35 : -8.3757e-05
Equation number 36 : 0.00033047
Equation number 37 : -0.00034977
Equation number 38 : 0.0017844
Equation number 39 : -0.0019964
Equation number 40 : -0.00071619
Equation number 41 : -1.5148e-06
Equation number 42 : -1.5148e-06
Equation number 43 : 0
Equation number 44 : -2.1081e-07
Equation number 45 : 1.0069e-07
Equation number 46 : -6.8953e-06
Equation number 47 : 2.7317e-05
Equation number 48 : -3.676e-05
Equation number 49 : 1.7135e-06
Equation number 50 : 1.884e-06
Equation number 51 : 1.0773e-06
Equation number 52 : 4.6537e-05
Equation number 53 : -2.3037e-05
Equation number 54 : 7.749e-05


Error using print_info (line 32)
Ramsey: The solution to the static first order conditions for optimal policy could not be found.
Either the model doesn't have a steady state, there are an infinity of steady states,  or the guess
values are too far from the solution
Error in steady (line 102)
    print_info(info,options_.noprint, options_);
Error in MaPCoord_Lv.driver (line 1195)
steady;
Error in dynare (line 293)
evalin('base',[fname '.driver']) ; 

Also, just to check, I solved the model with habits of consumption and I get a different error this time but my eqs resids look different:

Residuals of the static equations:

Equation number 1 : 0.20887
Equation number 2 : 0.1149
Equation number 3 : 0.1149
Equation number 4 : -0.47804
Equation number 5 : -0.25472
Equation number 6 : -0.25472
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
Equation number 41 : 0
Equation number 42 : 0
Equation number 43 : 0
Equation number 44 : 0
Equation number 45 : 0
Equation number 46 : 0
Equation number 47 : 0
Equation number 48 : 0
Equation number 49 : 0
Equation number 50 : 0
Equation number 51 : 0
Equation number 52 : 0
Equation number 53 : 0
Equation number 54 : 0


Error using print_info (line 32)
Ramsey: The steady state file computation for the Ramsey problem resulted in NaNs at the initial
values of the instruments
Error in steady (line 102)
    print_info(info,options_.noprint, options_);
Error in MaPCoord_Lv.driver (line 1381)
steady;
Error in dynare (line 293)
evalin('base',[fname '.driver']) ; 
>> 

Thanks for your help!.

Camilo

find_ss.m (1.8 KB) MaPCoord_Lv_steadystate.m (5.9 KB) MaPCoord_Lv.mod (17.9 KB) MaPCoord_sseqs.m (7.4 KB)

1 Like

Your steady state file is wrong in this case. It needs to be conditional on the instruments, i.e. work with the instrument values Dynare will input into the file. You cannot set

tauc = -0.16;
taua = -0.20;
taub = -0.20;

in the file as this overrides Dynare’s values.

1 Like

Hi Johannes, thanks for your reply.

If I comment those lines in [MaPCoord_Lv_steadystate.m] and in initval in the main file [MaPCoord_Lv.mod] I still get an error:

Residuals of the static equations:

Equation number 1 : 0.22521
Equation number 2 : 0.12389
Equation number 3 : 0.12389
Equation number 4 : -0.46839
Equation number 5 : -0.24958
Equation number 6 : -0.24958
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
Equation number 41 : 0
Equation number 42 : 0
Equation number 43 : 0
Equation number 44 : 0
Equation number 45 : 0
Equation number 46 : 0
Equation number 47 : 0
Equation number 48 : 0
Equation number 49 : 0
Equation number 50 : 0
Equation number 51 : 0
Equation number 52 : 0
Equation number 53 : 0
Equation number 54 : 0

with:

Error using print_info (line 32)
Ramsey: The steady state file does not solve the
static first order conditions conditional on the
instruments.
Error in steady (line 102)
    print_info(info,options_.noprint, options_);
Error in MaPCoord_Lv.driver (line 1163)
steady;
Error in dynare (line 293)
evalin('base',[fname '.driver']) ; 
>> 

Also, in the example file it looks like you always need to provide the SS value of the instrument: https://github.com/DynareTeam/dynare/blob/master/tests/optimal_policy/Ramsey/ramsey_ex.mod

Do you know where should the instrument be declared and where it should not?

As a final check, I will follow the example file, i.e., I will set the Instrument on its own in ‘initval’ separate from the rest of the Steady State:

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;

Hence in my main file now I have:

// Load SS - if commented it's loaded as an external .m file
initval;
tauc = -0.16;
taua = -0.20;
taub = -0.20;
end;

Everywhere else is commented (e.g. the same line in Steady_state file)

I get the same error:

Error using print_info (line 32)
Ramsey: The steady state file does not solve the
static first order conditions conditional on the
instruments.
Error in steady (line 102)
    print_info(info,options_.noprint, options_);
Error in MaPCoord_Lv.driver (line 1200)
steady;
Error in dynare (line 293)
evalin('base',[fname '.driver']) ; 

If you know of any, could you point me to an example of the Ramsey problem in Dynare where an external Steady_state file is used?

Thank you and best,

Camilo

The initval for the instrument is only the starting value for finding the steady state for the instrument. You are not allowed to set the instrument values in the steady state file or the block.

1 Like

Thank you for your reply, Johannes.

Indeed, I took that part out (from SS external file) and let the initval values:

 initval;
 tauc = -0.16;
 taua = -0.20;
 taub = -0.20;
 end; %other SS values come from external file

However, it still won’t work:

Using 64-bit preprocessor
Starting Dynare (version 4.6.1).
Calling Dynare with arguments: none
Starting preprocessing of the model file ...
Ramsey Problem: added 51 Multipliers.
Substitution of exo lags: added 24 auxiliary variables and equations.
Found 51 equation(s).
Found 129 FOC equation(s) for Ramsey Problem.
Evaluating expressions...done
Computing static model derivatives (order 1).
Computing dynamic model derivatives (order 1).
Computing static model derivatives (order 3).
Processing outputs ...
done
Preprocessing completed.

Error using eval
Unrecognized function or variable 'tauc'.
Error in MaPCoord_Lv_steadystate (line 165)
  eval(['ys(' int2str(ii) ') = ' varname ';']);
Error in evaluate_steady_state_file (line 49)
    [ys,params1,check] = h_steadystate(ys_init, exo_ss,M,options);
Error in evaluate_steady_state (line 57)
        [ys,params,info] = evaluate_steady_state_file(ys_init,exo_ss,M, ...
Error in resid (line 66)
        evaluate_steady_state(oo_.steady_state,M_,options_,oo_,0);
Error in MaPCoord_Lv.driver (line 1199)
resid;
Error in dynare (line 293)
evalin('base',[fname '.driver']) ; 

It just won’t recognize the instrument variables. That’s the reason I was adding that value to the Steady State file too.

Any idea what could I do to fix this?

You need to read in the value of the instrument. Try adding

NumberOfEndogenousVariables = M_.orig_endo_nbr; %auxiliary variables are set automatically
for ii = 1:NumberOfEndogenousVariables
  varname = M_.endo_names{ii};
  eval([varname '=ys(' int2str(ii) ');']);
end

where you read in the parameters.

2 Likes

Dear Johannes,

I have been following this and other forums to solve a similar problem. In particular, I am trying to find a numerical solution for the conditional steady state of an optimal tax policy (Ramsey) problem with three instruments (corporate tax, labor income tax, consumption tax). I am using Dynare 4.5.6. But when I add the piece of code you suggest above in the external steady state file I get the following error message:

Error using eval
Unrecognized function or variable ‘ys’.

Error in fun_rbc_optimal_tax_soe_Ramsey (line 17)
eval([varname ‘= ys(’ int2str(ii) ‘);’]);

Error in fsolve (line 255)
fuser = feval(funfcn{3},x,varargin{:});

Error in rbc_optimal_tax_soe_Ramsey_steadystate (line 44)
[x,fval,exitflag] =fsolve(@fun_rbc_optimal_tax_soe_Ramsey,x0,options);

Error in evaluate_steady_state_file (line 52)
[ys,check] = h_steadystate(ys_init, exo_ss);

Error in evaluate_steady_state (line 59)
[ys,params,info] = evaluate_steady_state_file(ys_init,exo_ss,M, …

Error in resol (line 104)
[dr.ys,M.params,info] =
evaluate_steady_state(oo.steady_state,M,options,oo,~options.steadystate.nocheck);

Error in stoch_simul (line 89)
[oo_.dr,info,M_,options_,oo_] = resol(0,M_,options_,oo_);

Error in rbc_optimal_tax_soe_Ramsey (line 471)
info = stoch_simul(var_list_);

Error in dynare (line 235)
evalin(‘base’,fname) ;

Any help on solving this issue will be greatly appreciated.

Regards,

Catalina

Hi Catalina,

I think Johannes’ hint above (that worked as intended) was a code chunk I had to add to the _steadystate.m file in the format of Dynare 4.6.0 and onwards. If you tried it, working with an older version may be the reason why it still does not work.

The info to update the file is here:

It that’s not the issue, then it may be that you are declaring constant values for the tools in the SS file: for an Instrument Conditional SS you need to provide any initial value in the initval block in the .mod file but you must avoid providing values for the instruments in the SS file as it prevents dynare from trying several values across iterations. Instead, you provide the chunk outlined by Johannes:

Here’s an example:
MaPCoord_Lv_steadystate.m (7.1 KB)

If this still does not work you may have to work out a separate file that solves for such Steady State value in the policy model as outlined here (page 4):

The algorithm is also mentioned in Bodenstein, Guerrieri, and La Briola (2020, JME; page 68, first paragraph):

https://pdf.sciencedirectassets.com/271711/1-s2.0-S0304393219X00021/1-s2.0-S0304393218304240/main.pdf?X-Amz-Security-Token=IQoJb3JpZ2luX2VjEBUaCXVzLWVhc3QtMSJIMEYCIQCLaIfcoQCIm76sMcjLQx65zwPGpC4EnqOhsUhUzebk1gIhAKJj1x52%2BAP4mgNDJxf44HPC5okg7CCgmu4Q9L05TGGnKr0DCN3%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEQAxoMMDU5MDAzNTQ2ODY1IgyI1yZ5fBX3GrYeDdIqkQMrc5TxUmvEy241FrYkFhoVb1OKfbGujRZMG0lW03%2BxJO4tzNjL3XCQOD5yFqnGy9UPBtJjyJfdRlSs7TJ4h8pArAkBoOz%2Fa%2BPK%2Bh6K83AKV0cFeE56G%2F380gQy0dtjJi5mRnOi26o8hvP6UyONCFBzWXOpBiHi9cJAvC9cGK1rDF92oVDqZhbquZbHlq4FHqLAc9Le8Wcr%2BLwrmWk89l7jGd0%2FdCg4hreK02Wq0uFeP%2Bp0yO8z8qfFE%2FK4oY3LlMFc5OpUildlo57za8i%2BN4OXbUCDsNzqogPx6jMzZfoBMpNentGyXfUpReqVtJ9Eyk0WEyckeorxUoT8SpdvD%2BndwT3EEGUvSNsstGmHIxVoKVU7UPe%2Bd9NMNdS1o1zqV8vn0KpE1Hv81%2F3wWf6qJ%2BnviiEojHKPtxoUbCb1A3iwq6WGcFtF428g9rZP%2B4UfT3JLpnGoY2rpkAMA7%2BGVS17473UYgKlhpu%2FRUkw57R0DXNws5zKAO1rT13LU7jqC4SpmBUJDhqjiJmPeXmY08rl%2FajDcyrH5BTrqAbem2ui4mWYoAM6zSTg%2BCbrkgA0KlhK53IAtmsF0qclfUeUatjM25KATeYOgmcIhucjrbxvcje1AoTszOyaULSUWWdNDaVgu6QDlBenhSy37DEf0VOfEq2fxXNNyagT6lxVVc2%2Fz9En5maj7wn%2B2KL68LmVnVK2Ikx4vQa1LM6AoskYApBFFxgQ2nlS10oQpnhclq7dP7c6hka6VDod1%2BwRKsG8TyUsgitJg2vz4%2BgPbaUvQHYsb4ZcfIZcyGhXKsb6EllkICu%2BzV5hvURog2Rv%2B9gLkgaqL2hGNtDBpdZTax2EHyUEL4Cu82Q%3D%3D&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20200806T213632Z&X-Amz-SignedHeaders=host&X-Amz-Expires=300&X-Amz-Credential=ASIAQ3PHCVTY7IQ4VL2Q%2F20200806%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Signature=0587a997580e8820d0e546efb5142bbaf140f15418df1730f213e4f35fcbce43&hash=6ad0f540c1a9cd4fa631739236da13b7d10ee6c58e9e65bd260af0b189a16b71&host=68042c943591013ac2b2430a89b270f6af2c76d8dfd086a07176afe7c76c2c61&pii=S0304393218304240&tid=spdf-6febc8ae-5dcc-4869-909b-e7534d77c000&sid=54f905da4ad71042cc1b4159e95d3b954beegxrqa&type=client

In a nutshell, if you have private and policy FOCs you follow these steps:

  1. set any value for your instruments, e.g., \tau
  2. conditional to \tau obtain the solution to the private eq. SS variables as usual: \bar x(\tau)
  3. replace your solution in the policy FOCs, you get a system of linear eqs in the Lagrange Multipliers \bar \lambda.
  4. solve for \bar \lambda. Since you have more eqs that unknowns (extra eqs are due to having set the tools in an ad-hoc way) you must use a regression like formula to solve for \bar \lambda and, furthermore, the solution is subject to an approximation error u.
  5. repeat for many values of \pi and pick the value such that \pi = \arg \min u

The resulting \pi from 5 is your steady-state value for the tools.

*note: in my application I had to use both Johannes’ hint but also the other algorithm because I was solving for a Nash eq. (several planners) which couldn’t be solved easily with the Dynare built-in ramsey_planner function.

Hope this helps, although Johannes may provide an even more effective solution suited to your specific issue.

Camilo

@cgranda Without the codes it is impossible to tell.

Dear Johannes,

I tried version 4.6.1 and modified the _steadystate.m file as per Camilo’s (Stéphane’s) suggestions. Although I managed to solve the issue above, now I am having other problems with fsolve.

Please find attached the codes. I will very much appreciate your comments and, more generally, any hint on how to solve the conditional steady state of an optimal tax problem numerically using an external steady state file.

rbc_optimal_tax_soe_Ramsey2.rar (4.3 KB)

Try
fun_rbc_optimal_tax_soe_Ramsey2.m (1.5 KB) rbc_optimal_tax_soe_Ramsey2_steadystate.m (3.1 KB)

Dear Johannes,

Thank you very much for your help! With the small changes you made, fsolve worked as intended. However, I am having a different issue now as the steady state file does not seem to solve the static first order conditions conditional on the instruments.

Equation solved.

fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.

Error using print_info (line 32) Ramsey: The steady state file does not solve the static first order conditions conditional on the instruments.

Error in stoch_simul (line 103)
print_info(info, options_.noprint, options_);

Error in rbc_optimal_tax_soe_Ramsey2.driver (line 505)
[info, oo_, options_, M_] = stoch_simul(M_, options_, oo_, var_list_);

Error in dynare (line 293)
evalin(‘base’,[fname ‘.driver’]) ;

I’ve tried different approaches to tackle this issue, but there seems to be something flawed (both conceptually and technically) in my understanding of the problem. I will try to summarize it in the following two questions:

  1. In the .mod file, I declare the instruments as endogenous variables but do not include equations for these in the model block. Then I give some initial values to the tax rates in the initval block. I understand this is the right way to do it, yet I get the message above. What does Dynare mean by “static first order conditions conditional on the instruments”? Does it refer to the planner’s FOCs? How should I treat the instruments?
  2. In past forums, you’ve warned not to use the command resid; with ramsey, and options_debug=1 displays the options_ structure in the command window. Is there any command allowing me to identify the problematic equations in the steady state (“static first order conditions conditional on the instruments”) file?

I will very much appreciate your attention and guidance on these matters.

  1. It means that the steady state file, given the initial value of the instruments does not solve the steady state of the private sector economy. So there must be something wrong.
  2. I warned of having the command in the mod-file. But you can run resid in the command window after you get the crash above.

Dear Johannes,

Thanks a lot for your prompt response and helpful insights. I have one last question regarding the use of resid. In my case, running it displays the residuals of 25 equations (two of them non zero), but I have introduced 22 equations in the model block.

Residuals of the static equations:

Equation number 1 : 1.3847
Equation number 2 : 0
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.039727
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

Is it possible to establish a connection between the equation numbers for the residuals above and the equations in the model block? How can I pin down which are the problematic static equations?

Once again, thanks in advance for your attention and guidance.

Hi Catalina,

You can use write_latex_dynamic_model in your .mod file to get a latex file with the final system of equations used for solving the model.

Additional equations usually refer to auxiliar variable definitions that Dynare creates to replace in the model you provided. For example, if your model has lead or lag of size 2, dynare will replace it with a new variable “Aux_endo_lead_number” that depicts a lag of size 1 only (the one Dynare works with). It may also refer to Ramsey policy FOCs.

In any case Dynare will append the new equations below the one you originally provided. Meaning that in your results, the first 22 equations should correspond to the ones you are providing directly in the .mod file.

Camilo

Hi Camilo,

I’ve just learned that Dynare appends the Ramsey policy FOCs above the equations originally provided, so the 22 equations I’ve written in the model block are the last ones in the results. Actually, if you tag the equations, you can find a correspondence between each equation tag and their order in the FOCs for the Ramsey problem in M_.equations_tags.

In any case, using write_latex_dynamic_model and write_latex_static_model is a great piece of advice, as this is how I realized what might be wrong with my model. I hope to be able to solve the issue in the coming days.

Thank you!

Catalina

2 Likes