← Module 10 overview
Module 10 · Project 6 · Due the date on Canvas · PCA & Dimension Reduction · adaptive competency DV18

Find PC1 by rotating the axis

Module 10 · Step 3 of 9 · Guided8–10 min

Why this lab Find PC1 yourself by rotating an axis through the data.

The lab rotates a candidate component until the variance of the projected scores is as large as possible. That maximum-variance direction is the first principal component (Hotelling, 1933).

In matrix terms. The direction being sought is the eigenvector associated with the largest eigenvalue of the covariance matrix of the centered data — of the correlation matrix once the variables are standardized. The variance of the scores along it is the largest eigenvalue, \( \lambda_1 \), which is the target printed beside the meter.

The same answer from the data matrix. Write the centered (and, when requested, scaled) data matrix with \( n \) rows as its singular value decomposition \( \mathbf{Z} = \mathbf{U}\mathbf{D}\mathbf{V}^{\mathsf T} \). The columns of \( \mathbf{V} \) are the loadings, the columns of \( \mathbf{U}\mathbf{D} \) are the scores, and each eigenvalue is a squared singular value divided by \( n-1 \): \( \lambda_k = d_k^2/(n-1) \). Keeping only the first \( k \) singular triples gives the truncated decomposition \( \hat{\mathbf{Z}}_k = \mathbf{U}_k\mathbf{D}_k\mathbf{V}_k^{\mathsf T} \), which is the closest rank-\( k \) matrix to \( \mathbf{Z} \) in squared error (Eckart & Young, 1936). The geometric view (the direction of maximum projected variance) and the algebraic view (the best low-rank approximation of the data) therefore describe one computation; R’s prcomp obtains its results from this decomposition.

Projection challenge loading…