Ramsey optimal policy. Error

Dear All,
I am working on Ramsey model to find the optimal consumption, labour and capital tax. When I am running the code it is giving following error.
Warning: Rank deficient, rank = 13, tol = 4.193558e-02.

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 lnsrch1 (line 95)
In solve1 (line 107)
In dynare_solve (line 150)
In dyn_ramsey_static (line 66)
In evaluate_steady_state (line 55)
In resol (line 104)
In stoch_simul (line 88)
In ramsey_policy (line 25)
In Ramsay (line 376)
In dynare (line 180)

SOLVE: maxit has been reached
Error using print_info (line 51)
The Jacobian matrix evaluated at the steady state contains elements that are not real or are infinite
Error in stoch_simul (line 98)
print_info(info, options_.noprint, options_);
Error in ramsey_policy (line 25)
info = stoch_simul(var_list);
Error in Ramsay (line 376)
Error in dynare (line 180)
evalin(‘base’,fname) ;

Could you please help me to solve the problem. I am attaching my dynare code.
Kind Regard,
Tehseen Ramopt.mod (2.2 KB)

I am getting the error

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

You should try to provide instruments to the command and provide a conditional steady state file. The Ramsey problem is very nonlinear, making it hard to find the steady state.

Dear Jpfeifer,
Thank you very much for your help. I followed your instruction by providing the instrument to the command and writing external steady state file. I read NK_baseline and some other examples to write that steady state file but I am getting the following error.

Undefined function or variable “ys”.
Error in dyn_ramsey_static (line 57)
[inst_val,info1] = dynare_solve(nl_func,ys(k_inst),0);
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 op3 (line 342)
Error in dynare (line 180)
evalin(‘base’,fname) ;

I also tried to run the code by using ‘‘steady_state_model’’ inside the mod file but the error is same. Could you please guide me how to fix the issue. Both mod and steadystate files are attached.
Kind Regard,
Tehseen. op3_steadystate.m (2.1 KB)op3.mod (4.2 KB)

Hi all,

After correcting a typo and running the code with dynare 4.5.3 I am getting the following message.

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

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 op3 (line 348)

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

Could anyone kindly suggest me how to resolve the issue. Updated mod and steadystate file are attached.

op3.mod (4.2 KB)
op3_steadystate.m (2.1 KB)

Dear Jpfeifer,
Thank you very much for you response. After reading few post related to the issue I got the understanding that my steady state is wrong or these sort of problems arises when steadystate equations are not in proper order. I have derived all the steadystate equation by hand and then after writing in matlab I am getting a value of every endogenous value given the value of 3 instruments.
Could you please guide me how to tackle this issue? Do you think I have to derive the steadystate equation again by some other way or there is any other solution for this?
Further more I have 19 endogenous variable out of which 3 are instrument., So I have 16 equations in my model and 16 equations for steadystate values. Whereas after writing the resid command we can see the residual of 19 equations. So it is bit difficult for me to understand which equations are creating the problem.
I am new to dynare and I am sorry to ask these basic question but I really need your help and guidance to make my model work.
Kind Regard,

I was wrong in my previous post. The resid-command does not work with Ramsey. What you should do is use
You will get:

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: 
	 tau_c 	 0.170000 
	 tau_k 	 0.300000 
	 tau_l 	 0.200000 
evaluate_steady_state: the following equations have non-zero residuals: 
	 Equation number 5: 0.095436
	 Equation number 6: -46.278509
	 Equation number 12: 3.861657
	 Equation number 15: 0.133184
	 Equation number 16: 0.100000

Take the last equation: af = rhoaf*af(-1) + epsaf
implies that af=0. But you set af=1


Dear jpfeifer,
Thank you very much for your reply. I checked my model and derived all the steady-state equations and model equations again. After making some small changes I am still getting the error. This time the non-zero residual is only for one equations that is the production function (equation number 12) .I tried to assign the different parameter values but the problem persist. This equation is very simple and straightforward. At this stage do you think that my model is fundamentally wrong or I need to derive the steady state again or assign the different values for parameters?
Your comments regarding this help me a lot in solving the problem.

op3.mod (4.4 KB)

According to your model yi=li=ci. You can easily verify that li is not equal to ci in your steady state model

Dear jpfeifer,

Thank you very much for your response. I would try to get the steady-state by equating li and ci.

Dear jpeifer,
Could you please refer to any dynare code related to optimal fiscal policy in which linearized model is used. Thanks

Sorry, I don’t have such a code. The requirements on when it is OK to use a linear model for optimal policy are quite strict.