Principal Components Analysis
Principal Components Analysis: Centring, Eigenvalues and Choosing a Reduced Representation
What PCA is asking
Given n observations on p variables, arranged as an n×p matrix X, PCA looks for the direction in Rp along which the data vary most, then the direction of greatest remaining variation orthogonal to the first, and so on.
The result is a new orthogonal coordinate system, ordered by how much of the data's spread each axis accounts for. Keeping the first few axes gives a faithful low-dimensional summary.
Centre first, and understand why
Every column of X has its mean subtracted, giving the centred matrix Xc. This is not a cosmetic step.
PCA maximises variance, and variance is defined about the mean; a direction-finding procedure applied to uncentred data can be pulled toward the direction of the mean vector when its contribution is large relative to centred variation, because the raw second-moment matrix XTX measures displacement from the origin rather than spread about the centre of the cloud.
When the mean contribution dominates centred variation, the first “component” can point toward the data cloud and describe where the data sit rather than how they vary. Centring removes that and nothing else: it shifts the cloud without rotating or rescaling it, so the shape PCA is looking for is untouched.
The covariance matrix and its eigen-decomposition
The sample covariance matrix is
a p×p symmetric positive semidefinite matrix. Symmetry is what makes the whole method work: by the spectral theorem, S has p real eigenvalues λ1≥λ2≥⋯≥λp≥0 and a corresponding orthonormal basis of eigenvectors v1,…,vp.
- The eigenvector vi is the i-th principal direction, a unit vector in the space of the original variables. Its entries are the loadings.
- The eigenvalue λi is the variance of the data along that direction. When all original variables share a physical unit, it has that unit squared. With mixed units, it is instead a coordinate-scale-dependent numerical variance with no single coherent physical unit; it is not a correlation and not a count.
- The scores are the projections Xcvi, giving each observation's coordinate on component i.
Because the trace of a matrix is the sum of its eigenvalues,
so the components divide up exactly the total variance of the original variables. The proportion of variance explained by component i is λi/∑kλk.
A worked two-variable example
Suppose two centred variables have sample covariance matrix
Read off tr(S)=7 and det(S)=12−4=8. The eigenvalues satisfy λ2−7λ+8=0, so
They sum to 7, as the trace requires, and PC1 accounts for 5.562/7=79.5% of the total variance. Solving (S−λ1I)v=0 gives −1.562v1+2v2=0, so v2=0.781v1, and normalising yields
Both loadings are positive and comparable, so PC1 is roughly a weighted average of the two variables, the direction in which they rise together. Always check that the eigenvalues sum to the trace; it catches arithmetic errors immediately.
Getting there from the SVD
In practice the covariance matrix is often never formed. Take the SVD of the centred data, Xc=UΣVT. Then
and the right singular vectors vi are exactly the principal directions. Two cautions follow. The singular values must be squared to become variances, and the factor 1/(n−1) must not be dropped when an eigenvalue itself is wanted. It does cancel in any explained-variance ratio, which is why ratios can be computed from σi2 alone.
Choosing how many components to keep
The usual device is cumulative explained variance: retain the smallest k for which ∑i≤kλi/∑iλi reaches a chosen threshold, often 80% or 90%. A scree plot of λi against i supports the same judgement visually, with a marked drop suggesting where the structure ends and the noise begins.
These are conventions, not tests. The threshold is a choice, and the components retained are not guaranteed to be the ones relevant to any particular downstream question, a low-variance direction can carry the signal that matters.
Covariance or correlation? The scaling decision
In covariance PCA, each eigenvalue is a numerical variance quantity in the chosen coordinate system. It has an ordinary squared physical unit only when all combined variables share that unit; with mixed units, it depends on their coordinate scales and has no single coherent physical unit.
A variable whose numerical variance is made much larger by its measurement units can dominate covariance PCA even when that weighting is not substantively intended. Recording income in dollars rather than thousands can materially change eigenvalues, explained proportions, and sometimes principal directions, despite representing the same observations.
Standardising each variable to unit variance first, equivalently, running PCA on the correlation matrix, removes that arbitrariness. Then tr=p, and each eigenvalue can be compared directly against 1, the variance a single standardised variable contributes.
The practical rule: use the correlation matrix when variables should receive equal initial weight despite different units or scales; use the covariance matrix when weighting by their numerical variance is intended, often when all variables share a unit and their relative magnitudes are meaningful.
Neither is more correct in the abstract; the choice states what should count as important and should be reported deliberately.
The scope here is centring and scaling, interpreting principal directions and explained variance, and selecting a reduced representation. Applying the same low-rank machinery to compress an image matrix, and general data-fitting procedures, belong to the sibling concepts.
A principal components analysis is carried out by forming the sample covariance matrix S of the centred data and computing its eigenvalues λ1≥λ2≥⋯≥λp and eigenvectors.
What do the eigenvalues represent?
A principal components analysis of five variables gives covariance-matrix eigenvalues
What is the smallest number of components that together explain at least 90% of the total variance?
Give your answer in components.