I have been struggling for several days trying to model a permanent shock using the Ramsey command. My model involves setting an initval and endval for the variable that changes permanently, which n. The setup is deterministic, and I use the perfect_foresight solver.

Since my steady state is non-linear, I created an external function to compute the steady state levels of two variables: the gross real interest rate (R) and the per capita pollution stock (p). These variables depend on my policy instrument, the carbon tax (tau_e). However, I have encountered issues when using the steady_state_model block.

In both the constant tau_e case and the optimal tau_e case, the endval block is not being taken into account. On the other hand, when I use initval and endval without the steady_state_model block, the constant tau_e case converges, and I obtain a solution.

However, when I introduce the Ramsey block, I encounter the following error:

"Error using print_info (line 33)
The generalized Schur (QZ) decomposition failed. For more information, see the documentation for Lapack function dgges: info=30, n=28. You can also run model_diagnostics to get
more information on what may cause this problem.

Error in check (line 48)
print_info(info, 0, options_);

Error in test.driver (line 1214)
oo_.dr.eigval = check(M_,options_,oo_);

Error in dynare (line 308)
evalin(‘base’,[fname ‘.driver’]);" I can’t find where the problem comes from.

You did not provide the solve_p function. Regarding steady_state_model: did you make sure that the steady state is conditional on the value of instruments and exogeneous varables, i.e. you do not override the settings of endval?

Thank you for your reply, and apologies for the confusion! Please find the attached file: solve_p.m (874 Bytes)
When using steady_state_model, I define the steady state conditional on my instrument tau_e. However, I need to include the value of n (the population growth rate) as it is an endogenous variable. The equation for

n = rho_n*n(-1) + (1-rho_n)*steady_state(n);

In this context, the steady state can take two values: an initial value specified in initval, and a final value defined in endval.
I get your point. I will add an exogenous variable to the equation

I have updated my script. Please find the attached file: Fixed_tau_y.mod (6.1 KB)
When I run the script without the Ramsey command, it works perfectly without any errors. However, when I include the Ramsey command, I encounter the following error:

evaluate_steady_state: the planner_discount is NaN/Inf. That will cause problems.
FSOLVE exit flag: 1, fval: 0.000000
FSOLVE exit flag: 1, fval: 0.000000
Warning: Matrix is singular to working precision.
> In dyn_ramsey_static>dyn_ramsey_static_1 (line 146)
In dyn_ramsey_static>@(x)dyn_ramsey_static_1(x,exo_ss,ys_init,M_,options_) (line 49)
In dynare_solve (line 107)
In dyn_ramsey_static (line 74)
In evaluate_steady_state (line 203)
In display_static_residuals (line 55)
In Fixed_tau_y.driver (line 1281)
In dynare (line 308)
Operands to the || and && operators must be convertible to logical scalar values.
Error in dynare_solve (line 109)
if ~ismember(options.solve_algo,[10,11]) && ~any(isnan(fvec)) && max(abs(fvec)) < tolf
Error in dyn_ramsey_static (line 74)
[inst_val, errorflag] = dynare_solve(nl_func, ys_init(k_inst), options_.ramsey.maxit, options_.solve_tolf, options_.solve_tolx, options_);
Error in evaluate_steady_state (line 203)
[ys,params,info] = dyn_ramsey_static(ys_init,exo_ss,M_,options_);
Error in display_static_residuals (line 55)
evaluate_steady_state(oo_.steady_state,[oo_.exo_steady_state; oo_.exo_det_steady_state],M_,options_,false);
Error in Fixed_tau_y.driver (line 1281)
display_static_residuals(M_, options_, oo_, options_resid_);
Error in dynare (line 308)
evalin('base',[fname '.driver']);

Do you have any suggestions on how to resolve this issue?
Thank you for your help!

My apologies for the confusion earlier. I made some corrections but forgot to update you. Please find the updated files attached: Fixed_tau_y.mod (6.1 KB) no_policy_variables.mat (316 Bytes) solve_for_R_tau_y.m (1.1 KB) solve_p.m (874 Bytes)
I have now added resid; steady; and check; after ramsey_model (planner_discount = beta, instruments=(tau_e)); command, which was missing previously. I ran the updated .mod file again and here is the output I received:

Warning: Matrix is singular to working precision.
> In sim1>lin_solve (line 189)
In sim1 (line 131)
In perfect_foresight_solver_core (line 103)
In perfect_foresight_solver>homotopy_loop (line 357)
In perfect_foresight_solver (line 153)
In Fixed_tau_y.driver (line 1124)
In dynare (line 308)
Total time of simulation: 18.881.
Maximum number of iterations is reached (modify option maxit).
--------------------------------------------------------------
Iter. | Share | Status | Max. residual | Duration (sec)
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 | 1.00000 | failed | Inf | 15.2
2 | 0.50000 | failed | Inf | 14.7
3 | 0.25000 | failed | Inf | 17.2
4 | 0.12500 | failed | Inf | 16.4
5 | 0.06250 | failed | Inf | 16.9
6 | 0.03125 | failed | Inf | 17.0
7 | 0.01563 | failed | Inf | 17.8
8 | 0.00781 | failed | Inf | 17.8
9 | 0.00391 | failed | Inf | 20.1
10 | 0.00195 | failed | Inf | 19.0
Failed to solve perfect foresight model
FSOLVE exit flag: 1, fval: 0.000000
FSOLVE exit flag: 1, fval: 0.000000
FSOLVE exit flag: 1, fval: 0.000000
FSOLVE exit flag: 1, fval: 0.000000
FSOLVE exit flag: 1, fval: 0.000000
FSOLVE exit flag: 1, fval: 0.000000
MODEL_DIAGNOSTICS: No obvious problems with this mod-file were detected.
Error using evaluate_planner_objective (line 106)
evaluate_planner_objective requires decision rules to have previously been computed (e.g. by stoch_simul or discretionary_policy)
Error in Fixed_tau_y.driver (line 1126)
oo_.planner_objective_value = evaluate_planner_objective(M_, options_, oo_);
Error in dynare (line 308)
evalin('base',[fname '.driver']);

I think that the problem is related to the use of endval. I run my .mod file without the endval and it works. Could you please confirm that in dynare we can use initval and endval (to model a permanet shock) with the ramsey_model command ?

Yes, the setting of initial and terminal conditions is necessary and should work. It seems the order of commands was a problem. Start from: Fixed_tau_y.mod (6.1 KB)