naginterfaces.library.correg.corrmat_​nearest

naginterfaces.library.correg.corrmat_nearest(g, errtol=0.0, maxits=0, maxit=0)[source]

corrmat_nearest computes the nearest correlation matrix, in the Frobenius norm, to a given square, input matrix.

For full information please refer to the NAG Library document for g02aa

https://support.nag.com/numeric/nl/nagdoc_30.2/flhtml/g02/g02aaf.html

Parameters
gfloat, array-like, shape

, the initial matrix.

errtolfloat, optional

The termination tolerance for the Newton iteration. If , is used.

maxitsint, optional

specifies the maximum number of iterations used for the iterative scheme used to solve the linear algebraic equations at each Newton step.

If , is used.

maxitint, optional

Specifies the maximum number of Newton iterations.

If , is used.

Returns
xfloat, ndarray, shape

Contains the nearest correlation matrix.

iteraint

The number of Newton steps taken.

fevalint

The number of function evaluations of the dual problem.

nrmgrdfloat

The norm of the gradient of the last Newton step.

Raises
NagValueError
(errno )

On entry, .

Constraint: .

(errno )

Newton iteration fails to converge in iterations.

(errno )

An intermediate eigenproblem could not be solved. This should not occur. Please contact NAG with details of your call.

Warns
NagAlgorithmicWarning
(errno )

Machine precision is limiting convergence.

The array returned in may still be of interest.

Notes

A correlation matrix may be characterised as a real square matrix that is symmetric, has a unit diagonal and is positive semidefinite.

corrmat_nearest applies an inexact Newton method to a dual formulation of the problem, as described by Qi and Sun (2006). It applies the improvements suggested by Borsdorf and Higham (2010).

References

Borsdorf, R and Higham, N J, 2010, A preconditioned (Newton) algorithm for the nearest correlation matrix, IMA Journal of Numerical Analysis (30(1)), 94–107

Qi, H and Sun, D, 2006, A quadratically convergent Newton method for computing the nearest correlation matrix, SIAM J. Matrix AnalAppl (29(2)), 360–385