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 <- rnorm(6)
> y <- rnorm(6)
> X <- cbind(x,y)
> pc1 <- princomp(X)
> pc1$scores %*% t(pc1$loadings)-X
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> pc1$center
x y
-0.1522791 0.4205906> pc2 <- princomp(X,covmat=cov(X)*5/6)
> pc2$scores %*% t(pc2$loadings)-X
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> pc2$center # All NA's (should be the same as pc1$center)
[1] NA NA
--
Jerome Asselin (Jérôme), Statistical Analyst
British Columbia Centre for Excellence in HIV/AIDS
St. Paul's Hospital, 608 - 1081 Burrard Street
Vancouver, British Columbia, CANADA V6Z 1Y6
Email: jerome@hivnet.ubc.ca
Phone: 604 806-9112 Fax: 604 806-9044