1

I am using the wonderful PortfolioAnalytics package in R.

To shrink the covariance matrix I use the "sigma.robust" example. I use the EDHEC data.

I create the initial portfolio, and from that, create the 4 portfolios I intend to compare.

What I want to see is that a) passing the robust covar works - by comparing it to one with and without, and b) that it works with risk models of StdDev and Expected Shortfall.

data(edhec)
# Use the first 4 columns in edhec for a returns object
R <- edhec[, 1:4]
colnames(R) <- c("CA", "CTAG", "DS", "EM")
head(R, 5)
funds <- colnames(R)

initialise pf and use some basic constraints

init.portf <- portfolio.spec(assets=funds)
init.portf <- add.constraint(portfolio=init.portf, type="full_investment")
init.portf <- add.constraint(portfolio=init.portf, type="box",min = .05,max = .4)

Portfolio with standard deviation as an objective

SD.portf <- add.objective(portfolio=init.portf, type="risk", name="StdDev")
SD.portf <- add.objective(portfolio=SD.portf, type="return", name="mean")

Portfolio with expected shortfall as an objective

ES.portf <- add.objective(portfolio=init.portf, type="risk", name="ES")
ES.portf <- add.objective(portfolio=ES.portf, type="return", name="mean")

Function for the robust covar

sigma.robust <- function(R){
  require(MASS)
  out <- list()
  set.seed(1234)
  out$sigma <- cov.rob(R, method="mcd")$cov
  return(out)
}

pass through the custom function

opt.sd_robust <- optimize.portfolio(R, SD.portf,optimize_method="ROI",momentFUN =  "sigma.robust",trace = TRUE)
opt.es_robust <- optimize.portfolio(R, ES.portf,optimize_method="ROI",momentFUN =  "sigma.robust",trace = TRUE)

create the normal portfolios that I intend to contrast the effect against

opt.sd <- optimize.portfolio(R, SD.portf,optimize_method="ROI",trace = TRUE)
opt.es <- optimize.portfolio(R, ES.portf,optimize_method="ROI",trace = TRUE)

combine them for easy viewing

opt_comb = combine.optimizations(list(opt.sd_robust = opt.sd_robust,opt.es_robust = opt.es_robust,opt.sd = opt.sd,opt.es = opt.es))

plot them

chart.Weights(opt_comb,ylim(0,1))

inspect them

extractWeights(opt_comb)



                     CA      CTAG  DS   EM
opt.sd_robust 0.08507019 0.1149298 0.4 0.40
opt.es_robust 0.15000000 0.4000000 0.4 0.05
opt.sd        0.05000000 0.1500000 0.4 0.40
opt.es        0.15000000 0.4000000 0.4 0.05

Conclusion

And it does work for the risk model using StdDev. The weights are different. The pass-through has worked. But it doesn't seem to affect the Expected Shortfall model. The weights are identical. I find this is the case even if I relax the box constraint [I'd wondered if I'd rendered any other outcome infeasible, so I tried with and without the constraint].

So I suppose I'm wondering if I'm doing something wrong. I had though ES is just looking in the tail of a distribution that is effectively derived from the transformed covariance matrix.

Thus shrinking/regularising the covar would be compatible with ES.

So I conclude I'm doing something wrong.

Can anybody help?

Dave
  • 11
  • 1
  • Including a [minimal reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) in your question will increase your chances of getting an answer. – Samuel Oct 19 '17 at 01:31

0 Answers0