[R-SIG-Finance] Forecasting GARCH
Brian G. Peterson
brian at braverock.com
Fri Aug 28 14:53:59 CEST 2009
Cristian Gonzalez wrote:
> I have a question regarding the implementation in R of the paper
> "Prediction in dynamic models with time-dependent conditional variance"
> by Baillie and Bollerslev, Journal of Econometrics 52 (1992) 91-113.
>
> The idea is to run GARCH in one time series and after that to use
> estimators in a new (several) more time series for prediction.
>
> Using R, available packages (fGarch, rGarch, etc.) do not have this
> routine. The predict function allows the forecast only of the previous
> time series; garchpred(estimation,n.ahead=5)
>
> MATLAB has this routine for a new time series using the garchpred
> function; garchpred(coef,newtimeseries,5)
>
> I am working only with R and I would like to continue working without
> using other programs. Do you know how I can to do it in R?
>
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
--
Brian G. Peterson
http://braverock.com/brian/
Ph: 773-459-4973
IM: bgpbraverock
More information about the R-SIG-Finance
mailing list