Basic Prerequisites: 04 · Eigenvalues & Covariance.
1. Intuition & Practical Objective
This page is where the folder earns its keep: the singular value decomposition (SVD) unifies three things every quant uses daily - least-squares regression, principal components analysis (PCA), and low-rank approximation / denoising - into one factorization. The objective is to see that these are not three methods but one decomposition viewed three ways: the SVD of the design/return matrix is simultaneously (a) the engine behind , (b) the geometry behind PCA’s principal axes, and (c) the machine behind the best rank- approximation (Eckart–Young).
In one line: regression asks “which combination of my columns best predicts ?”, PCA asks “which few directions carry most of the variance?”, and SVD answers both because it decomposes any matrix into independent rank-one layers . The largest layers are the signal; the smallest are the noise you should drop.
2. Mathematical Ground Truth & Derivations
Least squares (ESL Ch 3). Minimize (ESL eq. 3.3). The normal equations (3.5) give the closed form (ESL eq. 3.6)
with the hat matrix projecting onto the column space. This is the workhorse of factor models - each factor exposure is a linear regression of the return on the factor. Ridge adds an penalty (3.41–3.44):
which, via the SVD (ESL 3.45), shrinks each fitted component by (3.47): more shrinkage on the smaller (noisier) singular values .
SVD (ESL eq. 3.45, 14.54). Any real factors as with , , diagonal with singular values , where and . Equivalently
Eckart–Young–Mirsky. The best rank- approximation to (minimizing Frobenius error) is , and the error is . This is the mathematical engine of denoising: keep the big singular layers, drop the tail.
PCA via SVD (ESL 14.5). PCA fits the best rank- affine manifold to the rows (model eq. 14.49) by minimizing reconstruction error (eq. 14.50) - solved by the SVD eq. 14.54. The first right-singular vectors are the principal axes; the singular values measure how much variance each carries. (ESL’s digits example: 12 of 256 SVD directions account for 63% of variance.)
3. Computational Implementation - regression and PCA from the SVD, from scratch
Everything here is implemented from first principles (Jacobi diagonalization + Gaussian elimination), so there is no hidden numpy. Stdlib only.
Regression and the SVD give byte-identical coefficients (both solve the same normal equations; the SVD route is the numerically safer one for ill-conditioned ). And the best rank-2 manifold of misses exactly of Frobenius error - the Eckart–Young guarantee that PCA/denoising “keep the big layers, drop the tail” is exact, not heuristic.
4. Failure Modes & First-Principles Breakdowns
- Normal equations can be ill-conditioned even when the problem isn’t. Forming squares the condition number (). For wide or nearly-collinear , solve via the SVD / QR instead - this is the difference between “works” and “silently wrong.”
- makes singular (rank ). The normal equations have no unique solution; PCA on the sample covariance fills the spectrum with noise eigenvalues (06). Ridge () and shrinkage restore a solution by pushing the ill-conditioned directions off.
- SVD truncation is a model choice, not a given. Dropping “small” singular values removes noise and genuine small-signal directions; the cut-off (ESL digits kept 12/256 for 63%) must be justified (eigenvalue gap, cross-validation, or RMT threshold - 06).
- Correlation vs covariance scale. PCA on (scale-sensitive) vs on the correlation matrix (scale-free) gives different axes; standardized data is the default for factor extraction (Tsay §9.4).
5. References
- Hastie, Tibshirani, Friedman, The Elements of Statistical Learning (2nd ed.)
- Tsay, Analysis of Financial Time Series
- Glasserman, Monte Carlo Methods in Financial Engineering
- Strang, Introduction to Linear Algebra (5th ed.)
6. Connected Graph Bridges
- Back: 04 · Eigenvalues & Covariance · Index Hub
- Continue: 06 · Advanced Extensions (RMT & Numerics)
- Forward: Fundamental Multi-Factor Models (regression = the factor engine) · Covariance Shrinkage & Denoising · Parametric & Monte Carlo VaR · Econometrics & Time Series (OLS/regression diagnostics)