I had the same problem as dynare2014. When I run the “stoch_simul(order=2)” to my model, it works fine. Residuals of the static equations are all zero and it returns the IRFs. But when I replace the “stoch_simul” by “ramsey_policy”, it returns the following error message:

Starting Dynare (version 4.4.3).

Starting preprocessing of the model file …

Ramsey Problem: added 59 Multipliers.

Substitution of exo leads: added 1 auxiliary variables and equations.

Found 59 equation(s).

Found 120 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

Processing outputs …done

Preprocessing completed.

Starting MATLAB/Octave computing.

Residuals of the static equations:

Equation number 1 : NaN

Equation number 2 : NaN

Equation number 3 : NaN

Equation number 4 : NaN

Equation number 5 : 0

Equation number 6 : 0

Equation number 7 : NaN

Equation number 8 : 0

Equation number 9 : NaN

Equation number 10 : NaN

Equation number 11 : NaN

Equation number 12 : NaN

Equation number 13 : NaN

Equation number 14 : 0

Equation number 15 : NaN

Equation number 16 : NaN

Equation number 17 : 0

Equation number 18 : 0

Equation number 19 : 0

Equation number 20 : 0

Equation number 21 : 0

Equation number 22 : NaN

Equation number 23 : NaN

Equation number 24 : NaN

Equation number 25 : NaN

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 : NaN

Equation number 33 : NaN

Equation number 34 : NaN

Equation number 35 : 0

Equation number 36 : 0

Equation number 37 : 1

Equation number 38 : NaN

Equation number 39 : 0

Equation number 40 : 0

Equation number 41 : 0

Equation number 42 : 0

Equation number 43 : NaN

Equation number 44 : NaN

Equation number 45 : 0

Equation number 46 : NaN

Equation number 47 : NaN

Equation number 48 : 0

Equation number 49 : 0

Equation number 50 : 0

Equation number 51 : NaN

Equation number 52 : 0

Equation number 53 : 0

Equation number 54 : 0

Equation number 55 : 0

Equation number 56 : 0

Equation number 57 : 0

Equation number 58 : 0

Equation number 59 : 0

Equation number 60 : 0

STEADY: The Jacobian contains Inf or NaN. The problem arises from:

STEADY: Derivative of Equation 1 with respect to Variable c (initial value of c: 3.15605)

STEADY: Derivative of Equation 2 with respect to Variable lambda (initial value of lambda: 0.204888)

STEADY: Derivative of Equation 4 with respect to Variable lambda (initial value of lambda: 0.204888)

STEADY: Derivative of Equation 33 with respect to Variable lambda (initial value of lambda: 0.204888)

STEADY: Derivative of Equation 34 with respect to Variable lambda (initial value of lambda: 0.204888)

STEADY: Derivative of Equation 2 with respect to Variable R (initial value of R: 1.00503)

STEADY: Derivative of Equation 4 with respect to Variable R (initial value of R: 1.00503)

STEADY: Derivative of Equation 47 with respect to Variable R (initial value of R: 1.00503)

STEADY: Derivative of Equation 2 with respect to Variable pi (initial value of pi: 1)

STEADY: Derivative of Equation 3 with respect to Variable pi (initial value of pi: 1)

STEADY: Derivative of Equation 4 with respect to Variable pi (initial value of pi: 1)

STEADY: Derivative of Equation 22 with respect to Variable pi (initial value of pi: 1)

STEADY: Derivative of Equation 23 with respect to Variable pi (initial value of pi: 1)

STEADY: Derivative of Equation 47 with respect to Variable pi (initial value of pi: 1)

STEADY: Derivative of Equation 2 with respect to Variable q (initial value of q: 1)

STEADY: Derivative of Equation 10 with respect to Variable q (initial value of q: 1)

STEADY: Derivative of Equation 10 with respect to Variable inv (initial value of inv: 4.14831)

STEADY: Derivative of Equation 25 with respect to Variable delta_p (initial value of delta_p: 1)

STEADY: Derivative of Equation 25 with respect to Variable Kp (initial value of Kp: 4.54102)

STEADY: Derivative of Equation 16 with respect to Variable Fp (initial value of Fp: 5.44922)

STEADY: Derivative of Equation 25 with respect to Variable Fp (initial value of Fp: 5.44922)

STEADY: Derivative of Equation 2 with respect to Variable rk (initial value of rk: 0.0550251)

STEADY: Derivative of Equation 16 with respect to Variable pistar (initial value of pistar: 1)

STEADY: Derivative of Equation 22 with respect to Variable p_H (initial value of p_H: 1)

STEADY: Derivative of Equation 23 with respect to Variable p_F (initial value of p_F: 1)

STEADY: Derivative of Equation 24 with respect to Variable p_H_star (initial value of p_H_star: 1)

STEADY: Derivative of Equation 11 with respect to Variable pi_H (initial value of pi_H: 1)

STEADY: Derivative of Equation 12 with respect to Variable pi_H (initial value of pi_H: 1)

STEADY: Derivative of Equation 13 with respect to Variable pi_H (initial value of pi_H: 1)

STEADY: Derivative of Equation 16 with respect to Variable pi_H (initial value of pi_H: 1)

STEADY: Derivative of Equation 25 with respect to Variable pi_H (initial value of pi_H: 1)

STEADY: Derivative of Equation 2 with respect to Variable R_star (initial value of R_star: 1.00503)

STEADY: Derivative of Equation 33 with respect to Variable R_star (initial value of R_star: 1.00503)

STEADY: Derivative of Equation 34 with respect to Variable R_star (initial value of R_star: 1.00503)

STEADY: Derivative of Equation 43 with respect to Variable R_star (initial value of R_star: 1.00503)

STEADY: Derivative of Equation 44 with respect to Variable R_star (initial value of R_star: 1.00503)

STEADY: Derivative of Equation 2 with respect to Variable pi_star (initial value of pi_star: 1)

STEADY: Derivative of Equation 24 with respect to Variable pi_star (initial value of pi_star: 1)

STEADY: Derivative of Equation 32 with respect to Variable pi_star (initial value of pi_star: 1)

STEADY: Derivative of Equation 33 with respect to Variable pi_star (initial value of pi_star: 1)

STEADY: Derivative of Equation 34 with respect to Variable pi_star (initial value of pi_star: 1)

STEADY: Derivative of Equation 43 with respect to Variable pi_star (initial value of pi_star: 1)

STEADY: Derivative of Equation 44 with respect to Variable pi_star (initial value of pi_star: 1)

STEADY: Derivative of Equation 32 with respect to Variable e (initial value of e: 1)

STEADY: Derivative of Equation 34 with respect to Variable e (initial value of e: 1)

STEADY: Derivative of Equation 43 with respect to Variable e (initial value of e: 1)

STEADY: Derivative of Equation 44 with respect to Variable e (initial value of e: 1)

STEADY: Derivative of Equation 32 with respect to Variable b_f (initial value of b_f: 7.30436)

STEADY: Derivative of Equation 32 with respect to Variable b_fr (initial value of b_fr: 3.65218)

STEADY: Derivative of Equation 46 with respect to Variable tau (initial value of tau: 1.83527)

STEADY: Derivative of Equation 47 with respect to Variable tau (initial value of tau: 1.83527)

STEADY: Derivative of Equation 3 with respect to Variable b_g (initial value of b_g: 5.47827)

STEADY: Derivative of Equation 46 with respect to Variable b_g (initial value of b_g: 5.47827)

STEADY: Derivative of Equation 47 with respect to Variable b_g (initial value of b_g: 5.47827)

Reference to non-existent field ‘orig_index’.

Error in dynare_solve (line 53)

orig_var_index=M.aux_vars(1,infcol(ii)-M.orig_endo_nbr).orig_index;

Error in evaluate_steady_state (line 66)

[ys,check] = dynare_solve([M.fname '*static’],…*

Error in resol (line 104)

[dr.ys,M.params,info] = evaluate_steady_state(oo.steady_state,M,options,oo,0);

Error in check (line 73)

[dr,info,M,options,oo] = resol(1,M,options,oo);

Error in benchmark (line 1246)

oo.dr.eigval = check(M_,options_,oo_);

Error in dynare (line 180)

evalin(‘base’,fname) ;

Not including resid(1) and steady did not fix this problem. My impression is that I need to provide steady state values of model variables (including Lagrangian multipliers) for the ramsey FOCs, which will be different compare to the model FOCs. Am I correct on this?

If I provide the ramsey FOCs in the first place and just solve the ramsey model to a second order, would that give me the optimal policy and welfare evaluation as ramsey_policy does?

Please comment on my post, thank you!