Principal Component Analysis

The hidden factors in a basket's daily returns: how much of the variance each principal component explains against the noise edge, each asset's correlation with the components, and the components' cumulative returns.

PCAFACTOREIGENDaily closes for BTC, ETH, SOL, BNB and XRP; SPY, QQQ, IWM and the sector ETFs; Treasuries (TLT); gold, silver, copper, Brent and natural gas; the dollar index and major FX pairs, up to three years.

PCA command showing the scree for an 8 asset basket over a year, with each asset's PC1 loading

Typing it

PCA
>PCA
Runs PCA on BTC, ETH, SPY, QQQ, TLT, GOLD, DXY and BRENT over the last year.

What you see

  • Scree. Where it opens: the share of the basket's variance each component explains as bars, the running total as a line, and the noise edge dashed.
  • Loadings. Each asset's correlation with PC1, PC2 and PC3, from -1 to +1.
  • Scores. PC1 to PC3 added up through time, in daily standard deviations: each component's cumulative return.
  • Biplot. Each day as a dot on PC1 against PC2, with an arrow per asset for its loadings.
  • STATS. Variance explained by each component, alone and in total, and each asset's PC1 loading as a bar.

The maths

  • Method. The basket's daily returns are standardised and their correlation matrix is solved exactly for its eigenvalues and eigenvectors, so the result is the same every time.
  • Variance explained. Each eigenvalue over the number of assets.
  • Loadings. Each eigenvector times the square root of its eigenvalue: the asset's correlation with the component.
  • Sign. Each component is signed so its loadings sum positive, so PC1 reads as the basket rising and keeps its sign from day to day.
  • Noise edge. The Marchenko-Pastur upper edge, (1 + √(assets / days))², over the number of assets. A component below it cannot be told apart from chance; the caption counts the ones above it.

What to look for

  • How much variance PC1 takes. A dominant PC1 means one factor is running everything.
  • An asset loading against the others on PC1: a diversifier while it lasts.
  • Only one or two components above the noise edge: the basket is fewer bets than it looks.

Controls

Basket / + Add
Opens on BTC, ETH, SPY, QQQ, TLT, GOLD, DXY and BRENT. Click a chip to remove it. + Add opens the asset picker, which stays open to add several. At least 3 are needed.
Window
90D, 6M, 1Y (the default), 2Y or 3Y of calendar days.
PCs
How many components to keep: 3, 4, 5 (the default), 6, 8 or 10.
View
Scree (the default), Loadings, Scores or Biplot.
STATS
Shows or hides the stats column.

Good to know

  • Uses simple daily returns on the days every asset in the basket closed, so a basket with an equity in it runs on trading days and a weekend folds into Monday. The header shows the observation count.
  • Needs at least 3 assets and 20 days on which every one of them closed.

Pairs well with

CORRMATREGRRISKPARCORR

Questions

What does PC1 usually represent?

In a mixed basket it is often broad risk-on or risk-off. If every asset loads the same way on it, it is the market factor.

Is a loading a correlation?

Here, yes: the eigenvector scaled by the square root of its eigenvalue, which is the asset's correlation with the component. Many tools show the raw eigenvector, which is smaller and is not a correlation.

How many components matter?

The ones above the noise edge on the scree. Below it, a component is no bigger than what random, unrelated series of the same length would show.