# 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 =

0.9914

**0.9914**1.1139 1.1139 1.2212 1.2212 1.2229 1.2229 1.2506 1.2506

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

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

0.9914

**1.0147**1.1139 1.1139 1.2212 1.2212 1.2229 1.2229 1.2506 1.2506

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