Method
Principal components and empirical orthogonal functions
Adapted
Builds the sample covariance matrix of a centred data matrix, shows that its eigenvectors are the directions of successively largest sample variance and that they are the right singular vectors of the data matrix itself, reads the eigenvalues as the variance each direction explains, and identifies the truncated expansion as the best approximation of its rank — which is what an EOF analysis of a space-time field computes.
Prerequisites: Singular value decomposition, Spectral theorem for Hermitian matrices, Quadratic forms and the Rayleigh quotient, Orthogonal projection and least squares, Expectation, variance and covariance, The multivariate normal distribution
Principal component analysis takes a table of numbers — observations of variables — and finds the few directions in the -dimensional variable space along which the data actually vary. In the atmospheric and ocean sciences the same computation, applied to a field sampled at grid points on occasions, is called empirical orthogonal function (EOF) analysis: the eigenvectors are maps, and the coefficients that multiply them are time series. The two names describe one piece of linear algebra.
None of the books in this handbook's library treats principal components under that name. What they supply is the machinery: the singular value decomposition and the variational property of the eigenvectors of a symmetric matrix from Riley, Hobson and Bence (Riley, Hobson & Bence (2006), §8.17.1 and §8.18.3, pp. 290-291 and 302-304), and the covariance matrix of a random vector from Grimmett and Stirzaker (Grimmett & Stirzaker (2020), §4.9, pp. 132-134). The assembly of those pieces into the statement below, and every number in the example, are ours.
Let be a real data matrix with : row is one observation , column is one variable. For a space-time field, indexes time and indexes a grid point, so is the value of the field at grid point at time .
The column mean is , and is centred when , that is when every column sums to zero. We assume from here on that has been centred by subtracting from every row; the matrix before centring is called the raw data and is never used below.
The sample covariance matrix of a centred is the matrix
It is symmetric and positive semidefinite, since for every . Its diagonal entries are the sample variances of the variables, and is the total variance of the data set.
Given a unit vector , the numbers () are the data projected onto the direction . Their mean is zero, because is centred, and their sample variance is
A principal direction (in the geosciences, an empirical orthogonal function, or EOF) is a unit vector produced by the following rule: maximises over all unit , and for , maximises over all unit orthogonal to . The corresponding principal component (in the geosciences, the PC time series, or expansion coefficient) is the column vector
whose th entry is the amount of pattern present in observation . The sample variance of is , written , and, provided — equivalently , since — the explained variance fraction of mode is . For the zero data matrix every vanishes and the fractions are not defined; that case is excluded wherever they are used.
The population counterpart of is the covariance matrix of a random vector, . Grimmett and Stirzaker (Grimmett & Stirzaker (2020), Thm (4.9.5) and Exercise (4.9.3), pp. 132, 134) state this naming of at their Theorem (4.9.5), and give the variance of a linear combination at their Exercise (4.9.3), which is the population form of the identity just computed for a sample. Both are stated there for a vector with the multivariate normal distribution , which is the only distribution that section treats; neither uses normality, since both are identities between second moments that hold for any random vector with finite variances. Everything below is in any case a statement about the matrix actually formed from the data, not about .
Let be a centred real data matrix with and sample covariance , and let .
1. The principal directions exist and are the eigenvectors of . Write the eigenvalues of , which are real and non-negative, in decreasing order , with an orthonormal basis of eigenvectors, . Then this is a valid choice of principal directions, the successive maxima are
and the sample variance of the th principal component is . Exactly of the are non-zero. The choice is unique up to sign whenever , read with the end conventions and (so at the condition is and at it is ), and within any block of equal eigenvalues no direction is singled out at all.
2. The principal components are uncorrelated, and the variances add up. For the sample covariance of and is , and
so, when and hence , the explained variance fractions are non-negative and sum to one.
3. They come straight out of the SVD of . Let be a singular value decomposition (Singular value decomposition). An matrix has singular values ; extend the list by for , which is consistent because then has further zero eigenvalues. With that convention one may take, for ,
The second case is empty when ; when — the case the remark below stresses — supplies only , and the remaining principal components vanish. In particular the principal directions never require to be formed.
4. Truncation is optimal. For let
be the field reconstructed from the first modes. Then minimises over all matrices of rank at most , the minimum value being , and the fraction of the total variance it retains is
Equivalently, among all -dimensional subspaces of , the span of is one onto which the orthogonal projection of the data loses the least squared length.
Two short observations do all the work.
The first is that depends on only through its components in an eigenbasis: writing with gives , a weighted average of the eigenvalues. An average of numbers cannot exceed the largest of them, and it reaches that value only by putting all the weight on entries equal to the largest — on one eigenvector when the largest eigenvalue is simple, and anywhere in its eigenspace when it is not. So maximising a quadratic form over the unit sphere is not a calculus problem at all once the spectral theorem has been applied; it is the remark that a convex combination is largest at an extreme point. Imposing orthogonality to deletes the first weights and repeats the argument on what is left.
The second is that and carry the same information: , so the right singular vectors of are eigenvectors of and the squared singular values are times its eigenvalues. Truncating the principal component expansion is then literally truncating the dyadic sum , and its optimality is the Eckart-Young theorem already proved in Singular value decomposition.
Part 1. is real symmetric, so by the spectral theorem (Spectral theorem for Hermitian matrices) it has an orthonormal eigenbasis with real eigenvalues, which we order decreasingly; they are non-negative because .
Fix and let be a unit vector orthogonal to . Expand with ; orthogonality to the first eigenvectors says , and says . Then, using and ,
the inequality because for every , by the decreasing ordering, and because every . The value is attained at , which is a unit vector orthogonal to . So the maximum is and achieves it, which is what the defining rule for asks. The variance of is .
The number of non-zero eigenvalues is , and : indeed implies , and conversely implies , so the two matrices have the same null space.
For uniqueness, suppose (read at the left end and at the right, so that for the hypothesis is only ) and let be any maximiser. In the display above, equality in forces for every with , which under the assumed strict gap is every ; hence with . If instead , every unit vector in the corresponding eigenspace is a maximiser.
That argument used only the right-hand gap , and it determines up to sign given . The left-hand gap is what makes the conclusion a statement about the rule and not about one run of it: the constraint set depends on the earlier choices, and those are themselves arbitrary inside any block of equal eigenvalues. If , then may be taken to be any unit vector of the shared eigenspace, and is then forced to be a vector of that same eigenspace orthogonal to it — so moves with and is not determined up to sign. With both gaps, is a simple eigenvalue, and the left gap also pins down the constraint set: any admissible span the sum of the eigenspaces of , and since that sum contains every block of equal eigenvalues it meets, so it is the same subspace — the sum of all eigenspaces for eigenvalues exceeding — however the ties among the earlier modes were resolved. Hence is the same line whatever admissible preceded it, which is what "unique up to sign" asserts.
Part 2. The have mean zero because the columns of do, so their sample covariance is , which vanishes for by orthonormality. The trace identity is the fact that a square matrix has trace equal to the sum of its eigenvalues, applied to ; concretely, with orthogonal.
Part 3. Let be a singular value decomposition. Then
using . This is the computation Riley, Hobson and Bence (Riley, Hobson & Bence (2006), Eq. (8.132), p. 302) make at their Eq. (8.132); since is the diagonal matrix with entries followed by zeros — that is, with entries under the convention for — and is orthogonal, it exhibits an orthogonal diagonalisation of . Hence the columns of are orthonormal eigenvectors of with eigenvalues , and because the SVD convention orders , these eigenvalues come out already in decreasing order. By part 1 they are an admissible set of principal directions and variances. Finally for , which is their Eq. (8.134), so there; for the th column of is zero, so , in agreement with .
Part 4. Substituting and into the definition of gives , which is the rank- truncation of the dyadic form of (Riley, Hobson and Bence's (Riley, Hobson & Bence (2006), Eq. (8.136), p. 303) Eq. (8.136)). Its optimality in the Frobenius norm, with the stated minimum, is the Eckart-Young statement of Singular value decomposition. Dividing by turns it into , which gives the variance fraction. For the last sentence, let be the orthogonal projection of onto an -dimensional subspace; then has rank at most , so , and with the projection onto , because and the latter sum is exactly (Orthogonal projection and least squares).
- Centring is what makes a covariance matrix, and it is the hypothesis most often dropped by accident. Parts 3 and 4 — the identification with the SVD and the Eckart-Young optimality — are facts about an arbitrary matrix and hold whether or not it is centred; what centring buys is the reading of as a sample variance, and with it the zero mean of the principal components used in part 2. If the columns of are not centred, then is a matrix of second moments, not of covariances; its leading eigenvector is dominated by the mean and typically just reproduces it. Concretely, take a single variable with the two values and , so that and . Centred, the formula gives the sample variance ; applied to the raw column it gives instead, of which the mean alone contributes . So more than of the quantity being maximised has nothing to do with variability, and the "first mode" of an uncentred analysis is just the mean.
- The decreasing ordering is used once, in the inequality for . Without it the argument still shows that stationary directions are eigenvectors — this is the Lagrange-multiplier computation of Riley, Hobson and Bence (Riley, Hobson & Bence (2006), §8.17.1, Eqs. (8.113)-(8.116), pp. 290-291), who note that stationarity is necessary but not sufficient for a maximum — but it no longer identifies which eigenvector is the maximiser. The convex-combination argument above settles that and is why we do not need the multiplier.
- Symmetry of is what gives an orthonormal eigenbasis, and with it both the uncorrelatedness in part 2 and the completeness used in the expansion . It is automatic here, because is built as ; there is no hypothesis to check and no non-symmetric variant of the method.
- Degenerate eigenvalues destroy the modes, not the subspace. When , the individual patterns and are arbitrary inside a two-dimensional eigenspace and will change completely under a tiny perturbation of the data; only their span, and the sum of the two explained variances, is stable. Near-degeneracy is the usual situation for a propagating signal, whose two phases have nearly equal variance, and it is the standard reason an individual EOF should not be read as a physical mode.
- Rank is limited by the smaller dimension. Since , a field on grid points observed on occasions has at most non-zero eigenvalues, and at most after centring, because centring puts the rows in the hyperplane . Part 3 is then the only practical route: the matrix need never be built.
- Scaling is a modelling choice, not mathematics. is not invariant under rescaling the individual variables, so for variables in different units — hectopascals and metres per second — PCA of is meaningless and one works with the correlation matrix instead, that is, with each column divided by its sample standard deviation. For a field in one unit this choice is usually inappropriate, but a weight proportional to the square root of the area each grid point represents is needed, or dense high-latitude grid points are over-counted.
- versus changes every by the same factor and therefore changes no eigenvector and no explained variance fraction. We use for consistency with the unbiased sample variance of Sampling distributions.
- Row vectors. Grimmett and Stirzaker (Grimmett & Stirzaker (2020), §4.9, pp. 132-133) write random vectors as rows, so their covariance matrix is and their linear map acts on the right, with covariance . We use column vectors, in which the same statements read and . The transposes are not a disagreement, only a transcription.
- Lay out the data matrix. Rows are observations (times), columns are variables (grid points). Decide first what the "observations" are: EOFs of a field in time and EOFs of the same field transposed are different analyses, related by part 3.
- Handle missing values and weights before anything else. Fill or drop; then, for a field on a sphere, multiply column by with the area weight of grid point , so that is the area-weighted variance. For variables in different units, divide each column by its sample standard deviation instead.
- Centre. Subtract each column's mean. If a trend or a seasonal cycle is to be excluded rather than analysed, remove it here too; otherwise it will be mode 1.
- Factor, do not square. Compute the singular value decomposition (Singular value decomposition). Forming and diagonalising it gives the same answer in exact arithmetic but squares the condition number (Matrix norms and condition numbers), and is impossible anyway when is large.
- Read off the modes. EOF is the column , plotted as a map; the PC time series is ; the variance of mode is and its explained fraction is .
- Fix the sign. Each pair may be replaced by ; software makes an arbitrary choice. Fix it by a stated rule, for example by requiring the value of at a chosen grid point, or the projection of on a chosen index, to be positive, and say which rule you used.
- Decide how many modes to keep. Plot against and truncate where the spectrum flattens; check whether the gap you are truncating at is larger than the sampling uncertainty in the eigenvalues, which for independent observations is of order . Keep whole near-degenerate pairs or none of them.
- Reconstruct and check. Form and verify that equals . This is an arithmetic check on the whole computation and costs nothing.
A one-dimensional "field" is measured at grid points on occasions. The data, already centred (each column sums to zero), are
Step 1: the sample covariance matrix. With ,
For instance the entry is .
Step 2: guess and verify two eigenvectors. Rows and of are negatives of each other, and so are rows and ; the matrix therefore has rank at most , and the two sign patterns and suggest themselves. Multiplying out,
So and , with . Since and the remaining eigenvalues are non-negative, they must both be zero: the data lie exactly in a two-dimensional subspace, and .
Step 3: normalise, and compute the principal components. , so the EOFs are
EOF 1 is a dipole: the left half of the domain up, the right half down. EOF 2 opposes the two outer grid points to the two inner ones — its signs across grid points are , so it changes sign between points and and between points and , but not between and . It is not the grid-scale pattern that alternates at every step: that vector, , satisfies here, so it carries no sample variance at all and spans one of the two null directions whose zero eigenvalues step 2 accounted for (the other is the uniform pattern , also annihilated by ). The PC time series are :
(First entry of : .) Their sample variances are and , as part 1 promises, and , as part 2 promises.
Step 4: explained variance.
The dipole alone accounts for five sixths of the variance of the field; the two modes together account for all of it.
Step 5: cross-check against the SVD. The singular values must be , that is and , with ; and indeed . Truncating after one mode leaves , and no rank-one matrix does better.
Climate fields. Applied to monthly anomalies of sea-level pressure over the northern hemisphere, the leading EOF is the annular seesaw between the polar cap and the midlatitude belt whose PC time series is published as the Arctic Oscillation, or northern annular mode, index; the same analysis restricted to the Atlantic sector gives the North Atlantic Oscillation, the seesaw between the Icelandic low and the Azores high; applied to tropical Pacific sea-surface temperature, the leading EOF is the tongue of warm anomaly whose PC is an El Nino index. The attraction is exactly part 4: a handful of numbers per month reproduces a field of tens of thousands of grid points to within a few per cent of its variance, so a century of maps compresses to a few time series that can be correlated with everything else. The attendant danger is the degeneracy caveat above — the leading EOF is a statistically optimal pattern, and only sometimes also a dynamical mode.
Model reduction and data assimilation. Truncating at modes replaces a state vector of length by one of length in the subspace that carries the most variance, which is how a reduced-rank background covariance is built for Optimal interpolation and variational data assimilation, and how the "essential dynamics" of a protein is extracted from a molecular-dynamics trajectory: the atomic coordinate matrix has columns, and a handful of collective modes carries most of the fluctuation.
Measurement and instrumentation. The same decomposition applied to a set of spectra separates the number of independent chemical species present (the number of eigenvalues above the noise floor) from the noise, and applied to an array of detectors it identifies common-mode drift as a leading mode to be regressed out. In both cases what is being used is that the noise, being uncorrelated between channels, contributes a nearly flat tail to the eigenvalue spectrum, while any shared signal contributes a few large eigenvalues.