Exercise

Choosing the number of PCs

One of the main challenges with PCA is selecting the number of PCs, which can be done by determining the amount of the cumulative proportion of variance that is explained. We will use this method to select the number of PCs needed to explain 95% of the variation in the state.x77 data. The proportion of variation explained by each PC is preloaded for you as the object pca.pvar.

Instructions 1/2

undefined XP
    1
    2
  • Print the pca.pvar object.
  • Based on the pca.pvar object, which gives the proportion of variance explained by each principal component, plot the cumulative variance explained plot using the cumsum() function.