[R] PCA functions

Gavin Simpson gavin.simpson at ucl.ac.uk
Mon Feb 16 11:59:47 CET 2009


On Mon, 2009-02-16 at 10:45 +0000, S Ellison wrote:
> princomp uses the raw data and calculates the correlation or
> covariance matrix on the way to the PC's, so that doesn't use a
> correlation matrix itself. You do, however, get the choice.

That *isn't* what princomp() does. If you supply a valid covariance
matrix via argument 'covmat', princomp() uses that instead of
calculating one from the input data.

That is what ?princomp says it does, as does the R source, the true
reference.

G

> 
> However, PC's are the eigenvectors of the correlation (or covariance)
> matrix, so in principle calling eigen() on either would be sufficient
> for the PC's. The signs may differ, though, as they are arbitrary;
> compare prcomp(USArrests)$rotation with eigen(cov(USArrests)).
> 
> S
> 
> 
> 
> 
> >>> Bjørn-Helge Mevik <b.h.mevik at usit.uio.no> 16/02/2009 09:05 >>>
> "glenn" <g1enn.roberts at btinternet.com> writes:
> 
> > Is there a function (before I try and write it !) that allows the input of a
> > covariance or correlation matrix to calculate PCA, rather than the actual
> > data as in princomp()
> 
> Yes, there is: princomp(). :-)
> 
> 
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson             [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,          [f] +44 (0)20 7679 0565
 Pearson Building,             [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London          [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT.                 [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20090216/9942fd50/attachment.bin>


More information about the R-help mailing list