For the purposes of this question, assume we have 10-dimensional data - that is, ignore the Overall column.
A)
Explain why we need to scale this data set before performing PCA.
If we do not scale the data, then events like Javelin and Discus will dominate the differences between the observations. This is because these two events have the highest score. Scaling will ensure that all of these events are on the same scale.
B)
Use svd() to find the first 2 principal component scores and their loadings. Full credit will only be granted if you use the svd() ingredients u, d, and v. What percent of the overall variability do the first two PCs explain?
Our first principal component explains 29.13% of the variability. The second principal component 19.28% of the variability. In total our first two principal components explain 48.41% of the variability. Additionally, we have our loadings stored in V_dec.
C)
Find and print the loadings. Based on the loadings alone, if the first two PCs are plotted in a 2D plane as shown below, which of the four quadrants will the medalists be in? Explain your reasoning.
We would expect the medalists to be in quadrant 2. We can see for starters that PC2 had very few negative loadings. The only 3 negative loadings are small in absolute value compared to the other loadings. That means that the negative loadings will not contribute much to PC2. This tells us that someone who did well in a lot of events (like a medalist) would have a high PC2. The average loading value for PC1 is much close to 0, then the average loading value for PC2. Of the 10 loadings for PC2, 4 of them are negative and 6 are positive, however, 2 of the positive ones are very close to 0. So, we would expect the medalists to be around the x = 0 line, since high scores in each event would balacne each other out. Notably, each medalist perforemd very well in long jump, which is one of the largest negative components, so that is why I say they will be in quadrant 2.
D)
Add the PCs to the decathlon data set and create a scatterplot of these PCs, with the points labeled by the athletes’ names. Color-code the points on whether or not the athlete was a medalist. Use the ggrepel package for better labeling. Verify that your intuition from C) is correct.
library(ggrepel)
Warning: package 'ggrepel' was built under R version 4.4.3
This matches our intuition from above. The medalists are in quadrant 2, but are close to the x = 0 line.
E)
Canadian Damian Warner won the gold medal in the decathlon in the 2020 Tokyo games. He began the 2024 decathlon but bowed out after three straight missed pole vault attempts.
Would this have won a medal if it had happened in 2024? To answer this, we will compute his PCs with respect to the 2024 athletes and add it to the plot to see where his 2020 gold-medal performance compares to the 2024 athletes. To do this:
Find the mean vector from the 2024 athletes. Call it mean_vec_24.
Find the standard deviation vector from the 2024 athletes. Call it sd_vec_24.
Standardize Warner’s 2020 results with respect to the 2024 athletes: (warner-mean_vec_24)/sd_vec_24
Find Warner’s PC coordinates using the 2024 loadings.
ggplot(data = PCs_df_dec, aes(x = X1, y = X2, color = medalists)) +geom_point() +geom_text_repel(aes(label = Athlete)) +geom_point(x = warner_pcs[1], y = warner_pcs[2], color ='black', show.legend =FALSE, size =5, shape ="*") +geom_text(x = warner_pcs[1], y = warner_pcs[2]+0.25, label ='Warner', show.legend =FALSE, color ='grey50') +xlim(-4,4.5) +xlab('PC1') +ylab('PC2') +theme_classic()
Do you think his 2020 performance would have won a medal if it had happened in 2024?
I do not think that his 2020 performance would have won a medal if it happened in 2024. His PC2 is much lower than that of the 3 medalists. Since PC2 is high when you ahve high scores across all events, I do not believe this performance would compare.
Question 2
Below is a screenshot of a conversation between me and chatbot Claude:
After looking at the graphs, I grew skeptical. So I said:
Behold, Claude’s three data sets which I’ve called claudeA, claudeB, and claudeC:
Each data set has an X and a Y column which represent 2-dimensional variables that we need to rotate.
A)
Scale each data set and plot them side-by-side using the patchwork package. Make sure the aspect ratio of each graph is 1 (i.e., make the height and width of each graph equal). At this point, explain why you think I was skeptical. Specifically, do you think the percent variability explained by the first PC of each data set appears to exceed or fall short of the variability I asked it to?
library(patchwork)
Warning: package 'patchwork' was built under R version 4.4.3
I would expect the variance explained by the first PC to be higher than what you told Claude for each of these plots. When looking at each plot, I imagine rotating the points so that there is no correlation between the points anymore. If we do this, almost all of the variability for each plot is in the horizontal direction. The plots do not vary much vertically in this scenario. I would expect the first PCs for each plot to be higher than what you specified because of this.
B)
Use SVD to find the first PC for each data set, and find the actual percent of total variability explained by each PC using aggregation methods.