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_α]

enter image description here

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?

  • $\begingroup$ 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). $\endgroup$ Dec 7, 2022 at 11:18
  • $\begingroup$ 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? $\endgroup$
    – fredi96
    Dec 7, 2022 at 11:40
  • 1
    $\begingroup$ 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. $\endgroup$
    – Emil
    Dec 7, 2022 at 13:08
  • $\begingroup$ 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. $\endgroup$ Dec 7, 2022 at 13:45

2 Answers 2


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

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))

  • $\begingroup$ Why should expected shortfall approximately equal dnorm(qnorm(0.999))/(1-0.999)? $\endgroup$ Dec 9, 2022 at 21:22
  • $\begingroup$ @RichardHardy You can do the integration, but essentially this is the mean of a truncated normal distribution $\endgroup$
    – Henry
    Dec 12, 2022 at 10:42
  • $\begingroup$ Thank you. Somehow I was not aware of that. $\endgroup$ 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(...).


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.