# [R] Value at Risk using a volatility model?

Stat Tistician statisticiangermany at gmail.com
Sun Apr 7 10:47:01 CEST 2013

```I already know this, I did a second post, where I mention this, but I
have still problems with the implementation, especially in case of

2013/4/7 Patrick Burns <pburns at pburns.seanet.com>:
> There is an example of using the t distribution
> for VaR in:
>
> http://www.portfolioprobe.com/2012/11/19/the-estimation-of-value-at-risk-and-expected-shortfall/
>
> The trick is to know what the variance of the
> distribution is for a given value of the degrees
> of freedom.
>
> Pat
>
>
>
> On 06/04/2013 10:54, Stat Tistician wrote:
>>
>> Hi,
>> I want to calculate the Value at Risk with using some distirbutions and a
>> volatility model.
>> losses (negative returns) of a company of approx. the last 10 years. So I
>> want to calculated the Value at Risk, this is nothing else than the
>> quantile. Since I have losses I consider the right tail of the
>> distribution.
>>
>> Consider a first simple example, I assume the returns to follow a normal
>> distribution with mean zero and a volatility, which is estimated for each
>> day with a volatility model. Let's use a simple volatility model: The
>> empirical standard deviation of the last 10 days. So I calculate the
>> standard deviation of the first ten days and this is my estimate for the
>> 11th day and so on, until the end of my data. So I assume for each day a
>> normal distribution with mean zero and a sigma estimated by the voaltility
>> mdoel. So I use this estimated sigma to calculate the quantile, which
>> gives
>> me the Value at Risk. The code would be:
>>
>> volatility<-0
>> quantile<-0
>> for(i in 11:length(dat)){
>> volatility[i]<-sd(dat[(i-10):(i-1)])
>> }
>>
>> for(i in 1:length(dat)){
>> quantile[i]<-qnorm(0.975,mean=0,sd=volatility[i])
>> }
>> # the first quantile value is the VaR for the 11th date
>>
>> #plot the volatility
>> plot(c(1:length(volatility)),volatility,type="l")
>>
>> lines(quantile,type="l",col="red")
>>
>>
>> So in this case I understand everything and I can implement this. But now
>> comes my problem: I want to use a t-distribution with paramters mu, nu and
>> beta or even a generalized hyperbolic distribution. So in this case, I
>> don't know how to plug in the estimates for sigma, since there is no sigma
>> in the paramters? How can I implement the volatility model and e.g. the
>> generalized hyperbolic distribution in this case to calculate the Value at
>> Risk?
>>
>> Thanks
>>
>>         [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
> --
> Patrick Burns
> pburns at pburns.seanet.com