From ripley at stats.ox.ac.uk  Fri Aug  8 09:47:46 2003
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Fri Aug  8 09:47:30 2003
Subject: [Rd] covmat argument in princomp() (PR#3682)
In-Reply-To: <200308080046.h780kkJH015348@pubhealth.ku.dk>
Message-ID: <Pine.LNX.4.44.0308080834450.477-100000@gannet.stats>

On Fri, 8 Aug 2003 jerome@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@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


[Rd] covmat argument in princomp() (PR#3682)
Prof Brian Ripley