# Simulating financial strategies with given value-at-risk (VaR) and mean

I would like to generate thousands of distributions with respect to: VaR@5%=-7% and Median=0%.

A first idea:

1. Choose a family, say the Gaussian one.
2. Estimate its parameters. This is straightforward for the Gaussian but let's write the general algorithm (see mpiktas' answer on Estimating a distribution based on three percentiles):

library(nleqslv)
VaR_Threshold <- c(0.05,0.5)
VaR_Value <- c(-0.07,0)

ufn <- function(x,q) q-pnorm(VaR_Value, x[1],x[2])
usol <- nleqslv(c(0,1), ufn,q=VaR_Threshold)
usol$x [1] -1.262016e-11 4.255698e-02 (estimated parameters) plot(x<-seq(-1,1,by=0.01),dnorm(x,usol$x[1],usol$x[2]),type="l",col=2) points(p<-VaR_Value,dnorm(p,usol$x[1],usol$x[2])) pnorm(VaR_Value,usol$x[1],usol$x[2]) [1] 0.05 0.50 (check)  So this is for the Gaussian family: one unique solution. My question: is there a parametric family flexible enough to generate thousands of distributions with a given VaR and median? I tried with the stable distributions (4 parameters : 2 manually fixed + 2 optimized), in vain, probably because I don't master it... - add comment ## 1 Answer Almost any family with more than two parameters will do: you just have to fix all the parameters but two. Here is an example with stable distributions. library(fBasics) VaR_Threshold <- c( 0.05, 0.5) VaR_Value <- c(-0.07, 0) alpha <- 1.2 # in (0,2] beta <- 0 # The third argument, gamma, should be positive. f <- function(x) { r <- sum(( VaR_Threshold - pstable(VaR_Value, alpha, beta, abs(x[1]), x[2], pm=2) )^2) cat(r, "\n") # for debugging r } p <- optim(c(1,0),f)$par
pstable(VaR_Value, alpha, beta, abs(p[1]), p[2], pm=2)

-
abs() for abs(x[1]) changes everything! Thank you. –  user9637 Mar 7 '12 at 9:36