Session Ready
Exercise

Plotting cos2

You're getting the hang of PCA now! As Alex demonstrated in the video, an important index included in your PCA models is the squared cosine, abbreviated in FactoMineR and factoextra as cos2. This shows how accurate the representation of your variables or individuals on the PC plane is.

The factoextra package is excellent at handling PCA models built using FactoMineR. Here, you're going to explore the functionality of factoextra. You'll be using the pca_output_all object that you computed earlier and create plots based on its cos2. Visual aids are key to understanding cos2.

Instructions 1/4
undefined XP
  • 1

    Create a factor map using fviz_pca_var() for the variables with cos2 higher than 0.7.

    • 2

      Modify your code to create the individuals' factor map using fviz_pca_ind() and select.ind.

    • 3

      Create a barplot for the 10 variables with the highest cos2 on the 1st PC. Use "var" for variables, instead of "ind".

    • 4

      Modify your code to create a barplot for the variables with the highest cos2 in the 2nd PC.