[R] PCA functions

S Ellison S.Ellison at lgc.co.uk
Mon Feb 16 13:24:42 CET 2009

Many apologies for the poor steer; you are quite right. 

'fraid I hit 'send' before double-checking the help page myself. Next time...


>>> Gavin Simpson <gavin.simpson at ucl.ac.uk> 16/02/2009 10:59 >>>
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


> 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 

This email and any attachments are confidential. Any use...{{dropped:8}}

More information about the R-help mailing list