Matrix calculus: the identities behind OLS, ridge and portfolios
LA · Chapter 712 min readAsked at Two Sigma, Citadel, DE Shaw, QuantCo
Assumes Definiteness, Cholesky and generating correlated normals.
After this lesson you should be able to
- Differentiate the standard linear and quadratic forms.
- Derive OLS, ridge and the minimum-variance portfolio from scratch.
- Use a Lagrange multiplier on a constrained quadratic problem.
Four derivative identities generate most of the closed-form results in quantitative finance. Knowing them means you can derive OLS, ridge, the minimum-variance portfolio and the tangency portfolio on a whiteboard rather than recalling them.
| Expression | Derivative with respect to |
|---|---|
| , which is when is symmetric | |
| (w.r.t. ) | |
| (w.r.t. ) |
Derivation 7.2
OLS in three lines
Minimise the squared residual.
Apply the fourth identity.
Derivation 7.3
Ridge, from the same start
Add the penalty and differentiate again.
The penalty contributes by the third identity.
Derivation 7.4
The minimum-variance portfolio
Minimise variance subject to the weights summing to one.
Lagrangian with one constraint.
The direction falls out immediately.
Why every answer has in it. Minimum variance gives , the tangency portfolio gives , and a hedge ratio gives times a covariance vector. The inverse covariance keeps appearing because it is the natural weighting: it downweights directions with a lot of risk and upweights the quiet ones. That is also why every one of these is so unstable in practice — inverting a noisily estimated amplifies exactly its least reliable directions, which is the case for shrinkage restated in one sentence.
The rest of this lesson is in Premium
You have read the opening. 10 more sections follow, including 4 worked examples and 3 quick checks.
Nothing is charged for 7 days, and you can cancel before then. Or read The law of large numbers and the central limit theorem in full, free.