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?

  • $\begingroup$ Maybe this is very straightforward, can you give a step by step description of your process? $\endgroup$
    – Bob Jansen
    Feb 23 '14 at 19:58
  • $\begingroup$ Thank you for editing my post, what kind of details do you need ? $\endgroup$
    – Swing
    Feb 23 '14 at 20:01
  • $\begingroup$ I'd like some pseudocode of your MC-loop, e.g. step 1 do fun N times, step 2 calculate mean VaR. $\endgroup$
    – Bob Jansen
    Feb 23 '14 at 20:06
  • $\begingroup$ 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. $\endgroup$ 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))

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)

plot(M, VaRstdevs)


  • $\begingroup$ 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 ? $\endgroup$ Feb 25 '14 at 10:32
  • 1
    $\begingroup$ 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. $\endgroup$
    – user25064
    Feb 25 '14 at 13:46
  • $\begingroup$ 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 ;) $\endgroup$ 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.

  • $\begingroup$ 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 $\endgroup$ Feb 26 '14 at 19:10
  • $\begingroup$ 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. $\endgroup$ Feb 26 '14 at 19:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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