Optimal policy issue

Dear Professor, I am trying to find optimal parameters g1, g2, g3, g4 by following the Optimal policy example. I guess there is something wrong in my code. Could you help figure out what the problem is and how can I over come it. I also attach my mod file for your reference. Here are the results:

Starting Dynare (version 5.3).
Calling Dynare with arguments: none
Starting preprocessing of the model file …
Substitution of endo leads >= 2: added 6 auxiliary variables and equations.
Substitution of endo lags >= 2: added 9 auxiliary variables and equations.
Found 49 equation(s).
Evaluating expressions…done
Computing static model derivatives (order 1).
Computing dynamic model derivatives (order 2).
Processing outputs …
done
Preprocessing completed.

OPTIMAL SIMPLE RULE

Warning: Matrix is singular to working precision.

In evaluate_steady_state (line 305)
In resol (line 77)
In osr_obj (line 50)
In osr1 (line 96)
In osr (line 63)
In demo.driver (line 645)
In dynare (line 281)

OSR: Initial value of the objective function: 1e+08

Warning: Matrix is singular to working precision.

In evaluate_steady_state (line 305)
In resol (line 77)
In osr_obj (line 50)
In penalty_objective_function (line 33)
In csminwel1 (line 97)
In dynare_minimize_objective (line 273)
In osr1 (line 126)
In osr (line 63)
In demo.driver (line 645)
In dynare (line 281)

Warning: Matrix is singular to working precision.

In evaluate_steady_state (line 305)
In resol (line 77)
In osr_obj (line 50)
In penalty_objective_function (line 33)
In numgrad2 (line 36)
In csminwel1>get_num_grad (line 317)
In csminwel1 (line 105)
In dynare_minimize_objective (line 273)
In osr1 (line 126)
In osr (line 63)
In demo.driver (line 645)
In dynare (line 281)

Warning: Matrix is singular to working precision.

In evaluate_steady_state (line 305)
In resol (line 77)
In osr_obj (line 50)
In penalty_objective_function (line 33)
In numgrad2 (line 36)
In csminwel1>get_num_grad (line 317)
In csminwel1 (line 105)
In dynare_minimize_objective (line 273)
In osr1 (line 126)
In osr (line 63)
In demo.driver (line 645)
In dynare (line 281)

Warning: Matrix is singular to working precision.

In evaluate_steady_state (line 305)
In resol (line 77)
In osr_obj (line 50)
In penalty_objective_function (line 33)
In numgrad2 (line 36)
In csminwel1>get_num_grad (line 317)
In csminwel1 (line 105)
In dynare_minimize_objective (line 273)
In osr1 (line 126)
In osr (line 63)
In demo.driver (line 645)
In dynare (line 281)

Warning: Matrix is singular to working precision.

In evaluate_steady_state (line 305)
In resol (line 77)
In osr_obj (line 50)
In penalty_objective_function (line 33)
In numgrad2 (line 36)
In csminwel1>get_num_grad (line 317)
In csminwel1 (line 105)
In dynare_minimize_objective (line 273)
In osr1 (line 126)
In osr (line 63)
In demo.driver (line 645)
In dynare (line 281)


f at the beginning of new iteration, 100000000.0999999940
Norm of dx 0
Warning: Matrix is singular to working precision.

In evaluate_steady_state (line 305)
In resol (line 77)
In osr_obj (line 50)
In penalty_objective_function (line 33)
In numgrad2 (line 36)
In csminwel1>get_num_grad (line 317)
In csminwel1 (line 261)
In dynare_minimize_objective (line 273)
In osr1 (line 126)
In osr (line 63)
In demo.driver (line 645)
In dynare (line 281)

Warning: Matrix is singular to working precision.

In evaluate_steady_state (line 305)
In resol (line 77)
In osr_obj (line 50)
In penalty_objective_function (line 33)
In numgrad2 (line 36)
In csminwel1>get_num_grad (line 317)
In csminwel1 (line 261)
In dynare_minimize_objective (line 273)
In osr1 (line 126)
In osr (line 63)
In demo.driver (line 645)
In dynare (line 281)

Warning: Matrix is singular to working precision.

In evaluate_steady_state (line 305)
In resol (line 77)
In osr_obj (line 50)
In penalty_objective_function (line 33)
In numgrad2 (line 36)
In csminwel1>get_num_grad (line 317)
In csminwel1 (line 261)
In dynare_minimize_objective (line 273)
In osr1 (line 126)
In osr (line 63)
In demo.driver (line 645)
In dynare (line 281)

Warning: Matrix is singular to working precision.

In evaluate_steady_state (line 305)
In resol (line 77)
In osr_obj (line 50)
In penalty_objective_function (line 33)
In numgrad2 (line 36)
In csminwel1>get_num_grad (line 317)
In csminwel1 (line 261)
In dynare_minimize_objective (line 273)
In osr1 (line 126)
In osr (line 63)
In demo.driver (line 645)
In dynare (line 281)


Improvement on iteration 1 = 0.000000000
improvement < crit termination
zero gradient

OPTIMAL VALUE OF THE PARAMETERS:

          g1             0.76

          g2             0.44

          g3              0.5

          g4              0.5

Objective function : 1e+08

Warning: Matrix is singular to working precision.

In evaluate_steady_state (line 305)
In resol (line 77)
In osr1 (line 146)
In osr (line 63)
In demo.driver (line 645)
In dynare (line 281)

Error using ~
NaN values cannot be converted to logicals.

Error in osr1 (line 147)
if ~info

Error in osr (line 63)
osr_res = osr1(i_params,i_var,W);

Error in demo.driver (line 645)
oo_.osr = osr(var_list_,M_.osr.param_names,M_.osr.variable_indices,M_.osr.variable_weights);

Error in dynare (line 281)
evalin(‘base’,[fname ‘.driver’]);

Thank you for your help.
demo.mod (3.2 KB)

It seems there is a problem with steady state computation. Does your model work with stoch_simul if you pick a policy rule?

I got this message when I run stoch_simul.

dynare demo.mod
Starting Dynare (version 5.3).
Calling Dynare with arguments: none
Starting preprocessing of the model file …
Substitution of endo leads >= 2: added 6 auxiliary variables and equations.
Substitution of endo lags >= 2: added 9 auxiliary variables and equations.
Found 49 equation(s).
Evaluating expressions…done
Computing static model derivatives (order 1).
Computing dynamic model derivatives (order 2).
Processing outputs …
done
Preprocessing completed.

Warning: Matrix is singular to working precision.

In evaluate_steady_state (line 305)
In resol (line 77)
In stoch_simul (line 109)
In demo.driver (line 621)
In dynare (line 281)

Error using print_info
The steady state has NaNs or Inf.

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

Error in demo.driver (line 621)
[info, oo_, options_, M_] = stoch_simul(M_, options_, oo_, var_list_);

Error in dynare (line 281)
evalin(‘base’,[fname ‘.driver’]);

Then that is the issue you should focus on. It seems your model was not properly linearized.