4
$\begingroup$

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)

  • Risk Porfolios:

    covEstimation(matrixA,control=list(type="cor"))

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

$\endgroup$
  • 1
    $\begingroup$ cov_shrink lets you supply multiple possible shrinkage targets: are you using the constant correlation target for both? $\endgroup$ – surelyourejoking Jun 3 '18 at 11:57
  • $\begingroup$ I believe from some resources that the default of the function cov_shrink is the LW shrinkage to CC, for instance check: systematicinvestor.wordpress.com/2011/11/11/…. However I have tried also with 'cov_shrink(matrixA,prior.fun=cov.prior.cc)' or 'F <- cov.prior.cc(S) cov_shrink(matrixA,prior.fun=F)' but it is not working. $\endgroup$ – Ana B. Jun 3 '18 at 13:59
  • $\begingroup$ Interesting... may I ask how different they are? Perhaps you could edit the question to include a small sample of the output? I suggest you start by making sure that both packages are using the same covariance model: if nobody answers by tomorrow I’ll dig a bit deeper into the R source code to have a look. $\endgroup$ – surelyourejoking Jun 3 '18 at 14:49
2
$\begingroup$

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/

$\endgroup$
  • $\begingroup$ In general there's no reason why all of the non-diagonal elements of the shrunk matrix should be zero... very weird. $\endgroup$ – surelyourejoking Jun 7 '18 at 10:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.