[R] Predict ARMA GARCH model with new data

David Winsemius dwinsemius at comcast.net
Sun Oct 30 19:43:26 CET 2016


> On Oct 28, 2016, at 7:00 AM, Be Water <bwater at outlook.com> wrote:
> 
> How to add newdata to be predicted in an ARMA GARCH model with the fGARCH package?
> 
> ## R version 3.3.1 (2016-06-21)
> ## Platform: x86_64-w64-mingw32/x64 (64-bit)
> ## Running under: Windows >= 8 x64 (build 9200)
> 
> library(fGarch)
> 
> ## Data simulation
> set.seed(345)
> ar.sim <- arima.sim(model=list(ar=c(.9,-.2)), n=1000) 
> tail(ar.sim) 
> plot(ar.sim)
> 
> ## Model fit 
> model = garchFit( ~ arma(1, 2) + garch(1, 1), Data=ar.sim) 
> print(model)
> help(garchFit,package="fGarch")
> 
> ##QUESTION 1: How to add newdata to be predicted?
> newdata <- data.frame(x= -0.3)
> newdata <- -0.3
> predict(model, newdata = newdata, n.ahead=1)[1,1]
> 
> ##QUESTION 2: If this is the correct way, why do I get the same result with different newdata?
> predict(model, newdata= -1.035, n.ahead=1)
> predict(model, newdata= 0.124, n.ahead=1)
> help(predict, package="fGarch")
> 

Try this:

help('predict-methods', pac=fGarch)

Generally there is a fallback to the original data when the argument to `newdata` is malformed. I don't see any dependence on a varaible named either "x"  in the construction of `model`, nor do I even see an argument named `newdata` in the predict method for fGarch. Look at the examples on that help page. I think you are incorrectly generalizing expectations about model objects to this package.
> 
> 	[[alternative HTML version deleted]]
> 
And learn to use plain text.

-- 
David.

> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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