Hi, I am a new user of R, and apologize beforehand for the simplistic nature of this question: I ran prcomp on a data set with 4 variables, and am able to see the summary information (variance contribution, rotation matrix, plots, etc.). However, I'd also like to extract the actual values of the principal components (PC) corresponding to each sample. I've looked in the help, on-line manuals, FAQs, archived e-mails from this list, but have been unsuccessful in finding the solution. Alternatively, I saved the prcomp output to an ascii file, and then used the rotation matrix out of R and calculated the principal components in Excel... but these values do not match the prcomp output (at least the series of values that I assume are the PC values). If someone could shed some light, I'd greatly appreciate it. Thanks in advance. Oy _____________________________________________ Oy Leuangthong Department of Civil & Environmental Engineering University of Alberta (780) 492-3337 oy at ualberta.ca -------------- next part -------------- An HTML attachment was scrubbed... URL: https://stat.ethz.ch/pipermail/r-help/attachments/20001201/5724ffdd/attachment.html
Prof Brian D Ripley
2000-Dec-02 06:33 UTC
[R] simple (NEWBIE) question re: prcomp or princomp
On Fri, 1 Dec 2000, Oy Leuangthong wrote:> Hi, > > I am a new user of R, and apologize beforehand for the simplisticnature of this question:> > I ran prcomp on a data set with 4 variables, and am able to seethe summary information (variance contribution, rotation matrix, plots, etc.). However, I'd also like to extract the actual values of the principal components (PC) corresponding to each sample. I've looked in the help, on-line manuals, FAQs, archived e-mails from this list, but have been unsuccessful in finding the solution.>They are component `x' of the result, if retx is true (the default). It is in the help. One problem might be what you mean by the PCs: variously people mean the coefficients, the rotated basis or the projection onto the rotated basis, and (see below) what you do about centring and scaling. For princomp, just use the predict method. In general, I suggest using princomp not prcomp.> Alternatively, I saved the prcomp output to an ascii file, andthen used the rotation matrix out of R and calculated the principal components in Excel... but these values do not match the prcomp output (at least the series of values that I assume are the PC values). You need to centre the data (remove the means) first. The rotation is about the overall mean.> If someone could shed some light, I'd greatly appreciate it. > > Thanks in advance. > Oy > _____________________________________________ > Oy Leuangthong > Department of Civil & Environmental Engineering > University of Alberta > (780) 492-3337 > oy at ualberta.ca >-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Reasonably Related Threads
- Suggest patch for princomp.formula and prcomp.formula
- Accessing the (first or more) principal component with princomp or prcomp
- What is the difference between prcomp and princomp?
- which to trust...princomp() or prcomp() or neither?
- prcomp vs. princomp vs fast.prcomp