Expost prediction for ARMA or GARCH

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

Expost prediction for ARMA or GARCH

troger19

Dear researchers

I would like to ask, if there is a way how to make in R (fGarch,tseries,..) EXPOST prediction(quasi future). Correct me, if I am wrong, but the command predict(x,n.ahead) makes EXANTE predictions(true future prediction) only. In contrast with Eviews, where forecast function produces expost results. Another idea, is to divide the testing set into training and validation sets, estimate for example ARMA coefficients for training set and use them with validations set to produce expost predictions. In pseudocode it looks like this:

testing_set (1:100)
training_set(1:90)
validation_set(91:100)



arma_coef<-fit(training_set,~arma(1,1))

expost_prediction<- arma_coef * validation_set

Is this a way how to produce EXPOST predictions, or my approach is completely wrong? I beleive, there is much easier way how to do it in R, but I just cant find the satysfying solution by myself. Thank you any help.

Sincerely Jan

_______________________________________________
[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: Expost prediction for ARMA or GARCH

Arun.stat
Perhaps following thread will be of your benefit:

http://r.789695.n4.nabble.com/Forecasting-GARCH-td930240.html#a930243

Thanks,

Reply | Threaded
Open this post in threaded view
|

Re: Expost prediction for ARMA or GARCH

braverock
In reply to this post by troger19
On Sun, 19 Dec 2010 01:34:25 +0100, <[hidden email]> wrote:
> Dear researchers
>
> I would like to ask, if there is a way how to make in R
> (fGarch,tseries,..) EXPOST prediction(quasi future). Correct me, if I am
> wrong, but the command predict(x,n.ahead) makes EXANTE predictions(true
> future prediction) only. In contrast with Eviews, where forecast
function

> produces expost results. Another idea, is to divide the testing set into
> training and validation sets, estimate for example ARMA coefficients for
> training set and use them with validations set to produce expost
> predictions. In pseudocode it looks like this:
>
> testing_set (1:100)
> training_set(1:90)
> validation_set(91:100)
>
> arma_coef<-fit(training_set,~arma(1,1))
>
> expost_prediction<- arma_coef * validation_set
>
> Is this a way how to produce EXPOST predictions, or my approach is
> completely wrong? I beleive, there is much easier way how to do it in R,
> but I just cant find the satysfying solution by myself. Thank you any
help.

I believe what you are asking is:

"How do I use a pre-set (trained) set of ARMA or GARCH coefficients on a
new data set without changing the model?"

This is not ex post 'prediction'.  The model fitting is ex post.  predict
is *always* using the current model to predict future movements (ex ante)
on observations in the time series that come in after the model is fit.

In fGarch, at least, there is no way to do this.  See a list post from me
approximately one+ year ago asking about predict and pre-fitted values for
fGarch, and Yohan's helpful reply on the modifications that would be
necessary to fGarch.

In any GARCH model, the conditional volatility may be (and usually is)
displayed on the prior data.

for arma(), I don't know the answer, but I suspect it will involve some
coding on your part.

Regards,

  - Brian

--
Brian G. Peterson
http://braverock.com/brian/
Ph: 773-459-4973
IM: bgpbraverock

_______________________________________________
[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: Expost prediction for ARMA or GARCH

braverock
In reply to this post by Arun.stat
On Sun, 19 Dec 2010 04:15:28 -0800 (PST), "Arun.stat"
<[hidden email]> wrote:
> Perhaps following thread will be of your benefit:
>
> http://r.789695.n4.nabble.com/Forecasting-GARCH-td930240.html#a930243

Arun,

This is precisely the thread I was talking about in my reply.  Thank You.

I did not check after that thread to see if Alexios added the
functionality to the rgarch package or not, but it looks like he did, from
this quote on the rgarch website:

"Forecast (from spec or fit), Simulation (from fit or spec)"
http://rgarch.r-forge.r-project.org/

To the OP's question, this would be forcast from specification.

Regards,

  - Brian

--
Brian G. Peterson
http://braverock.com/brian/
Ph: 773-459-4973
IM: bgpbraverock

_______________________________________________
[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: Expost prediction for ARMA or GARCH

troger19

Dear Brian, Arun and Alex

Thank you all  for helping, I am going to check all your suggestions. At the end, I would like to provide few lines of code, just in case, if someone can utilize it in future:

library(quantmod)
library(tseries)
getSymbols("XPT/USD",src="oanda")

# 2 time series,
x<-XPTUSD
y<-Lag(x,k=1)

length(x)
> 500

## fitting arma model on first 450 observations,
fit <- arma(x[1:450], order = c(1, 0))
fitted_model<-fit$fitted.values


## lets calculate it all, on a full length, 1:450 are same, 451:500 would be expost
for (i in 1:500)
fitted_manual[i]<-fit$coef[1]+(fit$coef[2]*y[i])

## for comparision, I show, that values fitted by model (fitted_model) are exactly the same as those, that were calculated with coefficients and lagged time series (fitted_manual), what its ##not a suprise :)))

comparision<-cbind(fitted_mode,fitted_manual[1:450]);comparision   ## same

## so I thing, the last 50 values could be considered as expost predictions, because arma coeficients were estimated only on first 450 observations
comparision_expost<-cbind(x[451:500],fitted_manual[451:500]);comparision_expost

plot(comparision_expost[,1],type="l")


Best regards

_______________________________________________
[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: Expost prediction for ARMA or GARCH

Mark Knecht
On Mon, Dec 20, 2010 at 3:58 AM,  <[hidden email]> wrote:

>
> Dear Brian, Arun and Alex
>
> Thank you all  for helping, I am going to check all your suggestions. At the end, I would like to provide few lines of code, just in case, if someone can utilize it in future:
>
> library(quantmod)
> library(tseries)
> getSymbols("XPT/USD",src="oanda")
>
> # 2 time series,
> x<-XPTUSD
> y<-Lag(x,k=1)
>
> length(x)
>> 500
>
> ## fitting arma model on first 450 observations,
> fit <- arma(x[1:450], order = c(1, 0))
> fitted_model<-fit$fitted.values
>
>
> ## lets calculate it all, on a full length, 1:450 are same, 451:500 would be expost
> for (i in 1:500)
> fitted_manual[i]<-fit$coef[1]+(fit$coef[2]*y[i])
>
> ## for comparision, I show, that values fitted by model (fitted_model) are exactly the same as those, that were calculated with coefficients and lagged time series (fitted_manual), what its ##not a suprise :)))
>
> comparision<-cbind(fitted_mode,fitted_manual[1:450]);comparision   ## same
>
> ## so I thing, the last 50 values could be considered as expost predictions, because arma coeficients were estimated only on first 450 observations
> comparision_expost<-cbind(x[451:500],fitted_manual[451:500]);comparision_expost
>
> plot(comparision_expost[,1],type="l")
>

I tried running the code but it's having trouble early on with the
getSymbols command. Are downloads from Oanda supposed to be free and
open or are they subscription based?

> getSymbols("XPT/USD",src="oanda")
[1] "XPTUSD"
Warning message:
In readLines(tmp) :
  incomplete final line found on
'C:\DOCUME~1\Mark\LOCALS~1\Temp\RtmpDJGlT6\file7cac6eba'
>

The 'LOCALS~1' looks strange as the directory doesn't exist in my
directory. (Unless it's hidden by default.)

- Mark

_______________________________________________
[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.
markknecht@gmail.com