Expected Shortfall vs VaR

I have a question about how to compute the Expected Shortfall practically. I know from the theory that the ES is the conditional Expectation of the Loss distribution (conditional on the VaR) and that it is intrinsically greater than the VaR:

ES_α = E[L|L > VaR_α]

Following this formula I have calculated the VaR in R using quantile(loss, probs=0.999) function on my loss distribution. Then I have filtered the loss distribution observations greater than the VaR, filter(loss > VaR), and applied on this filtered loss distribution the expectation formula using sum(x*probability(x)).

However it turns out that the VaR is greater than the ES. How is it possible? Having the Loss distribution how should I calculate VaR and ES? Did I do it wrong?

• VaR is the $\alpha$ quantile value, CVaR is the mean of all the values up to the $\alpha$ quantile, so CVaR will be $\leq$ VaR (if we are talking about the lower tail). Dec 7, 2022 at 11:18
• With CVaR you mean ES? Anyway if I compute the "mean of all the values up to the α quantile" the ES > VaR, because it doesn't consider the relative frequencies of the loss observations, something that the expected value formula instead considers. So, shouldn't the "mean of all the values up to the α quantile" be instead weighted to the relative frequencies? Dec 7, 2022 at 11:40
• Also worth noting: in your graph, the ES is not the colored area (which is simply equal to $1-a$), as your arrow would indicate. The ES will be a value on the x-axis, in this case to the right of VaR.
– Emil
Dec 7, 2022 at 13:08
• Do you have a parametric distribution fit or just samples? If only samples see Richard Hardy answer below; if a parametric distribution fit I recommend a plugin estimator -- it's more stable especially for very high alpha. Dec 7, 2022 at 13:45

Simulating from a standard normal distribution as your chart suggests, you should get something like this

set.seed(2022)
loss <- rnorm(10^6)
VaR <- quantile(loss, probs=0.999)
VaR  # about qnorm(0.999) i.e. 3.090232
#    99.9%
# 3.090315
mean(loss[loss >= VaR]) # about dnorm(qnorm(0.999))/(1-0.999) i.e. 3.36709
# 3.36505


It is not totally clear to me what the probabilities are in sum(x*probability(x)) but assuming the x are losses greater than VaR then what you want is the conditional expectation sum(x*probability(x))/sum(probability(x))

• Why should expected shortfall approximately equal dnorm(qnorm(0.999))/(1-0.999)? Dec 9, 2022 at 21:22
• @RichardHardy You can do the integration, but essentially this is the mean of a truncated normal distribution Dec 12, 2022 at 10:42
• Thank you. Somehow I was not aware of that. Dec 12, 2022 at 11:00

When calculating ES as sum(x*probability(x)), make sure to adjust the probabilities so that they sum up to one. If you have filtered the data to only keep losses greater than VaR, simply take their empirical mean by mean(...).