[R] prcomp - principal components in R

markleeds at verizon.net markleeds at verizon.net
Mon Nov 9 19:27:19 CET 2009


   Hi: I'm not familar with prcomp but with the principal components function
   in bill revelle's  psych package , one can specify the number of components
   one wants to use to build the "closest" covariance matrix  I don't know
   what tol is doing in your example  but it's not doing  that.
   Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â
   Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â
   Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â
   Â Â Â Â Â Â Â Â Â Â Â Â Â  mark

   On Nov 9, 2009, zubin <binabina at bellsouth.net> wrote:

     All 8 variables are still in the analysis, i am just reducing the number
     of components being estimated i thought..
     Example 1 component 8 variables, there is no way 1 component explains
     100% of the variance of the 8 variable data set.
     > princ = prcomp(df[,-1],rotate="varimax",scale=TRUE,tol=.95)
     > summary(princ)
     Importance of components:
     PC1
     Standard deviation 1.38
     Proportion of Variance 1.00
     Cumulative Proportion 1.00
     > summary(princ)
     Rotation:
     PC1
     VIX0 -0.08217686
     UUP0 -0.18881983
     USO0 0.26647346
     GLD0 0.26983923
     HYG0 0.60674758
     term0 0.18220237
     spread0 0.61614047
     TNX0 0.18111684
     Daniel Malter wrote:
     > In the first PCA you ask how much variance of the EIGHT (!) variables is
     > captured by the first, second,..., eigth principal component.
     >
     > In the second PCA you ask how much variance of the THREE (!) variables
     is
     > captured by the first, second, and third principal component.
     >
     > Of course you need only as many PCs as there are variables to capture
     100 %
     > of the variance. Your "problem" thus comes from the fact that you have
     eight
     > variables in the first PCA, which requires eight PCs to capture 100%,
     and
     > that you have only three variables in the second PCA, which naturally
     only
     > requires three PCs to capture 100% of the variance.
     >
     > So it's more, yes, you are missing something in this case, rather than
     that
     > something is wrong with the analyses.
     >
     > HTH,
     > Daniel
     >
     > -------------------------
     > cuncta stricte discussurus
     > -------------------------
     >
     > -----Ursprüngliche Nachricht-----
     > Von: [1]r-help-bounces at r-project.org
     [[2]mailto:r-help-bounces at r-project.org] Im
     > Auftrag von zubin
     > Gesendet: Monday, November 09, 2009 12:37 PM
     > An: [3]r-help at r-project.org
     > Betreff: [R] prcomp - principal components in R
     >
     > Hello, not understanding the output of prcomp, I reduce the number of
     > components and the output continues to show cumulative 100% of the
     variance
     > explained, which can't be the case dropping from 8 components to 3.
     >
     > How do i get the output in terms of the cumulative % of the total
     variance,
     > so when i go from total solution of 8 (8 variables in the data set), to
     a
     > reduced number of components, i can evaluate % of variance explained, or
     am
     > I missing something??
     >
     > 8 variables in the data set
     >
     > > princ = prcomp(df[,-1],rotate="varimax",scale=TRUE)
     > > summary(princ)
     > Importance of components:
     > PC1 PC2 PC3 PC4 PC5 PC6 PC7 PC8
     > Standard deviation 1.381 1.247 1.211 0.994 0.927 0.764 0.6708 0.4366
     > Proportion of Variance 0.238 0.194 0.183 0.124 0.107 0.073 0.0562 0.0238
     >  Cumulative Proportion 0.238 0.433 0.616 0.740 0.847 0.920 0.9762
     *1.0000*
     >
     > > princ = prcomp(df[,-1],rotate="varimax",scale=TRUE,tol=.75)
     > > summary(princ)
     >
     > Importance of components:
     > PC1 PC2 PC3
     > Standard deviation 1.381 1.247 1.211
     > Proportion of Variance 0.387 0.316 0.297 Cumulative Proportion 0.387
     0.703
     > *1.000*
     >
     > [[alternative HTML version deleted]]
     >
     > ______________________________________________
     > [4]R-help at r-project.org mailing list
     > [5]https://stat.ethz.ch/mailman/listinfo/r-help
     > PLEASE do read the posting guide
     [6]http://www.R-project.org/posting-guide.html
     > and provide commented, minimal, self-contained, reproducible code.
     >
     >
     >
     ______________________________________________
     [7]R-help at r-project.org mailing list
     [8]https://stat.ethz.ch/mailman/listinfo/r-help
     PLEASE do read the posting guide
     [9]http://www.R-project.org/posting-guide.html
     and provide commented, minimal, self-contained, reproducible code.

References

   1. mailto:r-help-bounces at r-project.org
   2. mailto:r-help-bounces at r-project.org
   3. mailto:r-help at r-project.org
   4. mailto:R-help at r-project.org
   5. https://stat.ethz.ch/mailman/listinfo/r-help
   6. http://www.R-project.org/posting-guide.html
   7. mailto:R-help at r-project.org
   8. https://stat.ethz.ch/mailman/listinfo/r-help
   9. http://www.R-project.org/posting-guide.html



More information about the R-help mailing list