[R-SIG-Finance] Getting different days ahead forecast apart from of 1-day ahead using rugarch

alexios ghalanos alexios at 4dscape.com
Wed Feb 22 16:19:45 CET 2012


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:
> Dear All,
> Please, how can we get different days ahead forecast using rugarch package.
> I used the commands below to get the 1.day ahead forecast but change the n.ahead forecast in the code below has no effect as it still report one day ahead forecast. Hope to hear from you all. Thanks papa
> spece = ugarchspec(variance.model = list(model = "eGARCH"), distribution.model = "norm")
>   rollD = ugarchroll(spece, data = as.numeric(E.rtdm), n.ahead = 1, forecast.length = 500,
> +  refit.every = 25, refit.window = "recursive", parallel = TRUE,
> +  parallel.control = list(pkg = "snowfall", cores = 10), solver = "solnp",
> +  solver.control = list(tol = 1e-05, delta = 1e-06, trace = 0),
> +  calculate.VaR = TRUE, VaR.alpha = c(0.01, 0.05))
>
>
>   report(rollD, type="fpm")
>
> GARCH Roll Mean Forecast Performance Measures
> ---------------------------------------------
> Model : eGARCH
> no.refits : 20
> n.ahead   : 1
> n.rolls   : 500
>
>      n.ahead.1
>
> 	[[alternative HTML version deleted]]
>
>
>
>
> _______________________________________________
> R-SIG-Finance at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions should go.



More information about the R-SIG-Finance mailing list