# [R] Fitting distributions to financial data using volatility model to estimate VaR

Stat Tistician statisticiangermany at gmail.com
Sun Apr 7 09:41:57 CEST 2013

```Ok,
I try it again with plain text, with a simple R code example and just
sending it to the r list and you move it to sig finance if it is
necessary.

I try to be as detailed as possible.

I want to fit a distribution to my financial data using a volatility
model to estimate the VaR. So in case of a normal distribution, this
would be very easy, I assume the returns to follow a normal
distribution and calculate a volatility forecast for each day, so I
have sigma_1,sigma_2,...,sigma_n,. I can calculate the VaR via (mu
constant, z_alpha quantile of standard normal):
VaR_(alpha,t)=mu+sigma_t * z_alpha. This is in case, I have losses, so
I look at the right tail. So for each day I have a normal density with
a constant mu but a different sigma corrensponding to the volatility
model. Let's assume a very simple volatility model, e.g. (empirical)
standard deviation of the last 10 days and the mu is set to zero. The
R code could look like (data):

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")

Now, I want to change the volatility model to a more advanced model
(EWMA, ARCH, GARCH) and the distribution to a more sophisticated
distribution (student, generalized hyperbolic distribution). My main
question is now, how can I combine the volatility model and the
distribution, since in case e.g. of a Student's-t distribution with
parameters mu (location), v (df), beta (scale) I cannot just plug the
sigma in, because the distribution has no sigma?

One solution I already know is, that I take the variance formula of
the corresponding distribution - in case of a Student's-t distribution
this would be sigma=beta v/(v-2). I have an estimate for sigma. So for
each day I do the ML estimation with a modified log-likelihood where I
insert for the scale parameter: beta=sigma * (v-2)/v and do the
estimation.

First of all, is this correct?

I looked at several papers, but I did not understand, how they did
this? No matter what volatility model they use, I cannot understand
the connection of distribution and volatility model. For example,
consider this paper:
http://www.math.chalmers.se/~palbin/mattiasviktor.pdf

On page 50 they are showing the hyperbolical distribution with
different volatility models, how did they do this?

Also, I do not understand table 6.2 on page 49: If they have estimated
several distributions over the time, they have lots of estimates, but
they just show one distribution? I mean, where does it come from? The
3d picture clearly differnt distributions over time, so they have
estimated the distribution after 5 days (page 48), but in the table is
just one specific distribution with specific parameters? And they give
the volatility models in the rows?

A second famous paper is the Technial Document by JPMorgan:
RiskMetrics Technical Document - Fourth Edition 1996, December:

Especially page 238 is interesting: "According to this model, returns
are generated as follows"

r_t=sigma_t xi_t

sigma^2_t is calculated by EWMA

xi is distributed according to the generalized error distribution. So
they do not assume the returns to follow a certain distribution, but
they assume the returns condition on the volatility to follow a
certain distribution, right?

Now my question is, how can one calculate the VaR in this case? On
page 242 they give a short summary, describing the steps. The third
step in the most intersting: "Third, we use [...] volatility estimated
and the [...] probability distributions ([...] generalized error
distribution) evaluated at the parameter estimates to construct VaR
forecasts at the 1st and the 99th percentile."

My question is now, how do they do it?

They describe their fitting steps in the steps before, but I am not
getting the following point:

Do they fit the distribution to the original return series, calculate
the volatility (σt) and then just calculate the VaR with
VaR_t=sigma_t*q_alpha where q_alpha is the quantile of the fitted
distribution

or

do they fit the distribution to the standardized returns
(xi_t=r_t/sigma_t), calculate the volatility and then just calucate
the VaR with VaR_t=sigma_t*q_alpha where q_alpha is now the quantile
of the fitted distribution which was fitted using the standardized
residuals?

Another question is: Did they set the mean of the return to zero?

My main point is, how to fit a sophisticated distribution to financial
data using a volatility forecast for each day, which was generated by
EWMA, ARCH or GARCH and how to calculate the VaR for each day over a
time horizon and how to implement this. The paper is doing this, but I
am simply not getting it. I worked on this for days now and I am
really stuck here.

And one other question: If I am doing the way with the modified
log-likelihood: This is really challenging in case of a hyperbolic
distribution, since the variance is not calculated easily anymore? See
wikipedia.

Thanks a lot for your help.

```