Skip to content

covmat argument in princomp() (PR#3682)

2 messages · Jerome Asselin, Brian Ripley

#
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(). See code below for an 
example: pc2$center is all NA's.

Jerome Asselin

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)
pc2$scores %*% t(pc2$loadings)-X
pc2$center  # All NA's (should be the same as pc1$center)
x          y
  [1,] 0.1522791 -0.4205906
  [2,] 0.1522791 -0.4205906
  [3,] 0.1522791 -0.4205906
  [4,] 0.1522791 -0.4205906
  [5,] 0.1522791 -0.4205906
  [6,] 0.1522791 -0.4205906
x          y
-0.1522791  0.4205906
x          y
  [1,] 0.1522791 -0.4205906
  [2,] 0.1522791 -0.4205906
  [3,] 0.1522791 -0.4205906
  [4,] 0.1522791 -0.4205906
  [5,] 0.1522791 -0.4205906
  [6,] 0.1522791 -0.4205906
[1] NA NA
#
On Fri, 8 Aug 2003 jerome@hivnet.ubc.ca wrote:

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