[R-SIG-Finance] Expost prediction for ARMA or GARCH

babel at centrum.sk babel at centrum.sk
Mon Dec 20 12:58:09 CET 2010


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



More information about the R-SIG-Finance mailing list