[R-SIG-Finance] Rugarch for EWMA/VaR

ThomasF frickerthomas at googlemail.com
Thu May 3 22:23:58 CEST 2012


Dear R-Users, dear Alexios,

I am trying to use rugarch to forecast volatiliy and do VaR-backtests using
the Exponentially weighted moving average.
To achieve this I used the iGarch, set omega to 0 and either estimate or fix
alpha1 and beta1. Example code is provided at the end of my post.

Some issues came up which I'd be glad to solve with your help:

1) Whenever i try to fit alpha1 and beta1, I always get 0.5 as result. I
tried this for different underlyings and time horizons. Any idea what the
reason could be?

2) I also get an error (I translated the error message to english) after the 
ARCH LM Test output:

ARCH LM Tests
------------------------------------
             Statistic DoF P-Value
ARCH Lag[2]      4.653   2 0.09765
ARCH Lag[5]      7.991   5 0.15672
ARCH Lag[10]    12.082  10 0.27959
Error in names(ans) = c("10%", "5%", "1%") : 
  Attribut 'names' [3] must have same length as the vector [0]

Is there something wrong with my code or the way i put the data into the
model? The other part of the outputs seems legit.

3) when I tried to do the same calculations with fixed alpha i get the
following error when i try to filter the model:

1: In doTryCatch(return(expr), name, parentenv, handler) :
  passing an object of type 'NULL' to .C (arg 8) is deprecated
2: In doTryCatch(return(expr), name, parentenv, handler) :
  passing an object of type 'NULL' to .C (arg 9) is deprecated

The ugarchfilter output seems reasonable again.

4)  I am not able to generate a rolling forecast and VaR Output when i fixed
alpha1. Could you please give me a hint on how to do this with filtered
data?

5) Does any of those issues arise of the use of the data as "zoo" object?


Thanks in advance for your effort to help me 

Sincerely

Thomas


-----------------Code----------


################
###Download Data & Compute Returns
################

library ("tseries")

#adjusted close price of sp500
sp500price=get.hist.quote(instrument="^gspc", start="2006-01-01",
end="2011-12-31", quote="AdjClose")

# returns
sp500returns=diff(log(sp500price))


library("rugarch")



##############
### Use iGarch for EWMA - fitted alpha and beta
##############


### Model spec
spec1= ugarchspec (variance.model = list(model = "iGARCH", garchOrder = c(1,
1)), mean.model=list(armaOrder=c(0,0),include.mean=FALSE),
distribution.model = "norm", fixed.pars = list(omega=0))

###Fit Model
fit1= ugarchfit(spec=spec1, data=sp500returns, out.sample=0, solver="solnp",
solver.control=list(trace=0))
show(fit1)

#### rolling forecast und VaR
roll1=ugarchroll(spec=spec1, data=sp500returns, n.ahead=1,
forecast.length=500, refit.every=25, refit.window="recursive",
solver="solnp", solver.control=list(tol=1e-05, delta=1e-06, trace=0),
calculate.VaR=TRUE, VaR.alpha=c(0.01, 0.05))

report(roll1, type="VaR", n.ahead=1, VaR.alpha=0.01, conf.level=0.95)
report(roll1, type="fpm")
plot(roll1, which="all")




##############
### Use iGarch for EWMA - fixed alpha and beta with lambda=0.94
##############


### Model spec
spec2= ugarchspec (variance.model = list(model = "iGARCH", garchOrder = c(1,
1)), mean.model=list(armaOrder=c(0,0),include.mean=FALSE),
distribution.model = "norm",  fixed.pars = list(omega=0, alpha1=0.06))

###Fit Model???

fit2= ugarchfit(spec=spec2, data=sp500returns, out.sample=0, solver="solnp",
solver.control=list(trace=0))
show(fit2)

### filter model
filt2= ugarchfilter(spec=spec2, data=sp500returns)
show(filt2)

#### rolling forecast und VaR

roll2=ugarchroll(spec=spec2, data=sp500returns, n.ahead=1,
forecast.length=500,   calculate.VaR=TRUE, VaR.alpha=c(0.01, 0.05))

report(roll2, type="VaR", n.ahead=1, VaR.alpha=0.01, conf.level=0.95)

report(roll2, type="fpm")
plot(roll2, which="all")

--
View this message in context: http://r.789695.n4.nabble.com/Rugarch-for-EWMA-VaR-tp4607011.html
Sent from the Rmetrics mailing list archive at Nabble.com.



More information about the R-SIG-Finance mailing list