g02ae computes the factor loading matrix associated with the nearest correlation matrix with k-factor structure, in the Frobenius norm, to a given square, input matrix.


public static void g02ae(
	double[,] g,
	int n,
	int k,
	double errtol,
	int maxit,
	double[,] x,
	out int iter,
	out int feval,
	out double nrmpgd,
	out int ifail
Visual Basic
Public Shared Sub g02ae ( _
	g As Double(,), _
	n As Integer, _
	k As Integer, _
	errtol As Double, _
	maxit As Integer, _
	x As Double(,), _
	<OutAttribute> ByRef iter As Integer, _
	<OutAttribute> ByRef feval As Integer, _
	<OutAttribute> ByRef nrmpgd As Double, _
	<OutAttribute> ByRef ifail As Integer _
Visual C++
static void g02ae(
	array<double,2>^ g, 
	int n, 
	int k, 
	double errtol, 
	int maxit, 
	array<double,2>^ x, 
	[OutAttribute] int% iter, 
	[OutAttribute] int% feval, 
	[OutAttribute] double% nrmpgd, 
	[OutAttribute] int% ifail
static member g02ae : 
        g : float[,] * 
        n : int * 
        k : int * 
        errtol : float * 
        maxit : int * 
        x : float[,] * 
        iter : int byref * 
        feval : int byref * 
        nrmpgd : float byref * 
        ifail : int byref -> unit 


Type: array<System..::..Double,2>[,](,)[,][,]
An array of size [dim1, n]
Note: dim1 must satisfy the constraint: dim1n
On entry: G, the initial matrix.
On exit: a symmetric matrix 12G+GT with the diagonal elements set to unity.
Type: System..::..Int32
On entry: n, the order of the matrix G.
Constraint: n>0.
Type: System..::..Int32
On entry: k, the number of factors and columns of X.
Constraint: 0<kn.
Type: System..::..Double
On entry: the termination tolerance for the projected gradient norm. See references for further details. If errtol0.0 then 0.01 is used. This is often a suitable default value.
Type: System..::..Int32
On entry: specifies the maximum number of iterations in the spectral projected gradient method.
If maxit0, 40000 is used.
Type: array<System..::..Double,2>[,](,)[,][,]
An array of size [dim1, k]
Note: dim1 must satisfy the constraint: dim1n
On exit: contains the matrix X.
Type: System..::..Int32%
On exit: the number of steps taken in the spectral projected gradient method.
Type: System..::..Int32%
On exit: the number of evaluations of G-XXT+diagXXT-IF.
Type: System..::..Double%
On exit: the norm of the projected gradient at the final iteration.
Type: System..::..Int32%
On exit: ifail=0 unless the method detects an error or a warning has been flagged (see [Error Indicators and Warnings]).


A correlation matrix C with k-factor structure may be characterised as a real square matrix that is symmetric, has a unit diagonal, is positive semidefinite and can be written as C=XXT+diagI-XXT, where I is the identity matrix and X has n rows and k columns. X is often referred to as the factor loading matrix.
g02ae applies a spectral projected gradient method to the modified problem minG-XXT+diagXXT-IF such that xiT21, for i=1,2,,n, where xi is the ith row of the factor loading matrix, X, which gives us the solution.


Birgin E G, Martínez J M and Raydan M (2001) Algorithm 813: SPG–software for convex-constrained optimization ACM Trans. Math. Software 27 340–349
Borsdorf R, Higham N J and Raydan M (2010) Computing a nearest correlation matrix with factor structure. SIAM J. Matrix Anal. Appl. 31(5) 2603–2622

Error Indicators and Warnings

Errors or warnings detected by the method:
Some error messages may refer to parameters that are dropped from this interface (LDG, LDX) In these cases, an error in another parameter has usually caused an incorrect value to be inferred.
On entry, k=value and n=value.
Constraint: 0<kn.
On entry, ldg=value and n=value.
Constraint: ldgn.
On entry, ldx=value and n=value.
Constraint: ldxn.
On entry, n=value.
Constraint: n>0.
Spectral gradient method fails to converge in value iterations.
Dynamic memory allocation failed.
An error occured, see message report.
Invalid Parameters value
Invalid dimension for array value
Negative dimension for array value
Invalid Parameters value


The returned accuracy is controlled by errtol and limited by machine precision.

Parallelism and Performance


Further Comments

Arrays are internally allocated by g02ae. The total size of these arrays is n×n+4×n×k+nb+3×n+n+50 real elements and 6×n integer elements. Here nb is the block size required for optimal performance by (F08FEF not in this release) (F08FGF not in this release) which are called internally. All allocated memory is freed before return of g02ae.
See (G03CAF not in this release) for constructing the factor loading matrix from a known correlation matrix.


This example finds the nearest correlation matrix with k=2 factor structure to:

Example program (C#): g02aee.cs

Example program data: g02aee.d

Example program results: g02aee.r

See Also