Usage
QDIAG simultaneous approximate matrix diagonalization
W = qdiag( C0, C) finds a matrix W so that W'*C0*W has diagonal elements equal to 1 and W'*C(:,:,i)*W has smallest possible off-diagonal elements. C0 is a positive definite NxN matrix, and C is a NxNxK array of K correlation matrices.
W = qdiag( C0, C, p), where p is a vector with K positive elements, weights the matrices in C according to them. An empty vector has the effect that all matrices are weighted equally.
qdiag( C0, C, p, opt) allows to pass an option structure. opt can have the following fields (default values are taken for missing fields):
'verbose' : print informational messages in every iteration (default: false)
'approach' : implementation of QDIAG, O(KN^3) or O(N^5), see [1]. Possible values 'OKN3','ON5' (default: 'OKN3'):
'Nit' : maximum number of iterations (default 100)
'tol_w' : Stopping criterion. Changes of w smaller than this value terminate the iterations (default: 1e-4)
'evmethod' : Matlab eigenvalue method. Possible values 'eig','eigs' (default: 'eig')
'W' : used as the inital W (default: random NxN matrix)
'M' : number components, columns of W (default: M=N) opt.W has priority over opt.M
[W, errlog] = qdiag( C0, C, p, opt) additionally outputs the diagonalization error in every iteration.
[W, errlog, Wlog] = qdiag( C0, C, p, opt) additionally outputs the elements of W in every iteration.
CORRMAT compute lagged correlation matrices
Use corrmat to compute a set of correlation matrices to be diagonalized with qdiag or any other matrix diagonalization algorithm.
C = corrmat(x, lags), where x is a TxN matrix and lags is a K-element vector of whole numbers, computes K lagged NxN correlation matrices of the row vectors in x.
C = corrmat(x, lags, method) uses method to compute the matrices. method can be 'cov' (compute covariance matrices, default) or 'moments' (compute matrices of second moments).
C = corrmat(x, lags, method, symmetrize), where symmetrize is a scalar boolean, can be used to explicitely symmetrize the resulting correlation matrices (default: symmetrize==false).
[C,C0] = corrmat(x, lags, ... ) additionally returns in C0 the matrix C(:,:,k) for which lags(k) = 0 (if there is any).