naginterfaces.library.correg.corrmat_nearest_bounded¶
- naginterfaces.library.correg.corrmat_nearest_bounded(g, opt, alpha=None, w=None, errtol=0.0, maxits=0, maxit=0)[source]¶
corrmat_nearest_bounded
computes the nearest correlation matrix, in the Frobenius norm or weighted Frobenius norm, and optionally with bounds on the eigenvalues, to a given square, input matrix.For full information please refer to the NAG Library document for g02ab
https://support.nag.com/numeric/nl/nagdoc_30.3/flhtml/g02/g02abf.html
- Parameters
- gfloat, array-like, shape
, the initial matrix.
- optstr, length 1
Indicates the problem to be solved.
The lower bound problem is solved.
The weighted norm problem is solved.
Both problems are solved.
- alphaNone or float, optional
The value of .
If , need not be set.
- wNone or float, array-like, shape , optional
Note: the required length for this argument is determined as follows: if : ; otherwise: .
The square roots of the diagonal elements of , that is the diagonal of .
If , is not referenced and may be None.
- errtolfloat, optional
The termination tolerance for the Newton iteration. If , is used.
- maxitsint, optional
Specifies the maximum number of iterations to be used by the iterative scheme 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 )
On entry, the value of is invalid.
Constraint: , or .
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, all elements of were not positive.
Constraint: , for all .
- (errno )
Newton iteration fails to converge in iterations. Increase or check the call to the function.
- Warns
- NagAlgorithmicWarning
- (errno )
The machine precision is limiting convergence. In this instance the returned value of may be useful.
- (errno )
An intermediate eigenproblem could not be solved. This should not occur. Please contact NAG with details of your call.
- Notes
Finds the nearest correlation matrix by minimizing where is an approximate correlation matrix.
The norm can either be the Frobenius norm or the weighted Frobenius norm .
You can optionally specify a lower bound on the eigenvalues, , of the computed correlation matrix, forcing the matrix to be positive definite, .
Note that if the weights vary by several orders of magnitude from one another the algorithm may fail to converge.
- 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