# NOT RUN {
## example with a stress on VaR
set.seed(0)
x <- as.data.frame(cbind(
"normal" = rnorm(1000),
"gamma" = rgamma(1000, shape = 2)))
res1 <- stress(type = "VaR", x = x,
alpha = c(0.9, 0.95), q_ratio = 1.05)
## stressed ES
quantile_stressed(res1, probs = seq(0.9, 0.99, 0.01),
xCol = 1, wCol = 2, type = "i/n")
quantile(x[, 1], probs = seq(0.9, 0.99, 0.01), type = 1)
VaR_stressed(res1, alpha = seq(0.9, 0.99, 0.01), xCol = 1,
wCol = 2, base = TRUE)
## the ES of both model components under stress one
ES_stressed(res1, alpha = seq(0.9, 0.99, 0.01), xCol = "all",
wCol = 1)
## the ES of both model components under stress two
ES_stressed(res1, alpha = seq(0.9, 0.99, 0.01), xCol = "all",
wCol = 2)
# }
Run the code above in your browser using DataLab