# prcomp - principal components in R

9 messages
Open this post in threaded view
|

## 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]] ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|

## Re: prcomp - principal components in R

 principal components is  a data reduction technique.  It looks like you have three axes that account for 100%.  Make this reporducible. On Mon, Nov 9, 2009 at 11:37 AM, zubin <[hidden email]> wrote: > 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]] > > ______________________________________________ > [hidden email] mailing list > https://stat.ethz.ch/mailman/listinfo/r-help> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code. > -- Stephen Sefick Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods.  We are mammals, and have not exhausted the annoying little problems of being mammals.                                                                 -K. Mullis ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|

## Re: prcomp - principal components in R

 okay, an extreme case, only 1 component, explains 100%, something weird going on..  > 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 stephen sefick wrote: > principal components is  a data reduction technique.  It looks like > you have three axes that account for 100%.  Make this reporducible. > > On Mon, Nov 9, 2009 at 11:37 AM, zubin <[hidden email]> wrote: >   >> 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]] >> >> ______________________________________________ >> [hidden email] mailing list >> https://stat.ethz.ch/mailman/listinfo/r-help>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html>> and provide commented, minimal, self-contained, reproducible code. >> >>     > > > >           [[alternative HTML version deleted]] ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|

## Re: prcomp - principal components in R

 Look at it linearly? On Mon, Nov 9, 2009 at 11:45 AM, zubin <[hidden email]> wrote: > okay, an extreme case, only 1 component, explains 100%, something weird > going on.. > >  > 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 > > stephen sefick wrote: >> principal components is  a data reduction technique.  It looks like >> you have three axes that account for 100%.  Make this reporducible. >> >> On Mon, Nov 9, 2009 at 11:37 AM, zubin <[hidden email]> wrote: >> >>> 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]] >>> >>> ______________________________________________ >>> [hidden email] mailing list >>> https://stat.ethz.ch/mailman/listinfo/r-help>>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html>>> and provide commented, minimal, self-contained, reproducible code. >>> >>> >> >> >> >> > >        [[alternative HTML version deleted]] > > ______________________________________________ > [hidden email] mailing list > https://stat.ethz.ch/mailman/listinfo/r-help> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code. > -- Stephen Sefick Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods.  We are mammals, and have not exhausted the annoying little problems of being mammals.                                                                 -K. Mullis ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|

## Re: prcomp - principal components in R

 In reply to this post by zubin-2 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: [hidden email] [mailto:[hidden email]] Im Auftrag von zubin Gesendet: Monday, November 09, 2009 12:37 PM An: [hidden email] 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]] ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code. ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|

## Re: prcomp - principal components in R

 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: [hidden email] [mailto:[hidden email]] Im > Auftrag von zubin > Gesendet: Monday, November 09, 2009 12:37 PM > An: [hidden email] > 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]] > > ______________________________________________ > [hidden email] mailing list > https://stat.ethz.ch/mailman/listinfo/r-help> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code. > > > ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|