Principal component analysis, or PCA, is a method for reducing many related variables into a smaller number of new variables called principal components. It helps students summarize high-dimensional data, identify major patterns, and visualize data more easily. This cheat sheet connects the setup, matrix calculations, and interpretation steps needed to use PCA correctly.
It is useful when data has many measurements that may overlap or be strongly correlated.
The core idea is to center or standardize the data, compute a covariance or correlation matrix, and find its eigenvalues and eigenvectors. Eigenvectors give the directions of the principal components, while eigenvalues measure how much variance each component explains. Scores are found by projecting the data onto the selected component directions.
The proportion of explained variance helps decide how many components to keep.
Key Facts
- For a data matrix with observations and variables, the centered data matrix is , where each column mean is subtracted.
- The sample covariance matrix for centered data is .
- PCA solves the eigenvalue equation , where is a principal direction and is its variance.
- The first principal component is the direction with maximum variance, written as .
- The proportion of variance explained by component is .
- The cumulative explained variance for the first components is .
- If variables have very different units or scales, PCA is usually performed on standardized variables using .
- A rank- PCA reconstruction can be written as , where contains the first component scores.
Vocabulary
- Principal Component
- A principal component is a new variable formed as a linear combination of the original variables, chosen to capture as much variance as possible.
- Covariance Matrix
- A covariance matrix is a square matrix whose entries measure how pairs of variables vary together.
- Eigenvector
- An eigenvector of a matrix is a nonzero vector whose direction does not change when the matrix acts on it.
- Eigenvalue
- An eigenvalue is a scalar that tells how much variance is captured in the direction of its corresponding eigenvector in PCA.
- Explained Variance
- Explained variance is the amount or proportion of total data variation captured by a principal component.
- Score
- A score is the coordinate of an observation after it has been projected onto a principal component direction.
Common Mistakes to Avoid
- Forgetting to center the data is wrong because PCA directions depend on variation around the mean, not the raw location of the data.
- Using covariance PCA when variables have very different units can be wrong because large-scale variables may dominate the components even if they are not more important.
- Treating principal components as original variables is wrong because each component is a weighted combination of all original variables.
- Choosing components only because their eigenvalues are largest can be incomplete because the decision should also consider cumulative explained variance and the purpose of the analysis.
- Ignoring the signs of eigenvectors incorrectly can cause confusion because the direction may flip without changing the PCA solution, but score interpretations must stay consistent.
Practice Questions
- 1 A centered data matrix has eigenvalues , , and . What proportion of variance is explained by the first principal component?
- 2 For eigenvalues , , , and , how many components are needed to explain at least of the total variance?
- 3 A data point has centered values and the first principal direction is . Find its first principal component score .
- 4 Explain why standardizing variables before PCA may be important when one variable is measured in dollars and another is measured in centimeters.