This question already has an answer here:

I've read through this explanation here regarding calculating the variance explained from PCA output. I think I got it right but might be off in my interpretation of R output.

In the example below, I would like to calculate the percentage of variance explained by the first principal component of the USArrests dataset.

pca <- prcomp(USArrests, scale = TRUE)
eigs <- pca$sdev^2
eigs[1] / sum(eigs)
[1] 0.6200604

I assumed that R uses sdev as the square root of the eigen values. So I square it and divide the first value by the total. Is this correct?


marked as duplicate by Haitao Du, ttnphns, gung r Jan 4 '17 at 20:31

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


Yes, that's correct. summary.prcomp brings that information as well:

#Importance of components:
#                          PC1    PC2     PC3     PC4
#Standard deviation     1.5749 0.9949 0.59713 0.41645
#Proportion of Variance 0.6201 0.2474 0.08914 0.04336
#Cumulative Proportion  0.6201 0.8675 0.95664 1.00000

Compare to

  SD = sqrt(eigs),
  Proportion = eigs/sum(eigs),
  Cumulative = cumsum(eigs)/sum(eigs))

#                [,1]      [,2]      [,3]       [,4]
#SD         1.5748783 0.9948694 0.5971291 0.41644938
#Proportion 0.6200604 0.2474413 0.0891408 0.04335752
#Cumulative 0.6200604 0.8675017 0.9566425 1.00000000

Not the answer you're looking for? Browse other questions tagged or ask your own question.