[R] princomp with not non-negative definite correlation matrix
Prof Brian Ripley
ripley at stats.ox.ac.uk
Mon Apr 14 10:27:48 CEST 2003
On Thu, 10 Apr 2003 tvr at stanford.edu wrote:
> $ R --version
> R 1.6.1 (2002-11-01).
>
> So I would like to perform principal components analysis on a 16X16
> correlation matrix, [princomp(cov.mat=x) where x is correlation matrix],
> the problem is princomp complains that it is not non-negative definite.
>
> I called eigen() on the correlation matrix and found that one of the
> eigenvectors is close to zero & negative (-0.001832311). Is there any
> way to work around this problem. A constraint: I only have the
> correlation matrix, not the data that produced it.
>
> I believe I could replicate most of the functionality of princomp
> step-by-step (loadings, scores, etc.) and track the effect of the
> negative eigenvector on the rest of the analysis, but I'd rather not do
> that with every covariance/correlation matrix that might have a few
> eigenvectors that are negative but close to zero.
No correlation/covariance matrix ever has negative eigenvectors, so
princomp is correctly telling you that you have a problem.
I have no idea what your matrix is, but it is not a correlation matrix.
Possibly it has been written out and rounded? In that case try
setting the negative eigenvalues to zero. But I would want to be sure
that there was not some more serious error in the correlation matrix.
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list