Skip to content
Prev 10205 / 63424 Next

covmat argument in princomp() (PR#3682)

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