Skip to content
All library documents

Comparing Covariance Shrinkage Implementations with a Constant-Correlation Prior

Article Quant Q&A · Author: Ana B.

Summary

The document raises a reproducibility question about covariance shrinkage toward a constant-correlation prior in R. It names two packages that offer shrinkage routines and asks why their outputs differ when applied to the same generated data. The response presents a smaller example and reports matrices returned by two alternative covariance estimation calls. One output is diagonal, while the other includes nonzero off-diagonal entries, illustrating that results can differ substantially across routines or settings.

The example is useful as a prompt to check what each function estimates and how its arguments define the shrinkage target. However, the response does not establish that the packages implement identical estimators, explain their parameter conventions, or diagnose the original discrepancy. It offers a belief that one implementation may have an issue, rather than a verified conclusion. Researchers should consult package documentation and compare target definitions, inputs, and preprocessing before treating the outputs as directly comparable.

Key ideas

  • Covariance shrinkage methods may produce different estimates even when described as using a constant-correlation target.
  • The example contrasts a diagonal covariance output with one containing off-diagonal covariances.
  • Function names and package labels alone do not establish that two estimators are equivalent.
  • A valid comparison requires checking each method’s target, assumptions, arguments, and input handling.
  • The document reports a discrepancy but does not identify its cause conclusively.

Tags

Full text
# Ledoit Wolf shrinkage with constant correlation prior with tawny and Riskporfolios


# Ledoit Wolf shrinkage with constant correlation prior with tawny and Riskporfolios












I am trying to use R to perform the shrinkage of covariance matrix towards constant correlation as defined in 'Honey, I Shrunk the Sample Covariance Matrix'.

I see there are two packages where this is already implemented:

```
library(MASS)
library(tawny)
library(RiskPortfolios)
set.seed(10)

matrixA=mvrnorm(n = 10000, 0.5, 0.2, tol = 1e-6, empirical = TRUE, EISPACK = FALSE)
matrixA=matrix(matrixA,500,20)
```

- tawny: `cov_shrink(matrixA)`



The output should be the same covariance matrix however this doesn't happen. Would anyone know why?

## Answer by Ana B. (score 2)

https://quant.stackexchange.com/a/40122

You can try to run the first line of code for a smaller matrix:

```
matrixA=mvrnorm(n = 20, 0.5, 0.2, tol = 1e-6, empirical = TRUE, EISPACK = FALSE)
matrixA=matrix(matrixA,5,4)
```

and the by using:

cov.shrink(matrixA):

```
> [1,] 0.2642444 0.0000000 0.0000000 0.0000000 
  [2,] 0.0000000 0.2064425 0.0000000 0.000000  
  [3,] 0.0000000 0.0000000 0.2318104 0.0000000 
  [4,] 0.0000000 0.0000000 0.0000000 0.1624061
```

whereas with covEstimation(matrixA,control=list(type="cor")): I get:

```
            [,1]        [,2]        [,3]        [,4]
[1,]  0.27315366 -0.04648824 -0.05445814 -0.02765077
[2,] -0.04648824  0.14779198 -0.04005758 -0.02033898
[3,] -0.05445814 -0.04005758  0.20281035 -0.02382587
[4,] -0.02765077 -0.02033898 -0.02382587  0.05228524
```

I believe there is some issue with Tawny or it is not clear what is the outcome, also based on the comment in https://systematicinvestor.wordpress.com/2011/11/11/resampling-and-shrinkage-solutions-to-instability-of-mean-variance-efficient-portfolios/

Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.