Optimal policy under Ramsey

Dear Prof. Pfeifer and all
The original model is perfect,but i meet some questions when i Modify the model to find the maximize welfare in the **ramsey_policy **command.I have checked many times.

Warning: Some of the parameters have no value (chi,
Wmin, ka, TT, phi, mu_L, mu_P) when using
Stoch_simul. If these parameters are not
Initialized in a strongystate file or a
Steady_state_model-block, Dynare may not be able
To solve the model
The operands of the || and the && operator must be able to be converted to logical scalar values.
Error dynare_solve (line 88)
If (~ ismember (options.solve_algo, [10,11])) &&
(Max (abs (fvec)) <tolf)
Error dyn_ramsey_static (line 70)
[Inst_val, info1] =
Dynare_solve (nl_func, ys_init (k_inst), …
Error evaluate_steady_state (line 139)
[Ys, params, info] =
Dyn_ramsey_static (ys_init, M, options, oo);
Wrong (line 104)
[Dr.ys, M.params, info] =
Evaluate_steady_state (oo.steady_state, M, options, oo, 0);
Error stoch_simul (line 83)
[Oo_.dr, info, M_, options_, oo_] =
Resol (0, M_, options_, oo_);
Error ramsey_policy (line 38)
Info = stoch_simul (var_list);
Error model (line 1009)
Ramsey_policy (var_list_);
Error dynare (line 223)
Evalin (‘base’, fname);

Many thanks.
model.mod (11.1 KB)

This is a bug, because Dynare does not provide a proper error message. The problem is that you specify a steady_state_model-block, but do not provide an instrument. Either delete the steady state file or provide
an instrument.

1 Like

[quote=“jpfeifer”]This is a bug, because Dynare does not provide a proper error message. The problem is that you specify a steady_state_model-block, but do not provide an instrument. Either delete the steady state file or provide
an instrument.[/quote]

Thank you very much for your reply, I have improved some of the details of the model, but it still has a problem,i want to know where the problem lies and the solution.

many thanks

Warning: Matrices are singular values, close to singular values ​​or scaling errors. The results may be inaccurate. RCOND = NaN.

In dyn_ramsey_static> dyn_ramsey_static_1 at 167
In dyn_ramsey_static> @ (x) dyn_ramsey_static_1 (x, M, options_, oo) at 43
In dynare_solve at 74
In dyn_ramsey_static at 85
In evaluate_steady_state at 139
In resol at 104
In stoch_simul at 83
In ramsey_policy at 38
In model at 1014
In dynare at 223
Warning: Matrices are singular values, close to singular values ​​or scaling errors. The results may be inaccurate. RCOND = NaN.
In dyn_ramsey_static> dyn_ramsey_static_1 at 167
In dyn_ramsey_static> @ (x) dyn_ramsey_static_1 (x, M, options_, oo) at 43
In dyn_ramsey_static at 86
In evaluate_steady_state at 139
In resol at 104
In stoch_simul at 83
In ramsey_policy at 38
In model at 1014
In dynare at 223
Error using print_info (line 34)
The model does not determine the current variables
Uniquely
Error stoch_simul (line 94)
Print_info (info, options_.noprint, options_);
Error ramsey_policy (line 38)
Info = stoch_simul (var_list);
Error model (line 1014)
Ramsey_policy (var_list_);
Error dynare (line 223)
Evalin (‘base’, fname);
model.mod (9.23 KB)

It is still a problem with steady state finding. I would recommed to specify an instrument and provide a conditional steady state file. Did your model work without Ramsey?

orginalmodel.mod (11.6 KB)

This is where I am puzzled, the original model is useful, steady state is also correct.The model works without Ramsey.Looking forward to your help.

If that step works, specify an instrument and rework your steady state file to work conditional on the instrument.

Hi,
I’m trying to use Ramsey optimal policy, but get the message
++++++++++++++++++++++++++++
Error using print_info (line 156)
Ramsey: The maximum number of iterations has been reached. Try
increasing maxit.

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

Error in ramsey_policy (line 42)
info = stoch_simul(var_list);

Error in FA_CP_new (line 914)
ramsey_policy(var_list_);

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

What could be the problem here? I would greatly appreciate your help!

I attached the code. It’s a modification of the code provided by Peter Karadi on his homepage.
FA_CP_new.mod (10.1 KB)
parameters_FA.mat (2.2 KB)

With a different code I get the following message
++++++++++++++++++++++++++++
Error using print_info (line 142)
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 stoch_simul (line 100)
print_info(info, options_.noprint, options_);

Error in ramsey_policy (line 42)
info = stoch_simul(var_list);

Error in union_liqfac_ramsey (line 2390)
ramsey_policy(var_list_);

Error in dynare (line 223)
evalin(‘base’,fname) ;
+++++++++++++++++++++++++++
Code runs fine w/o Ramsey policy.

The problem seems to be one of finding the steady state of the Ramsey model. Are you providing a conditional steady state file?

Sorry… yes, I was rushing things. I thought providing the steady state was easier. In my original model, where I used optimal simple rules I just had the instrument being zero in the steady state. So now, I guess that is not the case anymore and I will not provide a steady state value for the instrument (or rather I provide one in an initval blog as you suggest in your github example) and then all the steady states of the variables have to be changed in a way that they contain the instrument as if it were different from zero.

I’m working myself through all the Ramsey threads in the forum. Now, I found that somebody else also uploaded the .mod file from Karadi for the Gertler/Karadi (2011) model: Welfare comparison with Ramsey optimal policy
In that code, steady state values are just entered as numbers and not conditional on the instrument as in the ramsey_example.mod file you provide on github. And they are provided in the initval block not in the steady_state_model block. Furthermore in the ramsey_example from github, you only provide steady state values for the variables which are not the instrument. While in ramsey.mod in Welfare comparison with Ramsey optimal policy also for the instrument a value is provided.

So now I’m confused: “conditional on the instrument” means that if I have a steady state value for the instrument, I can just calculate all other steady state values. I do not have to enter them as functions of the instrument? So basically, when I have a running code with simple rules and now want to calculate optimal policy, I do not have to rewrite the entire steady_state_model block, but can just use the same values as before.

Now, I fixed my code (adaption of Karadi’s code) accordingly. When I now try to fine optimal conventional monetary policy, i.e., instrument is i and Taylor rule is commented out, everything runs through fine. However, when I try to calculate optimal unconventional policy, I get the the message that the BK conditions are not fullfilled. What could be the problem? attached the code. Same parameter file as above should be used with it.
FA_CP_new2.mod (9.9 KB)

2 Likes

If you are using stochastic simulations, Dynare needs to compute the steady state of the Ramsey problem, including the steady state of the instrument. As always with stochastic simulations, there are two ways to do this:

  1. Let Dynare compute the steady state numerically. In that case, you just put in an initval-block with all variables you want to specify a starting value for. The problem is that the steady state is often hard to find, because the problem is typically highly nonlinear.
  2. You provide an analytical steady state for the decentralized economy in e.g. a steady_state_model-block. As you do not know the value of the instrument in steady state, that steady state must be conditional on the instrument. For every value of the instrument given to the file, you need to provide the steady state for all other variables. That way, Dynare only needs to find the value of the instrument in steady state and the Lagrange multipliers numerically. It turns out that this problem is linear and thus easy to solve. That is the reason we usually recommend doing it this way. The initval-block in this case serves only to provide the initial value for the instrument in steady state finding. You must use it when the standard value of 0 for the instrument is not feasible.

Regarding the mod-file, I cannot run it, because you are loading a mat-file you did not provide. But in any case, the discussion has been moved to

2 Likes

Hi,

I started to calculate the steady state but got stuck due to my lack of Matlab skills… I tried to do it as in ramsey_example.mod. Hence, I provide a guess for the instrument (psi) in the initval block and then write the other steady state values as functions of that instrument into the steady state block.

However, at one point I’m stuck with a very complicated equation, containing the variable I’m looking for on both sides and the instrument in various places as well. Now, I’m not sure to proceed. In find_c.m, you are able to have the instrument only on the left hand side. I cannot do this. Is it necessare to do it for csolve? Which solver could I use instead?

So, what I have so far is the following (for the _ss parts I provide values in the parameter block):

initval;
psi=0;
end;

steady_state_model;
Q=log(1);
In=0;
Lambda=log(1);
R=log(1/betta);
i=log(1/betta);
Ne_shock=0;
a=0;
ksi=0;
g=0;
infl=0;
inflstar=0;
delta=log(delta_ss);

Pm=log(pm_ss);
X=log(1/pm_ss);
phi=log(phi_ss);
Rk=log(Rk_ss);
prem=log(prem_ss);
nu=log(nu_ss);
eta=log(eta_ss);
stochbank = log(stochbank_ss);
w=log(w_ss);

L=find_L(0.333,w_ss,betta,hh,Y_over_K,L_over_K,G_over_Y,delta_ss,tau1_M,tau2_M,sig,chi,varphi);

and the find_L function:
function L = find_L(L0,w_ss,betta,hh,Y_over_K,L_over_K,G_over_Y,delta_ss,tau1_M,tau2_M,sig,chi,varphi,psi)
L = fsolve(@myfun,L0,[],1e-8,100,w_ss,betta,hh,Y_over_K,L_over_K,G_over_Y,delta_ss,tau1_M,tau2_M,sig,chi,varphi);
end

function 0 = myfun(L,w_ss,betta,hh,Y_over_K,L_over_K,G_over_Y,delta_ss,tau1_M,tau2_M,sig,chi,varphi,psi)

0 = L - ((w_ss*((1-bettahh) * ((1-hh)((Y_over_K * (L/L_over_K)) - (G_over_YY_over_K * L/L_over_K) - delta_ssL/L_over_K - tau1_M(psiL/L_over_K) + tau2_M(psi*L/L_over_K)^2 ))^(-sig))/chi)^(1/varphi));

end;

Any help or suggestions where I can find a solution are greatly appreciated.

Where exactly is the problem? You have derived an equation for L that you need to solve. csolve should work with that equation.

Unfortunately it does not work. First, I wasn’t allowed to write the function =0. So, I wrote L = … instead. Then, I got a log error message starting with

Error using psi
Not enough input arguments.
Error in find_L>myfun (line 6)

Therefore, I include psi (the instrument) into the list of arguments I pass to the function (however, this is not something you did in find_c which goes along with your ramsey example code.

function L = find_L(L0,psi,w_ss,betta,hh,Y_over_K,L_over_K,delta_ss,tau1_M,tau2_M,sig,chi,varphi)
L = csolve(@myfun,L0,[],1e-8,100,psi,w_ss,betta,hh,Y_over_K,L_over_K,delta_ss,tau1_M,tau2_M,sig,chi,varphi);
end
function L = myfun(L,psi,w_ss,betta,hh,Y_over_K,L_over_K,delta_ss,tau1_M,tau2_M,sig,chi,varphi)
L = (w_ss*((1-bettahh) * ((1-hh)((Y_over_K * (L/L_over_K)) - (delta_ss*(L/L_over_K)) - tau1_M*( psiL/L_over_K) + tau2_M(psi*L/L_over_K)^2 ))^(-sig))/chi)^(1/varphi);
end

However, if I do that, I got the following error message:

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

I’m pretty sure the function in the find_L file is correct. I checked it for the instrument =0: When I put in 0.33333333 for L I get out 0.33333333. The other steady state equations are also correct. The .mod file FA_CP_noRamsey without csolve but otherwise the same steady state equations runs fine,

Therefore, I think, I must be using the csolve command the wrong way or something like this?! Any help is appreciated very much!

Attached you find the codes.

FA_CP_Ramsey.mod (10.5 KB)
find_L.m (494 Bytes)
benchmarkcalibration_FA.m (1.5 KB)
FA_CP_noRamsey.mod (10.6 KB)

My guess is that the function needs to be

function L = find_L(L0,psi,w_ss,betta,hh,Y_over_K,L_over_K,delta_ss,tau1_M,tau2_M,sig,chi,varphi)
L = csolve(@myfun,L0,[],1e-8,100,psi,w_ss,betta,hh,Y_over_K,L_over_K,delta_ss,tau1_M,tau2_M,sig,chi,varphi);
end
    
function resid = myfun(L,psi,w_ss,betta,hh,Y_over_K,L_over_K,delta_ss,tau1_M,tau2_M,sig,chi,varphi)
 resid=L -  (w_ss*((1-betta*hh) * ((1-hh)*((Y_over_K * (L/L_over_K))  - (delta_ss*(L/L_over_K))  -  tau1_M*(psi*L/L_over_K) + tau2_M*(psi*L/L_over_K)^2   ))^(-sig))/chi)^(1/varphi);
end

csolve will try to solve the equation, i.e. find the value for L that makes the residual in resid equal to 0

The error message about psi comes from psi being the name of a built-in Matlab function

Thank you very much.
I changed the .mod file and the find_L file. I think it helped with the original problem, because the error message changed. Now, I get:

Error using print_info (line 142)
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

This is for setting the instrument which I now call psiCP=0.

When I instead set the instrument to some value between zero and one, I get

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

Is there any way to find out where exactly the problem lies? Model diagnostics only tells me “The steady state cannot be computed”.

By the way, I get the warning 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” and I don’t see where it is coming from.

I only attached the files I changed:
FA_CP_Ramsey.mod (10.6 KB)
find_L.m (517 Bytes)

You need to check your steady state file. With the instrument value

initval;
psiCP=0.3;
end;

the first equation in your model has a residual of 1.

Thank you! I will look into the steady state more closely.