[R] how to forecast the GARCH volatility?

Spencer Graves spencer.graves at pdf.com
Fri Nov 24 04:10:04 CET 2006


      <comments in line>

Rick Xu wrote:
> Dear All,
>
> I have loaded package(tseries), but when I run
> predict.garch(...) R tells me could not find function
> "predict.garch", however ?predict.garch shows me
>   
      The secret is methods dispatch. 

 > predict
function (object, ...)
UseMethod("predict")
<environment: namespace:stats>
 
      The 'predict' function calls 'UseMethod', which in turn appends 
class(object) to "predict", and looks for a function by that name.  If 
it doesn't find one, it looks for 'predict.default'.  If it doesn't find 
that, it gives an error message: 

 > predict(1:4)
Error in predict(1:4) : no applicable method for "predict"

      To find the methods available for 'predict', call 'methods': 

 > methods("predict")
 [1] predict.ar*                predict.Arima*           
 [3] predict.arima0*            predict.garch*           
 <snip> 
   Non-visible functions are asterisked

      To get a "Non-visible function", use 'getAnywhere': 

 > getAnywhere("predict.garch")
> something. I am confused about this. How can I
> forecast garch volatility?
>
> I have tried:
> predict(...,n.ahead=...),give me fitted value
>   
      What did you not like about this?      
> predict(...,n),give me NA,NA
>
>   
      How many arguments do you have in "..."?  The help file 
'?predict.garch' says 'Usage': 

     predict(object, newdata, genuine = FALSE, ...)

      R matches names to arguments by position or by name.  With names, 
R allows partial matching except for function arguments that appear 
after the special "..." argument.  The interpretation of the incomplete 
example you gave depends on how many arguments you have before "n".  
'predict(garch.object, n)' would interpret 'n' as 'newdata'.  If 'n' 
doesn't look like 'newdata', it might explain why you got NA,NA.  These 
aspects of R are probably described many places, but one I just checked 
was sec. 3.1 in Venables and Ripley (2000) S Programming (Springer). 

      Hope this helps. 
      Spencer Graves
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list