how to get coefficient and scores of Principal component analysis in R?
By coefficients do you mean loadings?
Anyway, if you read the help for princomp -- ?princomp -- will
get that, you'll see that it says, in part:
?princomp? returns a list with class ?"princomp"? containing the
following components:
sdev: the standard deviations of the principal components.
loadings: the matrix of variable loadings (i.e., a matrix whose columns
contain the eigenvectors). This is of class ?"loadings"?:
see ?loadings? for its ?print? method.
scores: if ?scores = TRUE?, the scores of the supplied data on the
principal components. These are non-null only if ?x? was
supplied, and if ?covmat? was also supplied if it was a
covariance list. For the formula method, ?napredict()? is
applied to handle the treatment of values omitted by the
?na.action?.
So for instance,
myprincomp <- princomp(mydata)
myprincomp$scores # shows the scores
Sarah
On Fri, Jan 28, 2011 at 2:16 PM, Zunqiu Chen <chener at ohsu.edu> wrote:
Dear All, It might be a simple question. But I could not find the answer from function ?prcomp? or ?princomp?. Does anyone know what are the codes to get coefficient and scores of Principal component analysis in R? Your reply will be appreciated! Best Zunqiu
Sarah Goslee http://www.functionaldiversity.org