inst/BookEx/C12R4.R

## Portfolio Names
Pnames <- c("GMV", "MaxDD", "AveDD", "CDaR95", "CDaRMin95")
## Portfolio allocations
WeightMatrix <- cbind(getWeights(GMV),
                      Weights(MaxDD),
                      Weights(AveDD),
                      Weights(CDaR95),
                      Weights(CDaRMin95))
colnames(WeightMatrix) <- Pnames
## Expected Shortfall and components
tmp <- apply(WeightMatrix, 2, function(x) ES(Rets, weights = x,
             method = "gaussian", portfolio_method = "component"))
## ES 95%
PES <- unlist(lapply(tmp, function(x) x[[1]])) * 100
## Marginal Contributions to ES
PMES <- matrix(unlist(lapply(tmp, function(x) x[[3]])),
               nrow = ncol(Rets)) * 100
rownames(PMES) <- colnames(Rets)
colnames(PMES) <- Pnames
## Marginal Contributions to StdDev
V <- cov(Rets)
PMRC <- apply(WeightMatrix, 2, mrc, Sigma = V)
rownames(PMRC) <- colnames(Rets)
## Diversification ratio
PDR <- apply(WeightMatrix, 2, dr, Sigma = V)

Try the FRAPO package in your browser

Any scripts or data that you put into this service are public.

FRAPO documentation built on May 2, 2019, 5:24 p.m.