How to add new data to be predicted with fGarch?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

How to add new data to be predicted with fGarch?

bwater
## 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)

##QUESTION: How to add new data to be predicted?
help('predict-methods', pac=fGarch) ## I cannot find any example

newdata <- data.frame(x= -0.3)
newdata <- -0.3
predict(model, newdata = newdata, n.ahead=1)

Thanks      
_______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: How to add new data to be predicted with fGarch?

Michael Weylandt
I'm not sure what you're trying to do. What should the `newdata`
argument be used for here? (The shocks/innovations, external
regressors, etc.?)

On Tue, Nov 1, 2016 at 4:57 AM, Be Water <[hidden email]> wrote:

> ## 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)
>
> ##QUESTION: How to add new data to be predicted?
> help('predict-methods', pac=fGarch) ## I cannot find any example
>
> newdata <- data.frame(x= -0.3)
> newdata <- -0.3
> predict(model, newdata = newdata, n.ahead=1)
>
> Thanks
> _______________________________________________
> [hidden email] 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.

_______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: How to add new data to be predicted with fGarch?

bwater
Well, I just want to predict mean and variance for the next period  based on the fitted model parameters.
Could be I don't understand how GARCH models work.
Thanks
     
_______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: How to add new data to be predicted with fGarch?

Michael Weylandt
The fGARCH predict() method will do that with the n.ahead argument; no
need to supply newdata. Try running

> example('predict-methods', package="fGARCH")

to see an example (with plots!).

The standard ARMA and GARCH models don't need external data to make
predictions: their predictions are made by integrating over the shocks
(innovations), the distribution of which is specified by the fitted
model.

I think ugarchsim from the rugarch package sometimes needs external
regressors if you fit an ARMA-X mean model [ARMA with external
regressors], but that's because they have a new (non-shock) term that
you don't want to integrate over.

(More precisely, you probably do want to integrate over the predictive
distribution of your external regressors, but you don't want your
GARCH model doing that. Instead, you want something with a proper
model to give a predictive distribution over your external regressors
and then do use a conditioning argument to get your predictive
distribution over both the regressors and the shocks).

Cheers,
Michael



On Wed, Nov 2, 2016 at 3:21 AM, Be Water <[hidden email]> wrote:
> Well, I just want to predict mean and variance for the next period  based on the fitted model parameters.
> Could be I don't understand how GARCH models work.
> Thanks
>

_______________________________________________
[hidden email] 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.