Skip to content

Help with PCA

3 messages · elisacarli21, Sarah Goslee, William Revelle

#
Dear all,

I've  a correlation matrix with rows and columns headings.
I've two questions:

1) How can i import it in R, setting first row as row heading and first
column as column heading?
2) Which is the best principal component anlysis package in R?

Thanks in advance

--
View this message in context: http://r.789695.n4.nabble.com/Help-with-PCA-tp4239756p4239756.html
Sent from the R help mailing list archive at Nabble.com.
#
Hi,
On Wed, Dec 28, 2011 at 7:54 AM, elisacarli21 <elisacarli21 at gmail.com> wrote:
read.table, with the appropriate options. You can see what they are
by typing
?read.table
at an R prompt.
Best for what?

I'd start with
?princomp
and if that doesn't meet your needs go looking farther.
www.rseek.org is good for finding R functions for particular purposes.

But if you're starting with the correlation matrix rather than the raw
data, you might need to do the eigenanalysis yourself rather than
relying on an existing function that assumes raw data.

Sarah
2 days later
#
Sarah and elisacarli21

principal in the psych package will do principal components of a correlation or covariance matrix.

ex:

library(psych)
principal(Thurstone,3,rotate="none")   #First three principal components of the Thurstone correlation matrix
#compare with eigen
e <- eigen(Thurstone)   #perform an eigen value decomposition
e   #show the resuls
e$vectors %*% diag(sqrt(e$values))  #convert to "loadings" and compare with the output from principal



Bill
On Dec 28, 2011, at 9:09 AM, Sarah Goslee wrote:

            
William Revelle		           http://personality-project.org/revelle.html
Professor			           http://personality-project.org
Department of Psychology   http://www.wcas.northwestern.edu/psych/
Northwestern University	   http://www.northwestern.edu/
Use R for psychology             http://personality-project.org/r
It is 6 minutes to midnight	   http://www.thebulletin.org