[R] Re: trouble with prcomp()

Prof Brian Ripley ripley at stats.ox.ac.uk
Mon Jun 14 10:03:56 CEST 2004


Centring and scaling.  The code is very easy to real, and contains

    x <- as.matrix(x)
    x <- scale(x, center = center, scale = scale.)

Note that the help page does say

     The calculation is done by a singular value decomposition of the
     (centered and scaled) data matrix ....


On Mon, 14 Jun 2004, Scott Robbins Loarie wrote:

> Thanks very much for showing me these functions,
> 
> In prcomp(), the documentation says that Value: x is "the data
> multiplied by the 'rotation' matix".  Using sample data:
> 
> data(iris)
> iris<-as.matrix(iris[,1:4])
> pcprim<-prcomp(iris, scale=TRUE)
> 
> Why does iris%*%pcprim$rotation (the data multiplied by the rotation
> matrix) not equal pcprim$x?
> 
> Thanks very much,
> 
> Scott
> 
> 
> On Mon, 14 Jun 2004, Prof Brian Ripley wrote:
> 
> > Why are you using the OPRHANED multiv library for a facility covered by
> > princomp() and prcomp() in base R?  The list might be able to help you
> > with the latter, but no one is supporting multiv (hence its status).
> >
> > On Sun, 13 Jun 2004, Scott Robbins Loarie wrote:
> >
> > > I am having trouble using the pca function in the multiv library.
> > > I am trying to generate the values found in $rproj by using $evecs to
> > > calculate linear combinations of my input data.  However, I have been not
> > > been able to correctly calculate the $rproj values.
> > >
> > > Using the following standard sample data, why does iris%*%pcprim$evecs[,]
> > > not equal pcprim$rproj?
> > >
> > > data(iris)
> > > iris<-as.matrix(iris[,1:4])
> > > pcprim<-pca(iris)
> >
> > --
> > 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
> >
> 
> 

-- 
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