# Density Confidence Interval

Density estimation belongs with the literature of non-parametric statistics. Using simple bootstrapping techniques we can obtain confidence intervals (CI) for the whole density curve. Here is a quick and easy way to obtain CI’s for different risk measures (VaR, expected shortfall) and using what follows, you can answer all kind of relevant questions.

## Density Confidence Interval

To get to the main ideas, let’s start with a simple practical example. We pull data from yahoo, for the SPY ticker which is the ETF which tracks the performance of the S&P 500. We then bootstrap the return series, and estimate the density for each bootstrap sample. This would give us a bunch of density estimates. Those are functions which we can visualize:

### Density Confidence Interval

What is plotted is: (1) black, the density estimate of the return series (2) in blue, overlaid a plot of normal density and (3) in grey is bootstrap density estimates, we have 100 of those estimates; one estimate for each bootstrap sample. Fine, so what do we need it for?

## Usage

An ever increasing in relevance are questions like: “What is the probability to see a daily realized return below -2%?” If you reached thus far in this post, you probably have some experience in picking up such questions. But now you can attach a confidence interval to the reply. We use here the ecdf function which estimates the empirical cumulative distribution function. We plot the whole distribution function, zooming-in on the segment we care about:

### Confidence Interval for the probability of a realized daily return below 2%

The bottom chart is simply a zoomed-in version of the top chart. The probability we are after: the probability to see a realized return below the -2% mark, is about 3%. The range of the bootstrapped estimates is superimposed in green, it is roughly between 1% and 3%. A range of [1%,3%] is more comforting than a range of [1%, 6%], that is why we are doing this: to get a feel for the statistical uncertainty which dominates all estimates.

The question “What is the probability to see a daily realized return below x%?” is interesting. We replied with our estimate for that probability, and we added confidence interval around that estimate. A much more common question is “What is the value we are expected to lose, with a probability of (no more than) 5%?”, this is essentially a Value at Risk (VaR) question. An old question, soon to be expired question, as the concept of expected shortfall takes hold (and it will!). Nonetheless, at the moment VaR measure dominates the financial risk management business. What is often overlooked is the level of confidence regarding the estimate. With this practical methodology you can get the confidence intervals to go with your reply. In fact, not only the confidence interval but the whole distribution of the estimate*. A point which will be demonstrated below.

We do exactly the same as we did before, but now, instead of fixing the value (2% in the previous example), we fix the probability (to 5%) and check the x-axis for the possible values.

### Confidence Interval for the 5% Value at Risk estimate

The bottom chart shows the histogram and and density estimate of the 5% VaR estimate.