Resid(1) Ramsey Policy

Hi,

Does the resid(1) function work with ramsey_policy(planner_discount=beta,order=1) command because I keep getting this output:

Residuals of the static equations:

Equation number 1 : 0
Equation number 2 : NaN
Equation number 3 : NaN
Equation number 4 : NaN
Equation number 5 : NaN
Equation number 6 : NaN
Equation number 7 : NaN
Equation number 8 : 0
Equation number 9 : 0
Equation number 10 : NaN

When I run the same model with the stoch_simul command I get:

Equation number 1 : 0
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

I calculate the steady state analytically and it should be correct.

Any idea then why I have NaN values when using resid(1) with Ramsey policy? or where could my mistake be?

Many thanks!

When you say that you run the same model with “stoch_simul”, do you actually mean that you wrote manually the first-order conditions corresponding to the ramsey problem? Otherwise, you are not comparing the same two objects.

Concerning the NANs, they typically come from a division by zero, a log of a negative number, or something similar. Check the values that you put in the initval block.

I have exactly the same problem. I run the model with “stoch_simul” and get all the Residuals of the static equations are zeros but once I run the same exact model but instead I specify the objective planner function and Ramsey command I get most of them NAN… but still I get the impulse responses … does that mean I have the wrong impulse responses?

Another question … when I use the same model but calibrated for a different country, using the command “stoch_simul” will produce the impulse responses immediately but I noticed that a few of the static equations are non-zeros… does that mean I have the wrong results? Any help is really appreciated on this!

This is what I get but still the model produces the impulse responses!

Equation number 1 : 1.7164e-07 Equation number 2 : 0 Equation number 3 : 0 Equation number 4 : 7.6288e-07 Equation number 5 : 0 Equation number 6 : 0 Equation number 7 : 0 Equation number 8 : 0 Equation number 9 : 1.2621e-07 Equation number 10 : 0 Equation number 11 : 0 Equation number 12 : 0 Equation number 13 : 3.6546e-07 Equation number 14 : 1.8396e-07 Equation number 15 : 0 Equation number 16 : 1.2445e-07 Equation number 17 : 0 Equation number 18 : 2.4328e-07 Equation number 19 : 2.4328e-07 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

Dynare’s tolerance for IRF computation by default is 6.0555e-06. Any residuals smaller than that are taken to be 0. Thus, your model correctly solves.

What about when I run the Ramsey command, although I get the impulse responses but the residuals are:

[code]
Residuals of the static equations:

Equation number 1 : 0
Equation number 2 : NaN
Equation number 3 : NaN
Equation number 4 : NaN
Equation number 5 : 0.95592
Equation number 6 : 0
Equation number 7 : 0
Equation number 8 : -1.7044
Equation number 9 : NaN
Equation number 10 : NaN
Equation number 11 : NaN
Equation number 12 : NaN
Equation number 13 : NaN
Equation number 14 : NaN
Equation number 15 : 0
Equation number 16 : NaN
Equation number 17 : 0
Equation number 18 : NaN
Equation number 19 : NaN
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 : NaN
Equation number 28 : 0
Equation number 29 : NaN
Equation number 30 : NaN
Equation number 31 : NaN
Equation number 32 : NaN
Equation number 33 : 0
Equation number 34 : NaN
Equation number 35 : NaN
Equation number 36 : NaN
Equation number 37 : NaN
Equation number 38 : NaN
Equation number 39 : NaN
Equation number 40 : NaN
Equation number 41 : NaN
Equation number 42 : NaN[/code]

Does that mean I got the wrong impulse responses?

As in the original post, you cannot run

resid(1);or

with Ramsey. Unless there is a bug in Dynare, it will never provide you with wrong results in case a model cannot be solved correctly (exception: you explicitly instruct Dynare not to check for correctness). If the steady state could not be computed correctly, you would get a warning.

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!

Please see [Optimal policy under commitment (Ramsey))