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

Mark Knecht markknecht at gmail.com
Mon Dec 20 17:17:53 CET 2010


On Mon, Dec 20, 2010 at 3:58 AM,  <babel at centrum.sk> 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



More information about the R-SIG-Finance mailing list