Statistics and Regression, lesson 12
Principal components
The few hidden drivers behind many series that move together.
Many stocks, or bonds of many maturities, rise and fall together, as if a few hidden drivers moved them all. Principal components find those drivers in the data, without being told what they are. You need covariance and correlation, and the near copies from Regularisation.
By the end, you can:
Part 1. The direction of most spread
Find the two principal components of two series, and the share of variance each explains.
Plot two stocks' daily returns against each other. If they're correlated, the cloud is long and thin, tilted along the line where both move the same way. Of all the directions through its middle, one has the most spread: the long axis. The direction at right angles holds the rest.
Example 1.1
Two stocks, each 20% volatile
Two stocks each have volatility 20% a year, and their correlation is 0.6. Find the directions of most and least spread, and the share of the total variance each explains.
- Fill in the covariance matrixvariances 0.04; covariance 0.024
0.2² = 0.04 on the diagonal, and 0.6 × 0.2 × 0.2 = 0.024 off it.
- Spread along the sum(0.04 + 0.04 + 2 × 0.024) / 2 = 0.064
Weights of 1 / √2 keep their squares adding to 1. A sum's variance is both variances plus twice the covariance, and each squared weight is 1 / 2.
- Spread along the difference(0.04 + 0.04 − 2 × 0.024) / 2 = 0.016
At right angles to the sum. The two add to the total, 0.08.
- Shares0.064 / 0.08 = 80%; 0.016 / 0.08 = 20%
The sum is the first component.
AnswerThe sum, both stocks equally, explains 80%. The difference explains 20%.
Why must the weights' squares add to 1? Otherwise any direction could claim more spread by scaling its weights up. With that fixed, no direction beats the sum here, and the variance splits exactly between sum and difference: σ²(1 + ρ) and σ²(1 − ρ), with ρ the correlation. So the first explains (1 + ρ) / 2.
Principal components
The first principal component is the direction, a set of weights whose squares add to 1, along which the data spreads most. Each next one spreads most at right angles to those before, one per series. Its share of the total variance is the variance it explains. Finding them is principal component analysis, PCA.
two series, equal volatility: the first explains (1 + ρ) / 2 = 1.6 / 2 = 80%
PCA follows raw variance, so units matter. A series recorded in basis points has numbers 100 times bigger than in percent, and 10,000 times the variance, so the first component swings onto it for no real reason. Standardise series that come in different units first. That's the same as running PCA on the correlation matrix.
Your turn
Two series each have volatility 10%, and their correlation is 0.8. What share of the variance does the first principal component explain?
Part 2. Many stocks, one driver
Read the first component of many stocks as the market, and work out how much it explains.
Keep going with Pro
You've done the first part. Pro opens the rest of this lesson, and every other one.
- Many stocks, one driver
- When inputs move together
Statistics and Regression overviewSpotted a mistake? Tell us.