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?

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