From: Chuck Cleland <ccleland_at_optonline.net>

Date: Sat 09 Jul 2005 - 05:03:29 EST

Date: Sat 09 Jul 2005 - 05:03:29 EST

K. Steinmann wrote:

> Dear R-helpers,

*>
**> Using the package Lattice, I performed a PCA.
**>
**> For example
**> pca.summary <- summary(pc.cr <- princomp(USArrests, cor = TRUE))
**>
**> The Output of "pca.summary" looks as follows:
**>
**> Importance of components:
**> Comp.1 Comp.2 Comp.3 Comp.4
**> Standard deviation 1.5748783 0.9948694 0.5971291 0.41644938
**> Proportion of Variance 0.6200604 0.2474413 0.0891408 0.04335752
**> Cumulative Proportion 0.6200604 0.8675017 0.9566425 1.00000000
**>
**>
**> How can I extract the proportion of variance?
*

Instead of trying to get it from the summary, how about using this:

eigen(cor(USArrests))$values / ncol(USArrests)

and/or

cumsum(eigen(cor(USArrests))$values / ncol(USArrests))

But note in the details section of ?princomp the following:

The calculation is done using 'eigen' on the correlation or covariance matrix, as determined by 'cor'. This is done for compatibility with the S-PLUS result. A preferred method of calculation is to use 'svd' on 'x', as is done in 'prcomp'.

Thus you could also do:

svd(cor(USArrests))$d / ncol(USArrests)

> Since names(pca.summary) or str(pca.summary) do not contain the proportion of

*> variance,
**> it seems I can not use something similar like pca.summary[[2]]$Comp.1[3].
**> I can't see how the values are stored.
**>
**>
**> Thanks in advance.
**>
**> K. St.
**>
**> ______________________________________________
**> R-help@stat.math.ethz.ch mailing list
**> https://stat.ethz.ch/mailman/listinfo/r-help
**> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
*

-- Chuck Cleland, Ph.D. NDRI, Inc. 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 452-1424 (M, W, F) fax: (917) 438-0894 ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.htmlReceived on Sat Jul 09 05:08:11 2005

*
This archive was generated by hypermail 2.1.8
: Fri 03 Mar 2006 - 03:33:26 EST
*