1
$\begingroup$

I am currently trying to figure out how to estimate the value at risk using the rugarch package in R. I've come to a result, but it seems a bit excessive. Here's my code:

install.packages("PerformanceAnalytics")
install.packages("fGarch")
install.packages("rugarch")
library(fGarch)
library(PerformanceAnalytics)
library(rugarch)

#Daten runterladen
db<- get.hist.quote(instrument = "DB",  start = "2005-11-21",
                  quote = "AdjClose")
sys<- get.hist.quote(instrument = "^STOXX50E",  start = "2005-11-21",
                  quote = "AdjClose")
#Returns
retdb<-diff(log(db))
retsys<-diff(log(sys))
#GARCH-Modell spezifizieren
spec2 = ugarchspec(variance.model = list(model = "sGARCH", garchOrder = c(1,     1), 
                                     submodel = NULL, 
                                     external.regressors = NULL, 
                                     variance.targeting = FALSE),
               mean.model=list(armaOrder=c(1,0)),
               distribution.model="sstd"
               )
#GARCH-Modell fitten
fit<-ugarchfit(spec=spec2,
      data=retdb)
fit2<-ugarchfit(spec=spec2,
           data=retsys)

#var berechnen
var1<-quantile(fit,0.99)
var1sys<-quantile(fit2,0.99)
#plot var
plot(var1)
lines(var1sys,col="red")

And this the image I'm getting (red-->Eurostoxx VaR, black--> DB VaR):

VaR Deutsche Bank vs. VaR Euro Stoxx

And, to be honest, I'm lacking the experience if this reasonable or not...

Thanks in advance, Richard

$\endgroup$
3
$\begingroup$

1) You are computing the "actual" VaR, in the sense that you are not forecasting it to see if your VaR model is able to estimate it, but you are just computing the VaR that "has taken place". To obtain a volatility forecast (either in-sample or out-of-sample) you can use the "ugarchforecast" function.

2) I think you are estimating the VaR on the wrong side of the distribution: you take the 0.99 quantile instead of the 0.01 one.

3) A more meaningful plot is the one with your returns series together with the respective VaRs: there, you can see with your eyes how it behaves.

4) Count the number of failures of your VaR (number of times the return process exceeds you VaR) and divide it by the number of observations, to get the Failure Rate: it should be near 0.01 (more generally, near the desired coverage level, such as your 0.01; other common levels are 0.005, 0.05 or 0.1)

5) There are a lot of other tests to check if your model is good in VaR estimation: Dynamic Quantile Test, Conditional and Unconditional coverage tests; other measures are various Loss Functions, (for example, the firm Loss Function), to compare various models performances. In This working paper you can find a comparison between various techniques to compute VaR (GARCH too) and numerous tests and comparison methods.

$\endgroup$

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.