Matlab eigs() Problem Description (applies to <R2017b due to a non-fixed seed)

For a rather large matrix (e.g 101x101) Matlab eigs() intermittently returns 2 different sets of eigenvalues when called repeatedly without changing input parameters. E.g.

[w,d]=eigs(a',10,'LM',opts); (with opts containing disp:0) can produce outputs like below (with difference being hihglighted):

K>> [www,ddd] = eigs(a',10,'LM',opts);

K>> sort(abs(diag(ddd)))' ans =

K>> [www,ddd] = eigs(a',10,'LM',opts);

K>> sort(abs(diag(ddd)))' ans =

We reported the probelm to Mathworks and got a reply (see below).

Possible quick work-around

use eig() instead eigs() when possible.

Mathworks suggested solution

"The behaviour you are seeing is actually not a bug, but expected behaviour. EIGS uses an iterative method of finding the eigenvalues for a matrix and starts off by choosing a starting vector completely randomly. An iterative process which starts in a different location might have completely different convergence properties and therefore might come up with a (slightly) different answer.... this kind of irregular behaviour only occurs with ill-conditioned matrices.

The best way to work around this behaviour is to specify a fixed starting vector from which the iterative process will start, i.e. by specifying the 'v0' field of the options structure that is passed into the EIGS command...."

Problem Impact

E.g., when running stoch_simul, system will intermittently faill B&K test and simul too for no real or apparent reason.

Consequently, when running estimations, the eigs() problem was causing very many AIM errors of type 4 - too few big roots.- to be reported during the ML and MCMC estimation but none of that type 4 appeared when I rerun the same estimation after blocking eigs() and using eig() instead.

Also, it then affected the results of the estimation : the likelihood was rather lower before the change than the likelihood after the modification and the estimated parameters were different.

Critical test data

Below .mat file contains matrix a which causes the above problem: eigs_bug.mat

DynareWiki: MatlabEigsBug (last edited 2022-09-19 11:11:56 by JohannesPfeifer)