# VaR estimate with Monte Carlo simlation

i want to verify the theoretical VaR 99% for the following Random Variable:

\begin{align*} X=\epsilon + \nu, \end{align*} $\epsilon \sim \mathcal{N}(0,1)$, \begin{align*} \nu= \begin{cases}\begin{array}{ll}0 & \text{with prob.}\enspace 0.991 \\ -10& \text{with prob.}\enspace 0.009 \end{array} \end{cases}. \end{align*} So i poved that the theoretical 99% VaR is 3.088. Then i ran some monte carlo simulations in excel( $\epsilon$ as a standard normal and $\nu$ as a bernoulli and so on and used the quantile function). Now i went up to 20000 simulations in excel, but the VaR estimate was very sensible to different simulations , varying from 2-8, but i already saw that most of the estimates were close to the theoretical one. I coded the same monte carlo simulation in MATLAB and had to increase the simulation amount to 500000 in order to get a very stable and precise estimate.

Now i am interested in the reason, 500000 seems very high to me, i have never experienced a situation were it was necessary to run more than 10000 simlations. Is it because X is a mixture of a continous and discrete Random Variable? Thanks.

To answer you question "is it because X is a mixture of a continous and discrete Random Variable": the answer is no. The mean reasons are (1) the sample size (which is limited / countable) (2) the fact that you're trying to get the tail value and (3) the shape of the KDE (distribution).The theoretical value of 3.088 will be emprirically calculated if and only if you have sufficiently large sample size.

(@Jack JackGuRae says It is about simulations are not actually random which isn't exactly true, as the pseudo-random number generators use algorithms that do ensure that big enough samples are properly distributed, i.e. simulating 1000 dice rolls will give you p=1/6 for each side to let's say 3 d.p.)

(@msitt is spot on with the tail remark)

As you've mentioned before, it is true that for some of the simulations, you needed considerably smaller sample size, but in this case you are trying to sample from a highly left-skewed distribution. Consider following code to plot the KDE:

sims   <- 10e6
errors <- rnorm(sims)
v      <- ifelse(runif(sims) <= 0.009, -10.0, 0.00)
x      <- v + errors
plot(density(x), col = 2, lwd = 2)
abline(v=unname(quantile(x,probs=c(0.01))))


where the vertical line is the 1% quantile. Chances of having a small sample with this particular value for 1% quantile are very small indeed.

Further example where we parametrize the quantile calculation based on the number if simulations and the Bernoulli mode and plot the quantiles based on the number of sims:

set.seed (3134)

quant <- function(sims, tailmode)
{
errors <- rnorm(sims)
v      <- ifelse(runif(sims) <= 0.009, tailmode, 0.00)
x      <- v + errors
return(unname(quantile(x,probs=c(0.01))))
}

sims <- seq(100, 20000, len=20)

par(mfrow=c(2,2))
plot(sims, Vectorize(quant, c("sims","tailmode"))(sims,-10), col = 2, pch=16, ylim = c(-9, -1), ylab = "", xlab="", main="-10")
plot(sims, Vectorize(quant, c("sims","tailmode"))(sims,-5 ), col = 2, pch=16, ylim = c(-9, -1), ylab = "", xlab="", main="-5")
plot(sims, Vectorize(quant, c("sims","tailmode"))(sims,-1 ), col = 2, pch=16, ylim = c(-9, -1), ylab = "", xlab="", main="-1")
plot(sims, Vectorize(quant, c("sims","tailmode"))(sims, 0 ), col = 2, pch=16, ylim = c(-9, -1), ylab = "", xlab="", main="0")


gives

which clearly shows that the less skewed your distribution is (i.e. the Bernoulli mode increasing), the faster the calculated 1% quantile converges to its model value.

The reason you need to run so many simulations is because you are trying to estimate a tail property which has a very small chance of happening.

Let's do a quick back of the envelope calculation: The 99% VaR will occur 1% of the time. With the way your binomial variable is set up let's assume only $\nu=-10$ contributes to the VaR. This happens with probability 0.009. If you run 1% * 0.009 = 11,111 simulations, you will only expect to get 1 tail event. With 500,000 simulations, you get 45 tail events, which is pretty much exactly what I would expect to get convergence.

It is not about a mixture of a continuous and discrete Random Variable.

It is about simulations are not actually random, even using 50,000 trials. That's why you get varying results. (It exhibits high discrepancy)

Simulating random variable from pseudo-random function generator, very large simulations is needed to ensure convergence.

Try using quasi-Monte Carlo Method. It uses quasi-random sequences. Plus, it is readily available in MATLAB. look here

Actually, with QMC, you may only need a few thousands simulations.

• Thanks. But when i used the random generator for other monte carlo.simulations for verifying VaR and ES, e.g. a portfolio of two correlated normals, i only needed 5000 simulations to get vey good estimation without much fluctuations, so there must be some difference.. – Mh Aztec Apr 5 '17 at 12:48