I have a question about princomp(mva) that I hope isn't too newbie. I used the sample data from Table 1.1 in "Manly (1986/1994) Multivariate Statistical Methods: a primer. Chapman and Hall" on sparrow body measurements. I rescaled the data to mean 0 and SD 1, and the covariance matrix is: V1 V2 V3 V4 V5 V1 1.0000000 0.7349642 0.6618119 0.6452841 0.6051247 V2 0.7349642 1.0000000 0.6737411 0.7685087 0.5290138 V3 0.6618119 0.6737411 1.0000000 0.7631899 0.5262701 V4 0.6452841 0.7685087 0.7631899 1.0000000 0.6066493 V5 0.6051247 0.5290138 0.5262701 0.6066493 1.0000000 Now when I call princomp [fun<-princomp(~V1+V2+V3+V4+V5)], I get the following loadings: Comp.1 Comp.2 Comp.3 Comp.4 Comp.5 V1 -0.4517989 -0.05072137 0.6904702 0.42041399 -0.3739091 V2 -0.4616809 0.29956355 0.3405484 -0.54786307 0.5300805 V3 -0.4505416 0.32457242 -0.4544927 0.60629605 0.3427923 V4 -0.4707389 0.18468403 -0.4109350 -0.38827811 -0.6516665 V5 -0.3976754 -0.87648935 -0.1784558 -0.06887199 0.1924341 However, this is in contrast to the results in Manly's book: Comp.1 Comp.2 Comp.3 Comp.4 Comp.5 V1 0.4517989 -0.05072137 0.6904702 -0.42041399 0.3739091 V2 0.4616809 0.29956355 0.3405484 0.54786307 -0.5300805 V3 0.4505416 0.32457242 -0.4544927 -0.60629605 -0.3427923 V4 0.4707389 0.18468403 -0.4109350 0.38827811 0.6516665 V5 0.3976754 -0.87648935 -0.1784558 0.06887199 -0.1924341 Interestingly, when I do the same in SAS, I get: Comp.1 Comp.2 Comp.3 Comp.4 Comp.5 V1 0.4517989 0.05072137 -0.6904702 0.42041399 -0.3739091 V2 0.4616809 -0.29956355 -0.3405484 -0.54786307 0.5300805 V3 0.4505416 -0.32457242 0.4544927 0.60629605 0.3427923 V4 0.4707389 -0.18468403 0.4109350 -0.38827811 -0.6516665 V5 0.3976754 0.87648935 0.1784558 -0.06887199 0.1924341 Finally, when I do it by "hand" in R (i.e., c<-cov(data); e<-eigen(c)), I get a fourth answer: V5 V4 V3 V2 V1 V1 0.4517989 0.05072137 -0.6904702 -0.42041399 -0.3739091 V2 0.4616809 -0.29956355 -0.3405484 0.54786307 0.5300805 V3 0.4505416 -0.32457242 0.4544927 -0.60629605 0.3427923 V4 0.4707389 -0.18468403 0.4109350 0.38827811 -0.6516665 V5 0.3976754 0.87648935 0.1784558 0.06887199 0.1924341 Can anyone point me in the right direction here? I can email the raw data to anyone if that would help. Thank you in advance... Damien -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
It seems that you have gotten the same answer as the book, with the exception that the first, fourth and fifth components have different signs. I believe that when doing eigenvalue decompositions it's possible (and I think documented) that you might get a sign flip here and there depending on your machine. It appears that princomp.default() uses La.eigen() and the help page for La.eigen says: `La.eigen' is preferred to `eigen' for new projects, but its eigenvectors may differ in sign and (in the asymmetric case) in normalization. (They may also differ between methods and between platforms.) Nevertheless, your PCA results will still be valid. -roger _______________________________ UCLA Department of Statistics rpeng at stat.ucla.edu http://www.stat.ucla.edu/~rpeng On Wed, 10 Apr 2002, Damien Joly wrote:> I have a question about princomp(mva) that I hope isn't too newbie. > > I used the sample data from Table 1.1 in "Manly (1986/1994) Multivariate > Statistical Methods: a primer. Chapman and Hall" on sparrow body > measurements. > > I rescaled the data to mean 0 and SD 1, and the covariance matrix is: > > V1 V2 V3 V4 V5 > V1 1.0000000 0.7349642 0.6618119 0.6452841 0.6051247 > V2 0.7349642 1.0000000 0.6737411 0.7685087 0.5290138 > V3 0.6618119 0.6737411 1.0000000 0.7631899 0.5262701 > V4 0.6452841 0.7685087 0.7631899 1.0000000 0.6066493 > V5 0.6051247 0.5290138 0.5262701 0.6066493 1.0000000 > > Now when I call princomp [fun<-princomp(~V1+V2+V3+V4+V5)], I get the > following loadings: > > Comp.1 Comp.2 Comp.3 Comp.4 Comp.5 > V1 -0.4517989 -0.05072137 0.6904702 0.42041399 -0.3739091 > V2 -0.4616809 0.29956355 0.3405484 -0.54786307 0.5300805 > V3 -0.4505416 0.32457242 -0.4544927 0.60629605 0.3427923 > V4 -0.4707389 0.18468403 -0.4109350 -0.38827811 -0.6516665 > V5 -0.3976754 -0.87648935 -0.1784558 -0.06887199 0.1924341 > > However, this is in contrast to the results in Manly's book: > > Comp.1 Comp.2 Comp.3 Comp.4 Comp.5 > V1 0.4517989 -0.05072137 0.6904702 -0.42041399 0.3739091 > V2 0.4616809 0.29956355 0.3405484 0.54786307 -0.5300805 > V3 0.4505416 0.32457242 -0.4544927 -0.60629605 -0.3427923 > V4 0.4707389 0.18468403 -0.4109350 0.38827811 0.6516665 > V5 0.3976754 -0.87648935 -0.1784558 0.06887199 -0.1924341 > > Interestingly, when I do the same in SAS, I get: > > Comp.1 Comp.2 Comp.3 Comp.4 Comp.5 > V1 0.4517989 0.05072137 -0.6904702 0.42041399 -0.3739091 > V2 0.4616809 -0.29956355 -0.3405484 -0.54786307 0.5300805 > V3 0.4505416 -0.32457242 0.4544927 0.60629605 0.3427923 > V4 0.4707389 -0.18468403 0.4109350 -0.38827811 -0.6516665 > V5 0.3976754 0.87648935 0.1784558 -0.06887199 0.1924341 > > Finally, when I do it by "hand" in R (i.e., c<-cov(data); e<-eigen(c)), > I get a fourth answer: > > V5 V4 V3 V2 V1 > V1 0.4517989 0.05072137 -0.6904702 -0.42041399 -0.3739091 > V2 0.4616809 -0.29956355 -0.3405484 0.54786307 0.5300805 > V3 0.4505416 -0.32457242 0.4544927 -0.60629605 0.3427923 > V4 0.4707389 -0.18468403 0.4109350 0.38827811 -0.6516665 > V5 0.3976754 0.87648935 0.1784558 0.06887199 0.1924341 > > > Can anyone point me in the right direction here? I can email the raw > data to anyone if that would help. > > Thank you in advance... > > Damien > > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- > r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html > Send "info", "help", or "[un]subscribe" > (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._ >-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Wed, 10 Apr 2002, Damien Joly wrote:> Now when I call princomp [fun<-princomp(~V1+V2+V3+V4+V5)], I get the > following loadings: > > Comp.1 Comp.2 Comp.3 Comp.4 Comp.5 > V1 -0.4517989 -0.05072137 0.6904702 0.42041399 -0.3739091 > V2 -0.4616809 0.29956355 0.3405484 -0.54786307 0.5300805 > V3 -0.4505416 0.32457242 -0.4544927 0.60629605 0.3427923 > V4 -0.4707389 0.18468403 -0.4109350 -0.38827811 -0.6516665 > V5 -0.3976754 -0.87648935 -0.1784558 -0.06887199 0.1924341 > > However, this is in contrast to the results in Manly's book: > > Comp.1 Comp.2 Comp.3 Comp.4 Comp.5 > V1 0.4517989 -0.05072137 0.6904702 -0.42041399 0.3739091 > V2 0.4616809 0.29956355 0.3405484 0.54786307 -0.5300805 > V3 0.4505416 0.32457242 -0.4544927 -0.60629605 -0.3427923 > V4 0.4707389 0.18468403 -0.4109350 0.38827811 0.6516665 > V5 0.3976754 -0.87648935 -0.1784558 0.06887199 -0.1924341<and two other ways snipped> These four are all the same principal components, it's just that the sign is reversed on some of them. That is, if vectors (v1,v2,v3,v4,v5) are principal components, so are (-v1,-v2,-v3,-v4,-v5), or as in this case (v1, v2,v3,-v4,-v5). Principal components are only defined up to sign changes (they specify lines in n-space and you can go along a line in either direction). Different computations will likely give different signs -thomas Thomas Lumley Asst. Professor, Biostatistics tlumley at u.washington.edu University of Washington, Seattle -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Dear Damien, Principal components are identified up to a reflection through the origin, so the solutions are really all equivalent -- corresponding components are the same, except for a possible change in sign. John At 05:43 PM 4/10/2002 -0500, you wrote:>I have a question about princomp(mva) that I hope isn't too newbie. > >I used the sample data from Table 1.1 in "Manly (1986/1994) Multivariate >Statistical Methods: a primer. Chapman and Hall" on sparrow body measurements. > >I rescaled the data to mean 0 and SD 1, and the covariance matrix is: > > V1 V2 V3 V4 V5 >V1 1.0000000 0.7349642 0.6618119 0.6452841 0.6051247 >V2 0.7349642 1.0000000 0.6737411 0.7685087 0.5290138 >V3 0.6618119 0.6737411 1.0000000 0.7631899 0.5262701 >V4 0.6452841 0.7685087 0.7631899 1.0000000 0.6066493 >V5 0.6051247 0.5290138 0.5262701 0.6066493 1.0000000 > >Now when I call princomp [fun<-princomp(~V1+V2+V3+V4+V5)], I get the >following loadings: > > Comp.1 Comp.2 Comp.3 Comp.4 Comp.5 >V1 -0.4517989 -0.05072137 0.6904702 0.42041399 -0.3739091 >V2 -0.4616809 0.29956355 0.3405484 -0.54786307 0.5300805 >V3 -0.4505416 0.32457242 -0.4544927 0.60629605 0.3427923 >V4 -0.4707389 0.18468403 -0.4109350 -0.38827811 -0.6516665 >V5 -0.3976754 -0.87648935 -0.1784558 -0.06887199 0.1924341 > >However, this is in contrast to the results in Manly's book: > > Comp.1 Comp.2 Comp.3 Comp.4 Comp.5 >V1 0.4517989 -0.05072137 0.6904702 -0.42041399 0.3739091 >V2 0.4616809 0.29956355 0.3405484 0.54786307 -0.5300805 >V3 0.4505416 0.32457242 -0.4544927 -0.60629605 -0.3427923 >V4 0.4707389 0.18468403 -0.4109350 0.38827811 0.6516665 >V5 0.3976754 -0.87648935 -0.1784558 0.06887199 -0.1924341 > >Interestingly, when I do the same in SAS, I get: > > Comp.1 Comp.2 Comp.3 Comp.4 Comp.5 >V1 0.4517989 0.05072137 -0.6904702 0.42041399 -0.3739091 >V2 0.4616809 -0.29956355 -0.3405484 -0.54786307 0.5300805 >V3 0.4505416 -0.32457242 0.4544927 0.60629605 0.3427923 >V4 0.4707389 -0.18468403 0.4109350 -0.38827811 -0.6516665 >V5 0.3976754 0.87648935 0.1784558 -0.06887199 0.1924341 > >Finally, when I do it by "hand" in R (i.e., c<-cov(data); e<-eigen(c)), I >get a fourth answer: > > V5 V4 V3 V2 V1 >V1 0.4517989 0.05072137 -0.6904702 -0.42041399 -0.3739091 >V2 0.4616809 -0.29956355 -0.3405484 0.54786307 0.5300805 >V3 0.4505416 -0.32457242 0.4544927 -0.60629605 0.3427923 >V4 0.4707389 -0.18468403 0.4109350 0.38827811 -0.6516665 >V5 0.3976754 0.87648935 0.1784558 0.06887199 0.1924341 > > >Can anyone point me in the right direction here? I can email the raw data >to anyone if that would help. > >Thank you in advance... > >Damien----------------------------------------------------- John Fox Department of Sociology McMaster University Hamilton, Ontario, Canada L8S 4M4 email: jfox at mcmaster.ca phone: 905-525-9140x23604 web: www.socsci.mcmaster.ca/jfox ----------------------------------------------------- -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
IMHO try princomp [fun<-princomp(V1+V2+V3+V4+V5)] without ~ for negation in this manner !? regards,christian Am 11.04.2002 00:43:43, schrieb Damien Joly <do_joly at yahoo.ca>:>I have a question about princomp(mva) that I hope isn't too newbie. > >I used the sample data from Table 1.1 in "Manly (1986/1994) Multivariate >Statistical Methods: a primer. Chapman and Hall" on sparrow body >measurements. > >I rescaled the data to mean 0 and SD 1, and the covariance matrix is: > > V1 V2 V3 V4 V5 >V1 1.0000000 0.7349642 0.6618119 0.6452841 0.6051247 >V2 0.7349642 1.0000000 0.6737411 0.7685087 0.5290138 >V3 0.6618119 0.6737411 1.0000000 0.7631899 0.5262701 >V4 0.6452841 0.7685087 0.7631899 1.0000000 0.6066493 >V5 0.6051247 0.5290138 0.5262701 0.6066493 1.0000000 > >Now when I call princomp [fun<-princomp(~V1+V2+V3+V4+V5)], I get the >following loadings: > > Comp.1 Comp.2 Comp.3 Comp.4 Comp.5 >V1 -0.4517989 -0.05072137 0.6904702 0.42041399 -0.3739091 >V2 -0.4616809 0.29956355 0.3405484 -0.54786307 0.5300805 >V3 -0.4505416 0.32457242 -0.4544927 0.60629605 0.3427923 >V4 -0.4707389 0.18468403 -0.4109350 -0.38827811 -0.6516665 >V5 -0.3976754 -0.87648935 -0.1784558 -0.06887199 0.1924341 > >However, this is in contrast to the results in Manly's book: > > Comp.1 Comp.2 Comp.3 Comp.4 Comp.5 >V1 0.4517989 -0.05072137 0.6904702 -0.42041399 0.3739091 >V2 0.4616809 0.29956355 0.3405484 0.54786307 -0.5300805 >V3 0.4505416 0.32457242 -0.4544927 -0.60629605 -0.3427923 >V4 0.4707389 0.18468403 -0.4109350 0.38827811 0.6516665 >V5 0.3976754 -0.87648935 -0.1784558 0.06887199 -0.1924341 > >Interestingly, when I do the same in SAS, I get: > > Comp.1 Comp.2 Comp.3 Comp.4 Comp.5 >V1 0.4517989 0.05072137 -0.6904702 0.42041399 -0.3739091 >V2 0.4616809 -0.29956355 -0.3405484 -0.54786307 0.5300805 >V3 0.4505416 -0.32457242 0.4544927 0.60629605 0.3427923 >V4 0.4707389 -0.18468403 0.4109350 -0.38827811 -0.6516665 >V5 0.3976754 0.87648935 0.1784558 -0.06887199 0.1924341 > >Finally, when I do it by "hand" in R (i.e., c<-cov(data); e<-eigen(c)), >I get a fourth answer: > > V5 V4 V3 V2 V1 >V1 0.4517989 0.05072137 -0.6904702 -0.42041399 -0.3739091 >V2 0.4616809 -0.29956355 -0.3405484 0.54786307 0.5300805 >V3 0.4505416 -0.32457242 0.4544927 -0.60629605 0.3427923 >V4 0.4707389 -0.18468403 0.4109350 0.38827811 -0.6516665 >V5 0.3976754 0.87648935 0.1784558 0.06887199 0.1924341 > > >Can anyone point me in the right direction here? I can email the raw >data to anyone if that would help. > >Thank you in advance... > >Damien > >-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- >r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html >Send "info", "help", or "[un]subscribe" >(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch >_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._ >-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._