# [R-SIG-Finance] CVaR, fExtremes

Enrico Schumann enricoschumann at yahoo.de
Fri Jul 11 13:17:28 CEST 2008

it seems to me there is a sign problem when it comes to upper and lower
tail. try the following (sorry that I change your example, but for the
Gaussian its easier to check)

require(fExtremes)
testData <- rnorm(100000)

# the function
CVaRtest <- function (x, alpha = 0.05, type = "sample", tail = c("lower",
"upper"))
{
x = as.matrix(x)
tail = match.arg(tail)
VaR = VaR(x, alpha, type, tail)
if (type == "sample") {
CVaR = NULL
if (tail=="lower"){
for (i in 1:ncol(x)) {
X = as.vector(x[, i])
Z <- VaR[i] - X
CVaR = c(CVaR, VaR[i] - 0.5 * mean((Z +
abs(Z)))/alpha)
}
}else{
for (i in 1:ncol(x)) {
X = as.vector(x[, i])
Z <- VaR[i] - X
CVaR = c(CVaR, VaR[i] - 0.5 * mean((Z -
abs(Z)))/alpha)
}
}
}
CVaR
}

VaR(testData,.05,tail="lower")
CVaR(testData,.05,tail="lower")
CVaRtest(testData,.05,tail="lower")

VaR(testData,.05,tail="upper")
CVaR(testData,.05,tail="upper")
CVaRtest(testData,.05,tail="upper")

# so, for your data
n <- 1000000
loss.ratio <- rlnorm(n, -0.3479, 0.104)

VaR(loss.ratio,.05,tail="lower")
CVaR(loss.ratio,.05,tail="lower")
CVaRtest(loss.ratio,.05,tail="lower")

VaR(loss.ratio,.05,tail="upper")
CVaR(loss.ratio,.05,tail="upper")
CVaRtest(loss.ratio,.05,tail="upper")

# a quick check
mean(loss.ratio[loss.ratio > quantile(loss.ratio,.95)])
mean(loss.ratio[loss.ratio < quantile(loss.ratio,.05)])

(btw. the documentation states that alpha is a numeric value, the
confidence interval', but this should rather be confidence interval =
1-\alpha')

best, enrico

cc: diethelm,yohan

-----Ursprüngliche Nachricht-----
Von: r-sig-finance-bounces at stat.math.ethz.ch
[mailto:r-sig-finance-bounces at stat.math.ethz.ch] Im Auftrag von Markus
Gesmann
Gesendet: Donnerstag, 10. Juli 2008 13:05
An: r-sig-finance at stat.math.ethz.ch
Betreff: [R-SIG-Finance] CVaR, fExtremes

Hi all,

I struggle to understand the output of the CVaR function in the fExtremes
package.
The output of VaR (Value at Risk) gives me results I expect to see. However
the output of CVaR is less than the output of VaR. From my understanding
CVaR gives the mean over a given threshold and should therefore always be
bigger than VaR.
The fowling example shows the output of VaR and CVaR:

library(fExtremes)
n <- 1000000
loss.ratio <- rlnorm(n, -0.3479, 0.104)
VaR(loss.ratio, 0.995) # same as quantile(loss.ratio, 0.995)
#    99.5%
# 0.9588572
CVaR(loss.ratio, 0.995)
#    99.5%
#0.7088572

I expected an output more like this:
mean(loss.ratio[loss.ratio > 0.995])
# 1.021089
mean(loss.ratio[loss.ratio > 0.995]) - VaR(loss.ratio, 0.995) #  99.5%
#0.09783733

Maybe I am just a little bit confused and mix up terminologies.

Markus

This message is intended for the personal and confidential use for the
designated recipient(s) named above.  If you are not the intended recipient
of this message you are hereby notified that any review, dissemination,
distribution or copying of this message is strictly prohibited. This
communication is for information purposes only and should not be regarded as
an offer to sell or as a solicitation of an offer to buy any financial
product, an official confirmation of any transaction or as an official
statement of Libero Ventures Ltd.  Email transmissions cannot be guaranteed
to be secure or error-free. Therefore we do not represent that this
information is complete or accurate and it should not be relied upon as
such.  All information is subject to change without notice.

_______________________________________________
R-SIG-Finance at stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only.
-- If you want to post, subscribe first.
No virus found in this incoming message.
Checked by AVG - http://www.avg.com

09.07.2008
18:32



More information about the R-SIG-Finance mailing list