Does forcing the matrix to be positive definite incur an overhead?

Posted on
31 Aug 2017

Investigating and Comparing NAG Routines g02aa and g02ab

Alice Bentley recently undertook some work experience at NAG, and during her time here she looked at two of our Nearest Correlation Matrix routines, g02aa and g02ab. She wrote up her investigation and we are delighted to publish it on our blog.


The tests below use randomly generated matrices, however the results were verified with real stock data. In order to produce a broken correlation matrix, I used a “Pairwise Deletion Method”. After randomly deleting a percentage of the observations, the individual correlations are computed from only the observations that teach pair of variables have in common. The results from random data showed the same trends and patterns as the results from the real stock data therefore I can be confident in my conclusions.

I investigated how increasing the size of the matrix affected the time it took for the computer to complete each function. g02ab, which allows the user to specify a minimum eigenvalue for the resulting matrix, is only very slightly slower than g02aa with large matrices. 

However, with much smaller matrices the overhead is negligible.

I investigated how changing alpha, the minimum eigenvalue that g02ab finds, affects time.

The graph shows that there isn’t a correlation between time and alpha. I found this to be true when using larger values of alpha too.

g02aa is included for comparison but shouldn’t vary with alpha, as it doesn’t depend on alpha. The variation is just the usual fluctuation caused by computing on a PC with other processes running.


If you are a student and fancy spending some work experience time with us, do get in touch via email or see our website.