Ledoit-Wolf Shrinkage

The Ledoit-Wolf Shrinkage pulls the sample covariance towards the identity matrix scaled by the average variance, with the shrinkage intensity that minimizes the expected squared (Frobenius) distance to the true covariance matrix (Ledoit and Wolf, 2004). The target has no estimation error and the sample covariance no bias, and the mix keeps the matrix well-conditioned.

The formula for the Ledoit-Wolf Shrinkage starts from the sample covariance S of the demeaned returns \(y_{i , t}\) of the N assets over the T periods, divided by T, and the target F, the identity matrix I times the average variance nu:

\[S_{i,j} = \frac{\sum_{t=1}^{T} y_{i,t} \cdot y_{j,t}}{T}\] \[\nu = \frac{\sum_{i=1}^{N} S_{i,i}}{N}\] \[F = \nu \cdot I\]

The intensity delta compares the variance of the entries of S, \(b^{2}\), with their squared distance from the target, \(d^{2}\):

\[b^{2} = \frac{\sum_{t=1}^{T} \sum_{i=1}^{N} \sum_{j=1}^{N} (y_{i,t} \cdot y_{j,t} - S_{i,j})^{2}}{N \cdot T^{2}}\] \[d^{2} = \frac{\sum_{i=1}^{N} \sum_{j=1}^{N} (S_{i,j} - F_{i,j})^{2}}{N}\] \[\delta = \frac{\min\left(b^{2}, d^{2}\right)}{d^{2}}\]

The estimate moves S that share of the way to the target:

\[\Sigma = (1 - \delta) \cdot S + \delta \cdot F\]

A delta close to 0 means the sample covariance is precise enough on its own, one close to 1 that the history cannot tell the assets apart. The target treats every asset as equally volatile and unrelated, so it also pulls the correlations towards zero.

Its parameters can be set, and it can be shown as a correlation matrix. The covariance matrix holds the variance of every asset and the covariance of every pair, the risk input of the mean-variance analysis of Markowitz (1952). With N assets it holds N (N + 1) / 2 numbers to estimate, and when N is not small compared to the number of periods T, the sample estimate is noisy and ill-conditioned: its smallest eigenvalues come out too small, and an optimizer that inverts it puts large weights on the combinations of assets that only look safe in the sample. The estimators differ in how they deal with this: by shrinking towards a structured target, by cleaning the eigenvalues, by weighting recent periods, by counting only large moves or by resisting outliers. Every estimate is annualized with the number of periods in a year.

Also known as: Ledoit-Wolf covariance, shrunk covariance, shrinkage towards the identity.

In the Finance Toolkit this is get_covariance_estimate with method="ledoit_wolf", the same function as Covariance Estimate.

Example · AAPL, MSFT, JNJ, XOM · 2021 to 2025

Install the Finance Toolkit with pip install financetoolkit -U, then call get_covariance_estimate:

from financetoolkit import Toolkit

toolkit = Toolkit(
    ["AAPL", "MSFT", "JNJ", "XOM"],
    api_key="FINANCIAL_MODELING_PREP_KEY",
    start_date="2021-01-01",
    end_date="2025-12-31",
)

toolkit.portfolio.get_covariance_estimate(method="ledoit_wolf")

Which returns:

References

  • Paper Ledoit, O. and Wolf, M. (2004). “A Well-Conditioned Estimator for Large-Dimensional Covariance Matrices.” Journal of Multivariate Analysis, 88(2), 365-411.
  • Library Referenced against scikit-learn’s LedoitWolf (Ledoit-Wolf Shrinkage)
  • Library Shares similar logic as PyPortfolioOpt’s CovarianceShrinkage.ledoit_wolf (Ledoit-Wolf Shrinkage, Ledoit-Wolf Constant Correlation Shrinkage, Ledoit-Wolf Single Factor Shrinkage)
Share