Skip to content
Prev 4774 / 15274 Next

Forecasting GARCH

Cristian Gonzalez wrote:
Arun was correct, this has been covered before. I asked the question 
regarding fGarch, and Yohan answered. Unfortunately, I have not had time 
to complete working this out for fGarch following his excellent 
suggestion. The contents of our interchange are copied below:

   BGP> I've been continuing to examine the fGarch code, and I think
   BGP> that I can probably do most of what I want by fitting a model,
   BGP> overriding.series, and then calling .garchLLH although I've
   BGP> not yet confirmed that this is the case.
Yohan Chalabi wrote:
Hi Brian,

overriding .series is probably your best option. Note that .series and
other variables stored in the .fGArchEnv environment used to be global
variables. Moving those global variables to an environment was our best
solution to avoid problems with global variables without modifying to
much code.

library(fGarch)
fit <- garchFit(~garch(1,1), dem2gbp)
ls(all.names = TRUE, envir = fGarch:::.fGarchEnv)

you can use .getfGarchEnv and .getfGarchEnv to retrieve and
set new values in this environment. 

Note that .series is scaled by default in .garchFit(). If you override
.series$x, do not forget to change .series$scale because it will be used
in .garchLLH.

Calling .garchLLH with fGarchEnv = TRUE will update the variables
in .fGarchEnv.


As a side note, there is a handy update method for fGARCH object. You
can re-fit the model with new parameters, for example

update(fit, ~aparch(1,1))

HTH
Yohan

   BGP>
   BGP> I understand completely that I can predict by using something
   BGP> like rollapply or apply.fromstart to repeat garchFit and then
   BGP> predict.
   BGP>
   BGP> However, I think that much of the information in a garch
   BGP> model can be extracted without refitting if we simply want 
   BGP> to calculate the conditional variance without refitting the 
   BGP> model.  predict() would likely also be able to be applied 
   BGP> in this way. 
   BGP> Any confirmation on where to look in the code would be
   BGP> appreciated.  
   BGP> As always, any modified code I work up will be contributed back.


Regards,

- Brian