While using princomp() function in R, the following error is encountered : "covariance matrix is not non-negative definite".
I think, this is due to some values being zero (actually close to zero, but becomes zero during rounding) in the covariance matrix.
Is there a work around to proceed with PCA when covariance matrix contains zeros ?
[FYI : obtaining the covariance matrix is an intermediate step within the princomp() call. Data file to reproduce this error can be downloaded from here – http://tinyurl.com/6rtxrc3%5D
The first strategy might be to decrease the tolerance argument. Looks to me that
princompwon’t pass on a tolerance argument but thatprcompdoes accept a ‘tol’ argument. If not effective, this should identify vectors which have nearly-zero covariance:And this would identify vectors with negative eigenvalues:
Using the h9 example on the help(qr) page:
Another approach might be to use the
aliasfunction: