# How to Calculate a Monte Calo VaR estimation error

I'm performing a Monte Carlo to calculate value at risk (with a 3 dimension risk factor) Now, I would like to calculate the error of the estimation of the VaR with respect to the number of simulations (drawing a graph of estimation error with respect the number of simulations)

What is the formula for the error on the VaR?

• Maybe this is very straightforward, can you give a step by step description of your process? Feb 23 '14 at 19:58
• Thank you for editing my post, what kind of details do you need ? Feb 23 '14 at 20:01
• I'd like some pseudocode of your MC-loop, e.g. step 1 do fun N times, step 2 calculate mean VaR. Feb 23 '14 at 20:06
• Does an explicit approach for measuring VaR error in MC exist ? To my knowledge one mainly approximates the density function and then takes the quantile. So the error in the VaR would be directly linked to the error in the densitiy function - we must be able to evaluate how stable the mass in the tail is in the simulated density. Feb 24 '14 at 8:29

1. Do $N$ MC simulations of $M$ samples, calculating your estimate of VaR for each one $\{\widehat{VaR}_i\}_{i=1}^N$ and you now have an IID sample!
2. Take the sample (or unbiased) standard deviation for your estimate of VaR (this is probably what you mean by error) $SD(\widehat{VaR})=\sqrt{\frac{1}{N-1} \sum_{i=1}^N (\widehat{VaR}_i - \overline{VaR})^2}$ and of course $\overline{VaR}=\frac{1}{N}\sum_{i=1}^N\widehat{VaR}_i$
3. Increase $M$ to get your plot, plot $M$ against $SD(\widehat{VaR})$ for each value $M \in [\underline{M}, \overline{M}]$ you might want to use something like $\underline{M}=50$ and $\overline{M}=1000$ depending on the application.

Edit There probably are more tractable things to do but by the fact that OP is already in Monte-Carlo world, this is the Monte-Carlo answer.

Edit 2

N = 1000
M = seq(50, 1000, by=10)

VaRstdevs = rep(0, length(M))

i=1
for(nscenarios in M) {
varsample = rep(0, N)
for(sim in 1:N) {
samp = rnorm(nscenarios, 0, 0.3/sqrt(252)) # 30% annualized sd MC sim
varsample[sim] = -1.0*quantile(samp, 0.05) # VaR 95%
}
VaRstdevs[i] = sd(varsample)
i=i+1
}

plot(M, VaRstdevs)

• By "Do $N$ MC simulations of $M$ samples" you mean: Calculate each VaR with $N$ monte carlo scenarios. Repeat this calculation $M$ times to get a distribution of the $VaR$. Correct ? Feb 25 '14 at 10:32
• Actually just the opposite, I mean to calculate Monte Carlo VaR over $M$ scenarios $N$ times. Thus for each full simulation there is a value for VaR which becomes a sample of the estimator. Hope this makes sense. Edited to include some simple code. Feb 25 '14 at 13:46
• okey - I see so you sample N times a VaR that is the result of M monte Carlo paths. Increasing M leads to les deviation. Thnaks for the graph - unfortunately I can upvote it only once ;) Feb 25 '14 at 13:55

Let's say your return realization for path $i$ is $r_i = \beta\cdot f_i$, where $f_i=(f_{1i}, f_{2i}, f_{3i})$ - factors realizations, and $\beta$ - factor coefficients. So, your VaR is $VaR=percentile(r_i,\alpha)$, where $\alpha$ - confidence.

The simplest Monte Carlo stopping criterion is to keep adding paths $i$ and computing VaR on the growing sample until VaR "stops changing". For instance you can keep track of the MAX change in VaR during the last N paths, and wait until it becomes smaller than the required tolerance.

• the drawback of your approach vs. user25064's analysis is that when you implement it you will have no idea how long you simulation might run. If you are on tight deadline and you VaR turns out to be missbehaved you could end up waiting a while depending on the model Feb 26 '14 at 19:10
• we study the convergence of the Monte Carlo before deploying it in production. once we figure out how many paths is required, say N=1,000, we configure the code to run always N paths, and report the convergence criterion at the end of the execution, throw a warning if it's not reached. we're not going to leave the infinite loop. another approach is to set the max number of paths, and stop either whenever the convergence/stopping condition is reached, OR when the max number of paths reached. Feb 26 '14 at 19:48