[Rd] covmat argument in princomp() (PR#3682)
Prof Brian Ripley
ripley at stats.ox.ac.uk
Fri Aug 8 09:47:46 MEST 2003
On Fri, 8 Aug 2003 jerome at hivnet.ubc.ca wrote:
> R version: 1.7.1
> OS: Red Hat Linux 7.2
>
> When "covmat" is supplied in princomp(), the output value "center" is all
> NA's, even though the input matrix was indeed centered. I haven't read
> anything about this in the help file for princomp().
You *did* try to read the help page? You seem to have failed to read the
description of `value', which says
center: the means that were subtracted.
> See code below for an example: pc2$center is all NA's.
> x <- rnorm(6)
> y <- rnorm(6)
> X <- cbind(x,y)
> pc1 <- princomp(X)
> pc1$scores %*% t(pc1$loadings)-X
> pc1$center
> pc2 <- princomp(X,covmat=cov(X)*5/6)
If you had read either the help page or the code, you would have seen
that x is not used when you supply covmat. So although means were
subtracted, they were done by you not princomp(), and NA is the right
answer.
--
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-devel
mailing list