Minimizing negative welfare

I am getting that message when I am minimizing the negative welfare of the representative agent.

??? Reference to non-existent field ‘eigval’.

Error in ==> check at 80
eigenvalues_ = dr.eigval;

Error in ==> welfare4_loop_det at 333
oo_.dr.eigval = check(M_,options_,oo_);

Error in ==> cond_welfare at 30
welfare4_loop_det

Error in ==> fminsearch at 265
x(:slight_smile: = y; f = funfcn(x,varargin{:});

Error in ==> max_cond_welfare at 46
[bigtheta_star,condwelfare_star] = fminsearch(‘cond_welfare’,bigtheta_start,options);

How can I solve the problem?

Thanks,

Boniface

Please post a mod-file documenting the issue and state the version of Dynare you are using.

I am using the version 4.3.3> Besides, the file is max_cond_welfare.

Here is the problem

max_cond_welfare

Configuring Dynare …
[mex] Generalized QZ.
[mex] Sylvester equation solution.
[mex] Kronecker products.
[mex] Sparse kronecker products.
[mex] Local state space iteration (second order).
[mex] Bytecode evaluation.
[mex] k-order perturbation solver.
[mex] k-order solution simulation.
[mex] Quasi Monte-Carlo sequence (Sobol).
[mex] Markov Switching SBVAR.

Starting Dynare (version 4.3.3).
Starting preprocessing of the model file …
Found 25 equation(s).
Evaluating expressions…done
Computing static model derivatives:

  • order 1
    Computing dynamic model derivatives:
  • order 1
  • order 2
    Processing outputs …done
    Preprocessing completed.
    Starting MATLAB/Octave computing.

Total computing time : 0h00m04s

Configuring Dynare …
[mex] Generalized QZ.
[mex] Sylvester equation solution.
[mex] Kronecker products.
[mex] Sparse kronecker products.
[mex] Local state space iteration (second order).
[mex] Bytecode evaluation.
[mex] k-order perturbation solver.
[mex] k-order solution simulation.
[mex] Quasi Monte-Carlo sequence (Sobol).
[mex] Markov Switching SBVAR.

Starting Dynare (version 4.3.3).
Starting preprocessing of the model file …
Found 25 equation(s).
Evaluating expressions…done
Computing static model derivatives:

  • order 1
    Computing dynamic model derivatives:
  • order 1
  • order 2
    Processing outputs …done
    Preprocessing completed.
    Starting MATLAB/Octave computing.

Total computing time : 0h00m04s
Total computing time : 0h00m02s
Total computing time : 0h00m02s

Iteration Func-count min f(x) Procedure
0 1 -20.1585
Total computing time : 0h00m01s
Total computing time : 0h00m01s
Total computing time : 0h00m01s
Total computing time : 0h00m01s
Total computing time : 0h00m01s
Total computing time : 0h00m01s
??? Reference to non-existent field ‘eigval’.

Error in ==> check at 80
eigenvalues_ = dr.eigval;

Error in ==> welfare4_loop_det at 333
oo_.dr.eigval = check(M_,options_,oo_);

Error in ==> cond_welfare at 30
welfare4_loop_det

Error in ==> fminsearch at 265
x(:slight_smile: = y; f = funfcn(x,varargin{:});

Error in ==> max_cond_welfare at 46
[bigtheta_star,condwelfare_star] = fminsearch(‘cond_welfare’,bigtheta_start,options);
boniface.zip (4.75 KB)

Try following the steps outlined here:
[Loop over parameters)
to program a more efficient loop.
The issue seems to be that you do not allow for stoch_simul to fail, e.g. due to Blanchard-Kahn violations. In this case, the eigenvalues will not be computed/stored. At the previous link, you will see that

info=stoch_simul(var_list_)

is called. Here, info stores the exit code of stoch_simul. If it is 0, everything is fine. If info>0, the solution could not be computed and you need to attach a penalty for this outcome to deal with your optimizer.

Thanks.

Boniface