Skip to content
LeetQuant
QR10 Portfolio Construction and Risk

QR10 · Portfolio Construction and Risk · Lesson 3 of 5

Covariance Estimation and Shrinkage

Why the sample covariance matrix is noisy when the number of assets is close to the number of observations, how eigenvalues spread, and how shrinkage, factor models and EWMA give usable estimates.

18 min

Objective

Every portfolio construction step (minimum variance, mean–variance, risk parity, risk limits) takes a covariance matrix as input, and none of them can do better than that input. By the end you should be able to explain why the sample covariance matrix fails when NN (assets) is comparable to TT (observations), describe what the failure does to an optimiser, and choose between shrinkage, a factor model and an exponentially weighted estimate.

The sample covariance matrix and its limits

With TT demeaned return vectors rt∈RNr_t \in \mathbb{R}^N,

S=1T−1∑t=1T(rt−rˉ)(rt−rˉ)⊤.S = \frac{1}{T-1}\sum_{t=1}^{T} (r_t - \bar r)(r_t - \bar r)^\top .

Each entry is unbiased, but SS has N(N+1)/2N(N+1)/2 free entries estimated from NTNT numbers, and its rank is at most T−1T - 1. The key ratio is

q=NT.q = \frac{N}{T} .

If q≥1q \ge 1 (for example 500 stocks and one year of daily data) SS is singular: some portfolios appear to have zero variance, and S−1S^{-1} does not exist. Even for qq well below 1, SS is a poor input to an optimiser, for a reason best seen through its eigenvalues.

Eigenvalue spreading

Suppose the true covariance is the identity: NN uncorrelated assets with unit variance. Every true eigenvalue is 1. The sample eigenvalues are not. For large NN and TT with q=N/T<1q = N/T < 1 fixed, the Marchenko–Pastur law says they fill the interval

λ∈[(1−q)2, (1+q)2].\lambda \in \Big[\big(1 - \sqrt q\big)^2,\ \big(1 + \sqrt q\big)^2\Big] .

With N=100N = 100 and T=250T = 250 (q=0.4q = 0.4) that is roughly [0.135, 2.665][0.135,\ 2.665]: pure noise produces a "factor" with nearly three times the average variance and directions that look almost riskless. The average eigenvalue is still 1 (the trace is unbiased), so the noise does not change the total variance; it redistributes it, biasing the largest eigenvalues up and the smallest down.

In real data the top few eigenvalues (market, sectors) sit well above the noise edge and are genuine. The bulk inside the Marchenko–Pastur range is mostly indistinguishable from noise. One cleaning method, eigenvalue clipping, keeps the eigenvalues above the upper edge and replaces the rest by their average, preserving the trace.

Why optimisers make it worse

A minimum-variance optimiser computes Σ−11\Sigma^{-1}\mathbf 1. Inversion turns the smallest eigenvalues into the largest weights, so the optimiser loads on exactly the directions where SS is most wrong: the spuriously low-variance ones. The result is a portfolio whose predicted risk is too low and whose realised risk is too high. This is "error maximisation": the optimiser finds the estimation errors.

Worked example

predicted versus realised risk of a sample minimum-variance portfolio

True returns are 100 uncorrelated assets with unit variance, so the true minimum-variance portfolio is equal weight with variance 1/1001/100. You estimate SS from T=250T = 250 normal observations and build w=S−11/(1⊤S−11)w = S^{-1}\mathbf 1 / (\mathbf 1^\top S^{-1}\mathbf 1). How do its predicted variance w⊤Sww^\top S w and its true variance w⊤Σww^\top\Sigma w compare with 1/1001/100?

Show solution

For normal data the answer is known in closed form (the predicted minimum variance 1/(1⊤S−11)1/(\mathbf 1^\top S^{-1}\mathbf 1) follows a scaled chi-squared distribution), and to first order in q=N/Tq = N/T:

E[w⊤Sw]≈(1−q) σmin⁡2,E[w⊤Σw]≈σmin⁡21−q.\mathbb{E}\big[w^\top S w\big] \approx (1 - q)\,\sigma^2_{\min}, \qquad \mathbb{E}\big[w^\top \Sigma w\big] \approx \frac{\sigma^2_{\min}}{1 - q} .

With q=0.4q = 0.4: the optimiser predicts variance 0.6/1000.6/100 and delivers about 1.67/1001.67/100. A 300-run simulation gives 0.603/1000.603/100 and 1.66/1001.66/100.

In volatility terms, the portfolio claims 0.6≈77%\sqrt{0.6} \approx 77\% of the true minimum volatility and realises 1.67≈129%\sqrt{1.67} \approx 129\% of it. The gap between forecast and outcome is a factor of 1.67/0.6≈2.81.67/0.6 \approx 2.8 in variance, with no model error at all, only sampling noise. Naive equal weighting, which ignores the data entirely, would have hit the true minimum exactly.

Shrinkage toward a target

Shrinkage trades a little bias for a large cut in variance. Pick a structured target FF with few parameters and blend:

Σ^=δF+(1−δ)S,0≤δ≤1.\hat\Sigma = \delta F + (1 - \delta) S, \qquad 0 \le \delta \le 1 .

Common targets:

  • Scaled identity, F=σˉ2IF = \bar\sigma^2 I with σˉ2=tr⁡(S)/N\bar\sigma^2 = \operatorname{tr}(S)/N. Shrinking toward it keeps the eigenvectors of SS and pulls every eigenvalue toward the mean: λ^k=δσˉ2+(1−δ)λk\hat\lambda_k = \delta\bar\sigma^2 + (1 - \delta)\lambda_k.
  • Diagonal, F=diag⁡(S)F = \operatorname{diag}(S): keeps the variances and multiplies every correlation by 1−δ1 - \delta.
  • Constant correlation: sample variances with every correlation set to the average sample correlation.
  • Single-index (market) model: F=ββ⊤σm2+DF = \beta\beta^\top\sigma_m^2 + D.

Ledoit and Wolf choose δ\delta to minimise the expected squared (Frobenius) distance between Σ^\hat\Sigma and the true Σ\Sigma. Ignoring the small correlation between the errors of FF and SS, the optimum is

δ∗≈∑i,jVar⁡(sij)∑i,jE[(sij−fij)2],\delta^* \approx \frac{\sum_{i,j}\operatorname{Var}(s_{ij})}{\sum_{i,j}\mathbb{E}\big[(s_{ij} - f_{ij})^2\big]} ,

clipped to [0,1][0, 1]. The numerator is the estimation noise in SS; the denominator is how far SS sits from the target, which is noise plus genuine misspecification of FF. Both parts can be estimated from the same data, so δ∗\delta^* is data driven. As TT grows the noise falls like 1/T1/T and δ∗→0\delta^* \to 0: with enough data you trust the sample.

Shrinkage also guarantees good conditioning. If FF is positive definite and δ>0\delta > 0, Σ^\hat\Sigma is positive definite even when SS is singular, so it can always be inverted.

Worked example

shrinking a noisy correlation

Asset 1 has 10% volatility and asset 2 has 20%. The sample correlation is 0.8, but the true one is 0.5. (a) Find the sample minimum-variance weights and their true volatility. (b) Shrink toward the diagonal target with δ=0.5\delta = 0.5 and repeat. (c) Separately, if the eigenvalues of a sample matrix are 2.665 and 0.135 and you shrink toward the identity with δ=0.4\delta = 0.4, what happens to the condition number?

Show solution

(a) With ρ=0.8\rho = 0.8, σ12=0.016\sigma_{12} = 0.016 and

w1=σ22−σ12σ12+σ22−2σ12=0.04−0.0160.01+0.04−0.032=43,w2=−13.w_1 = \frac{\sigma_2^2 - \sigma_{12}}{\sigma_1^2 + \sigma_2^2 - 2\sigma_{12}} = \frac{0.04 - 0.016}{0.01 + 0.04 - 0.032} = \tfrac43, \qquad w_2 = -\tfrac13 .

Under the true ρ=0.5\rho = 0.5 (σ12=0.01\sigma_{12} = 0.01) its variance is 169(0.01)+19(0.04)−2⋅43⋅13(0.01)=0.01333\tfrac{16}{9}(0.01) + \tfrac19(0.04) - 2 \cdot \tfrac43 \cdot \tfrac13 (0.01) = 0.01333, a volatility of 11.55%11.55\%.

(b) The diagonal target keeps the variances and halves the correlation to 0.40.4, so σ12=0.008\sigma_{12} = 0.008:

w1=0.04−0.0080.01+0.04−0.016=0.0320.034≈0.941,w2≈0.059.w_1 = \frac{0.04 - 0.008}{0.01 + 0.04 - 0.016} = \frac{0.032}{0.034} \approx 0.941, \qquad w_2 \approx 0.059 .

Its true volatility is 10.05%10.05\%. The true optimum at ρ=0.5\rho = 0.5 is w=(1,0)w = (1, 0) with volatility 10%10\% (since ρ=σ1/σ2\rho = \sigma_1/\sigma_2 exactly). Shrinkage removed the spurious short and recovered almost all of the lost efficiency.

(c) New eigenvalues are 0.4+0.6×2.665=1.9990.4 + 0.6 \times 2.665 = 1.999 and 0.4+0.6×0.135=0.4810.4 + 0.6 \times 0.135 = 0.481. The condition number falls from 2.665/0.135≈19.72.665/0.135 \approx 19.7 to 1.999/0.481≈4.21.999/0.481 \approx 4.2, so the inverse, and hence the optimiser, is far less sensitive to noise.

Factor-model covariance

A factor model imposes structure instead of blending toward it:

Σ=B Σf B⊤+D,\Sigma = B\,\Sigma_f\,B^\top + D ,

with k≪Nk \ll N factors and diagonal specific variances DD. It is positive definite whenever D>0D > 0, needs O(Nk)O(Nk) parameters instead of O(N2)O(N^2), and its smallest eigenvalue is at least min⁡iDii\min_i D_{ii}, which caps the leverage an optimiser can find. In the single-index model, σij=βiβjσm2\sigma_{ij} = \beta_i\beta_j\sigma_m^2 for i≠ji \ne j and σi2=βi2σm2+si2\sigma_i^2 = \beta_i^2\sigma_m^2 + s_i^2.

For example, with σm=16%\sigma_m = 16\%, β=(1.2, 0.8)\beta = (1.2,\ 0.8) and specific volatilities 25%25\% and 20%20\%: the covariance is 1.2×0.8×0.0256=0.02461.2 \times 0.8 \times 0.0256 = 0.0246, the variances are 0.09940.0994 and 0.05640.0564 (volatilities 31.5%31.5\% and 23.7%23.7\%), and the implied correlation is 0.330.33. One market variance, two betas and two specific variances determine every entry.

Structure also guarantees validity. A matrix assembled entry by entry (correlations from different windows, or pairwise over different date ranges) need not be positive semidefinite, and then some portfolio has negative "variance". The equicorrelation matrix shows the constraint: its eigenvalues are 1+(n−1)ρ1 + (n - 1)\rho and 1−ρ1 - \rho, so nn assets cannot all have pairwise correlation below −1/(n−1)-1/(n - 1). Shrinkage toward a PD target and factor models never have this problem.

The price is bias: correlations not explained by the factors are forced to zero. In practice desks combine the two ideas, using a fundamental or statistical factor model and treating it as the shrinkage target or adding a few residual correlations back.

EWMA covariance

Volatility and correlation change over time, so equal-weighting a long window is stale. The exponentially weighted moving average (RiskMetrics) updates

Σt=λ Σt−1+(1−λ) rt−1rt−1⊤,\Sigma_t = \lambda\,\Sigma_{t-1} + (1 - \lambda)\, r_{t-1} r_{t-1}^\top ,

assuming zero mean daily returns. The weight on an observation kk days old is (1−λ)λk(1 - \lambda)\lambda^k, so the effective window is about 1/(1−λ)1/(1 - \lambda) and the half-life is ln⁡0.5/ln⁡λ\ln 0.5/\ln\lambda. RiskMetrics uses λ=0.94\lambda = 0.94 for daily data: an effective window of about 17 days and a half-life of about 11 days.

The trade-off is the same as in shrinkage, now across time. A short window reacts to regime changes but is noisy, and an EWMA covariance with an effective window of 17 days is badly conditioned for more than a handful of assets. Common fixes are a longer half-life for correlations than for volatilities, or EWMA on the factor covariance Σf\Sigma_f (small) with slower updates for the loadings and specific risks.

Worked example

one EWMA update

With λ=0.94\lambda = 0.94, yesterday's estimates are daily volatilities 1% and 2% and correlation 0.5. Today's returns are −2%-2\% and −3%-3\%. Update the volatilities and the correlation.

Show solution

In units of 10−410^{-4}: σ12=1\sigma_1^2 = 1, σ22=4\sigma_2^2 = 4, σ12=0.5×1×2=1\sigma_{12} = 0.5 \times 1 \times 2 = 1, and the cross-products of today's returns are r12=4r_1^2 = 4, r22=9r_2^2 = 9, r1r2=6r_1 r_2 = 6.

σ12=0.94(1)+0.06(4)=1.18,σ22=0.94(4)+0.06(9)=4.30,σ12=0.94(1)+0.06(6)=1.30.\sigma_1^2 = 0.94(1) + 0.06(4) = 1.18, \quad \sigma_2^2 = 0.94(4) + 0.06(9) = 4.30, \quad \sigma_{12} = 0.94(1) + 0.06(6) = 1.30 .

The volatilities become 1.18≈1.086%\sqrt{1.18} \approx 1.086\% and 4.30≈2.074%\sqrt{4.30} \approx 2.074\%, and the correlation

ρ=1.301.18×4.30≈0.577.\rho = \frac{1.30}{\sqrt{1.18 \times 4.30}} \approx 0.577 .

A single day on which both assets fell together raised the correlation estimate from 0.5 to 0.58. That responsiveness is the point of EWMA, and also why EWMA correlations jump in sell-offs, exactly when diversification is most needed.

Knowledge check

You compute the sample covariance of 50 truly uncorrelated, unit-variance assets from 200 observations. Roughly what range do the sample eigenvalues cover?

Knowledge check

You shrink a sample covariance matrix toward a scaled identity target. What happens to its eigenvectors and eigenvalues?

Knowledge check

What is the half-life, in days, of an EWMA estimator with λ=0.97\lambda = 0.97?

Key takeaways

  • The sample covariance has rank at most T−1T - 1; with q=N/Tq = N/T near or above 1 it is singular or nearly so.
  • Under pure noise, sample eigenvalues spread over [(1−q)2,(1+q)2][(1 - \sqrt q)^2, (1 + \sqrt q)^2]; optimisers load on the spuriously small ones.
  • A sample minimum-variance portfolio predicts about (1−q)σmin⁡2(1 - q)\sigma^2_{\min} and realises about σmin⁡2/(1−q)\sigma^2_{\min}/(1 - q).
  • Shrinkage δF+(1−δ)S\delta F + (1 - \delta)S trades bias for variance, keeps the estimate positive definite, and Ledoit–Wolf picks δ\delta from the data.
  • Factor models impose structure with O(Nk)O(Nk) parameters; EWMA tracks time variation with effective window 1/(1−λ)1/(1 - \lambda) and half-life ln⁡0.5/ln⁡λ\ln 0.5/\ln\lambda.

Practice problems

Finished reading?

Answer the 3 knowledge checks to complete this lesson (0 done).