Skip to content

Getting different days ahead forecast apart from of 1-day ahead using rugarch

2 messages · Papa Senyo, Alexios Ghalanos

#
Once again Emmanuel you are not reading the documentation.

library(rugarch)
data(sp500ret)
spec = ugarchspec(variance.model = list(model = "eGARCH"), 
distribution.model = "norm")
rollD = ugarchroll(spec, data = sp500ret, n.ahead = 3, forecast.length = 
500,
refit.every = 25, refit.window = "recursive", calculate.VaR = TRUE, 
VaR.alpha = c(0.01, 0.05))

class(rollD)
"uGARCHroll"
attr(,"package")
[1] "rugarch"

?'uGARCHroll-class'
Where it is clearly stated what each method on the returned object does, 
and how to extract exactly what you need. Every class and method
in rugarch is documented.

The extractor method (as.data.frame) clearly states how you can pass the 
'n.ahead' as an option to extract that particular series, and the 
'which' option indicates what you want to extract from the object:

e.g.

n2d = as.data.frame(rollD, which = "density",n.ahead = 2)
head(n2d,3)
          fdate           fmu      fsigma         fskew fshape
roll-1   2007-02-06  2.421884e-04 0.005658718     0      0
roll-2   2007-02-07  2.331122e-04 0.005582674     0      0
roll-3   2007-02-08  2.364455e-04 0.005379911     0      0

head(n3d,3)
n3d = as.data.frame(rollD, which = "density",n.ahead = 3)

          fdate           fmu      fsigma        fskew fshape
roll-1   2007-02-07  2.366104e-04 0.005728963     0      0
roll-2   2007-02-08  2.351039e-04 0.005653518     0      0
roll-3   2007-02-09  2.356572e-04 0.005452251     0      0

The returned density is the forecasted values produced by the model 
(conditional mean, sigma, skew[constant] and shape[constant]). It even 
returns the dates for you so that you can clearly see the horizon 
involved (assuming the original data you passed had dates).

Given the forecasted density parameters you can then calculate any 
measure from the distribution e.g.
qdist("norm",p=0.05,mu = n2d[1,"fmu"],sigma = n2d[1,"fsigma"])
or simpler still (in this case):
n2d[1,"fmu"]+ n2d[1,"fsigma"]*qnorm(0.05)

Finally keep in mind that when n.ahead>1, this represents the 
unconditional forecast.

Regards,
Alexios
On 21/02/2012 15:24, Papa Senyo wrote: