Search This Blog

Tuesday, November 12, 2013

R commands for PCA

Here are some R commands for PCA
pcdat = princomp(data) - It does actual job and put the results to pcdat. It will use covariance matrix
pcdat = princomp(data,cor=TRUE) - It will use correlation matrix
summary(pcdat) - It will print standard deviation and proportion of variances for each component
screeplot(pcdat) - It will plot screeplt
biplot(pcdat) or biplot.princomp(pcdat,scale=1) - It will give you biplot
loadings(pcdat) - it will give information how much each variable contribute to each component. For principal components you can ignore loading subsection of the output from this command
pcdat$scores - It will plot scores of each observation for each variable
For further details about this and other R commands type
help.start()

No comments:

Post a Comment

Thank you