Topic 23 Principal Components Analysis (Project Work)
Learning Goals
- Implement PCA for your project dataset or for an example dataset and interpret findings
Slides from today are available here.
Project dataset
If you would like to explore PCA on your project, you can use the code from Topic 22. You will need to make sure that the variables used are quantitative or indicator variables.
Example dataset
Explore the results of PCA for the candy_rankings
data in the fivethirtyeight
R package. Entering ?candy_rankings
in the Console will display the codebook.
library(fivethirtyeight)
library(tidyverse)
candy_rankings %>%
candy <- select(-competitorname, -winpercent)
# Implement PCA like in Topic 22
# Set center = TRUE, but decide whether scale should be TRUE or FALSE by examining the scale of the variables