# naginterfaces.library.correg.corrmat_​shrinking¶

naginterfaces.library.correg.corrmat_shrinking(g, k, errtol=0.0, eigtol=0.0)[source]

corrmat_shrinking computes a correlation matrix, subject to preserving a leading principal submatrix and applying the smallest relative perturbation to the remainder of the approximate input matrix.

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

https://www.nag.com/numeric/nl/nagdoc_29/flhtml/g02/g02anf.html

Parameters
gfloat, array-like, shape

, the initial matrix.

kint

, the order of the leading principal submatrix .

errtolfloat, optional

The termination tolerance for the iteration.

If , is used.

See Accuracy for further details.

eigtolfloat, optional

The tolerance used in determining the definiteness of .

If , where and denote the minimum and maximum eigenvalues of respectively, is positive definite.

If , machine precision is used.

Returns
xfloat, ndarray, shape

Contains the matrix .

alphafloat

.

iteraint

The number of iterations taken.

eigminfloat

The smallest eigenvalue of the leading principal submatrix .

normfloat

The value of after the final iteration.

Raises
NagValueError
(errno )

On entry, .

Constraint: .

(errno )

On entry, and .

Constraint: .

(errno )

The principal leading submatrix of the initial matrix is not positive definite.

(errno )

corrmat_shrinking finds a correlation matrix, , starting from an approximate correlation matrix, , with positive definite leading principal submatrix of order . The returned correlation matrix, , has the following structure:
corrmat_shrinking utilizes a shrinking method to find the minimum value of such that is positive definite with unit diagonal.