PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox: nag_nearest_correlation_h_weight (g02aj)
Purpose
nag_nearest_correlation_h_weight (g02aj) computes the nearest correlation matrix, using element-wise weighting in the Frobenius norm and optionally with bounds on the eigenvalues, to a given square, input matrix.
Syntax
[
g,
h,
x,
iter,
norm_p,
ifail] = g02aj(
g,
alpha,
h, 'n',
n, 'errtol',
errtol, 'maxit',
maxit)
[
g,
h,
x,
iter,
norm_p,
ifail] = nag_nearest_correlation_h_weight(
g,
alpha,
h, 'n',
n, 'errtol',
errtol, 'maxit',
maxit)
Description
nag_nearest_correlation_h_weight (g02aj) finds the nearest correlation matrix, , to an approximate correlation matrix, , using element-wise weighting, this minimizes , where denotes the matrix with elements .
You can optionally specify a lower bound on the eigenvalues, , of the computed correlation matrix, forcing the matrix to be strictly positive definite, if .
Zero elements in
should be used when you wish to put no emphasis on the corresponding element of
. The algorithm scales
so that the maximum element is
. It is this scaled matrix that is used in computing the norm above and for the stopping criteria described in
Accuracy.
Note that if the elements in 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
Jiang K, Sun D and Toh K-C (To appear) An inexact accelerated proximal gradient method for large scale linearly constrained convex SDP
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
Parameters
Compulsory Input Parameters
- 1:
– double array
-
ldg, the first dimension of the array, must satisfy the constraint
.
, the initial matrix.
- 2:
– double scalar
-
The value of
.
If , is used.
Constraint:
.
- 3:
– double array
-
ldh, the first dimension of the array, must satisfy the constraint
.
The matrix of weights .
Constraint:
, for all and , .
Optional Input Parameters
- 1:
– int64int32nag_int scalar
-
Default:
the first dimension of the arrays
h,
g and the second dimension of the arrays
h,
g. (An error is raised if these dimensions are not equal.)
The order of the matrix .
Constraint:
.
- 2:
– double scalar
Default:
The termination tolerance for the iteration. If
then
is used. See
Accuracy for further details.
- 3:
– int64int32nag_int scalar
Default:
Specifies the maximum number of iterations to be used.
If , is used.
Output Parameters
- 1:
– double array
-
- 2:
– double array
-
A symmetric matrix with its diagonal elements set to zero and the remaining elements scaled so that the maximum element is .
- 3:
– double array
-
Contains the nearest correlation matrix.
- 4:
– int64int32nag_int scalar
-
The number of iterations taken.
- 5:
– double scalar
-
The value of after the final iteration.
- 6:
– int64int32nag_int scalar
unless the function detects an error (see
Error Indicators and Warnings).
Error Indicators and Warnings
Errors or warnings detected by the function:
Cases prefixed with W are classified as warnings and
do not generate an error of type NAG:error_n. See nag_issue_warnings.
-
-
Constraint: .
-
-
Constraint: .
-
-
Constraint: .
-
-
Constraint: .
-
-
Constraint: .
-
-
On entry, one or more of the off-diagonal elements of were negative.
-
-
Function fails to converge in
iterations.
Increase
maxit or check the call to the function.
- W
-
Failure to solve intermediate eigenproblem. This should not occur. Please contact
NAG with details of your call.
-
An unexpected error has been triggered by this routine. Please
contact
NAG.
-
Your licence key may have expired or may not have been installed correctly.
-
Dynamic memory allocation failed.
Accuracy
The returned accuracy is controlled by
errtol and limited by
machine precision. If
is the value of
norm_p at the
th iteration, that is
where
has been scaled as described above, then the algorithm terminates when:
Further Comments
Arrays are internally allocated by nag_nearest_correlation_h_weight (g02aj). The total size of these arrays is double elements and integer elements. All allocated memory is freed before return of nag_nearest_correlation_h_weight (g02aj).
Example
This example finds the nearest correlation matrix to:
weighted by:
with minimum eigenvalue
.
Open in the MATLAB editor:
g02aj_example
function g02aj_example
fprintf('g02aj example results\n\n');
g = [ 2, -1, 0, 0;
-1, 2, -1, 0;
0, -1, 2, -1;
0, 0, -1, 2];
h = [ 0.0, 10.0, 0.0, 0.0;
10.0, 0.0, 1.5, 1.5;
0.0, 1.5, 0.0, 0.0;
0.0, 1.5, 0.0, 0.0];
alpha = 0.04;
[g, h, x, iter, norm_p, ifail] = ...
g02aj(g, alpha, h);
fprintf('\nReturned H Matrix\n');
disp(h);
fprintf('Nearest Correlation Matrix\n');
disp(x);
fprintf('Number of iterations taken: %d\n', iter);
fprintf('Norm value: %26.4f\n', norm_p);
fprintf('Alpha: %26.4f\n', alpha);
[~, w, info] = f08fa('n', 'u', x);
fprintf('\nEigenvalues of X\n');
disp(w');
g02aj example results
Returned H Matrix
0 1.0000 0 0
1.0000 0 0.1500 0.1500
0 0.1500 0 0
0 0.1500 0 0
Nearest Correlation Matrix
1.0000 -0.9229 0.7734 0.0026
-0.9229 1.0000 -0.7843 -0.0000
0.7734 -0.7843 1.0000 -0.0615
0.0026 -0.0000 -0.0615 1.0000
Number of iterations taken: 66
Norm value: 0.1183
Alpha: 0.0400
Eigenvalues of X
0.0769 0.2637 1.0031 2.6563
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015