# Warning: Matrix close to singular or badly scaled

Hi, all,

I’m trying to find the optimal macroprudential and monetary rules in a DSGE model using optimal simple rules.
However I obtained a multiple of warnings as follows:

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.

Using 64-bit preprocessor
Starting Dynare (version 2015-10-23).
Starting preprocessing of the model file …
Substitution of endo lags >= 2: added 4 auxiliary variables and equations.
Found 83 equation(s).
Evaluating expressions…done
Computing static model derivatives:

• order 1
Computing dynamic model derivatives:
• order 1
• order 2
Processing outputs …
done
Preprocessing completed.

OPTIMAL SIMPLE RULE

OSR: Initial value of the objective function: 30.1947

## Improvement on iteration 1 = 4.899323116 warning: possible inaccuracy in H matrix

f at the beginning of new iteration, 25.2953508037
Predicted improvement: 29.750447518
lambda = 1; f = 100554997.7040317
lambda = 0.33333; f = 103423018.0523658
lambda = 0.11111; f = 103423018.0523656
lambda = 0.037037; f = 103423018.0523656
lambda = 0.012346; f = 101664723.0438191
lambda = 0.0041152; f = 100540719.5171381
lambda = 0.0013717; f = 100168255.6644537
lambda = 0.00045725; f = 100044268.4353072
lambda = 0.00015242; f = 100002955.6048355
lambda = 5.0805e-005; f = 25.2923052
lambda = 9.8216e-005; f = 25.2894634
lambda = 0.00018987; f = 100008031.1053914
Warning: Matrix is close to singular or badly
scaled.
Results may be inaccurate. RCOND =
8.287261e-018.

In dyn_first_order_solver at 314
In stochastic_solvers at 238
In resol at 141
In osr_obj at 48
In csminit1 at 140
In csminwel1 at 118
In dynare_minimize_objective at 203
In osr1 at 102
In osr at 60
In e at 981
In dynare at 223
lambda = 0.00012785; f = 25.2883736
lambda = 0.00016209; f = 100004266.2215708
lambda = 0.00014058; f = 100001351.2700622
Warning: Matrix is close to singular or badly
scaled.
Results may be inaccurate. RCOND =
4.201578e-018.
In dyn_first_order_solver at 314
In stochastic_solvers at 238
In resol at 141
In osr_obj at 48
In csminit1 at 140
In csminwel1 at 118
In dynare_minimize_objective at 203
In osr1 at 102
In osr at 60
In e at 981
In dynare at 223
lambda = 0.00012907; f = 25.2851655
lambda = 0.00013585; f = 100000711.3056649
lambda = 0.00013174; f = 100000153.7416213
Warning: Matrix is close to singular or badly
scaled.
Results may be inaccurate. RCOND =
3.495697e-018.
In dyn_first_order_solver at 314
In stochastic_solvers at 238
In resol at 141
In osr_obj at 48
In csminit1 at 140
In csminwel1 at 118
In dynare_minimize_objective at 203
In osr1 at 102
In osr at 60
In e at 981
In dynare at 223
lambda = 0.00012933; f = 25.2870071
Warning: Matrix is close to singular or badly
scaled.
Results may be inaccurate. RCOND =
7.934372e-019.

Can somebody please explain what this means and what I can do about it? Thanks!

This means that the Newton-type solver tries some parameter values that result in the matrices arising during solving the model being close to singular. This can happen but is no reason to worry unless the solver terminates prematurely due to this. I tried your file and it stops after 153 iterations, with no warning appearing after iteration 3, so you should be fine.

Thanks a lot, Dr. Pfeier! Could you tell me how you find that it stops after 153 iterations, with no warning appearing after iteration 3? Did you use any commands? Much appreciated!

Just look at the output of the solver. You can see e.g.

This gives you the iteration. I had no

[quote]Results may be inaccurate. RCOND =
8.287261e-018.

In dyn_first_order_solver at 314
In stochastic_solvers at 238
In resol at 141
In osr_obj at 48
In csminit1 at 140
In csminwel1 at 118
In dynare_minimize_objective at 203
In osr1 at 102
In osr at 60
In e at 981
In dynare at 223[/quote]

after iteration number 3 (though this might be different on different computers)

Get it, thanks a lot, Dr. Pfeifer!