Principal component analysis asks for the single direction in which a cloud of data varies the most, then the next direction at right angles to it, and so on. For returns of N assets that cloud lives in N dimensions and is hard to look at, but its principal directions rank the independent sources of risk. The recipe is short: centre every column, form the covariance matrix, take its eigenvectors, sort them by eigenvalue and project the data onto the leading ones.
Here Xc is the T×N matrix of centred returns, the columns of Q are the principal directions (loadings) and the columns of Z are the scores, the data in the new coordinates. The scores are uncorrelated and the variance of the j-th is λj, so the eigenvalues split the total variance trΣ exactly. The signs of the directions are arbitrary: q and −q are the same line. Two cautions apply. Centring matters, because without it the first direction partly points at the mean. Units matter too: PCA of a covariance matrix is dominated by the most volatile variables, so when variables are on different scales you standardise them first, which means working with the correlation matrix.
Two assets by handTwo assets have covariance matrix Σ=(4223). The trace is 7 and the determinant is 8, so λ2−7λ+8=0 and λ=(7±17)/2, that is 5.562 and 1.438. The first component therefore explains 5.562/7=79.5% of the total variance. Its direction solves (4−5.562)q1+2q2=0, giving q1≈(0.788,0.615) up to sign. A centred observation (1,1) has a first score of 0.788+0.615=1.403 in absolute value. Both loadings have the same sign, so this component is a weighted average of the two assets.
Recipe: centre, covariance, eigendecompose, sort by eigenvalue, project onto the top directions.
Scores: uncorrelated, with variance λj; the explained share is λj/∑λi.
Cautions: signs are arbitrary; centre the data; standardise when units differ (correlation matrix).
What real stock returns sayFor the daily returns of twelve large US stocks since 2010 (4,184 days), the first principal component of the correlation matrix explains about 40% of the variance and every stock loads on it with the same sign: it is the market. The second explains about 12% and splits the stocks into groups, technology against defensive names. The remaining ten share the other 48% and are much harder to tell apart from noise, which is the subject of the next lessons.
Lab · what's graded
The PCA recipe15 pts
The first eigenvalue15 pts
The explained share15 pts
A score15 pts
When to standardise15 pts
Facts about scores10 pts
Why centre the data15 pts
0/ 7 answered
1Order the steps15 ptsNot answered
Put the steps of PCA on a returns matrix in order.
Drag to reorder, or focus an item, press Space to lift it, the arrow keys to move it and Space to drop it.
1Project the centred data onto the top eigenvectors to get scores
2Form the covariance matrix
3Sort the eigenpairs by decreasing eigenvalue
4Subtract each column's mean
5Compute the eigenvectors and eigenvalues of that matrix
2Numeric answer15 ptsNot answered
Find the larger eigenvalue of Σ=(4223) (trace 7, determinant 8). Give it to three decimals.
lambda1=accepted: ± 0.005
3Numeric answer15 ptsNot answered
What percentage of the total variance does the first component explain? Give it to one decimal.
share=accepted: ± 0.1
4Numeric answer15 ptsNot answered
The first direction is q1=(0.788,0.615). What is the absolute value of the first score of the centred observation (1,1)? Give it to three decimals.
score=accepted: ± 0.003
5Choice15 ptsNot answered
A PCA of the covariance matrix of a stock with 30% volatility and ten bond funds with 3% volatility is run. What happens, and what is the fix?
6Choice10 ptsNot answered
Select every true statement about PCA scores and loadings.
7Explain in words15 ptsNot answered
In one or two sentences, say why the data must be centred before computing principal components.
Math modeKeyboard or LaTeX inputTask 1 of 7 · Ctrl ⏎ to check