Dear R helping team,
I am trying to check if the model I fitted is the best fitted model from the
data. I have over all 392 data, I want to fit the model in the first 382 data
and do 10 step predictions, check whether my model fits the last 10 data well.
Here is the R code I wrote
da<-read.table(file.choose(),header=T)
y <- data.frame(time seq(as.Date('2007-01-07'), by = 'weeks',
length = 392))
#produce a vector that can show the dates
of the exchange rates.#
ex<-da[,2]
mod <- list()
mod[["linear"]] <- linear(ex, m = 4)
mod[["setar"]] <- setar(ex, m = 4,
thDelay = 1)
mod[["lstar"]] <- lstar(ex, m = 4,
thDelay = 1)
mod[["nnetTs"]] <- nnetTs(ex, m = 4,
size = 3)
mod[["aar"]] <- aar(ex, m = 4)set.seed(10)mod.test <-
list()ex.train <- window(ex, end = 380)ex.test <- window(ex, start =
381)mod.test[["linear"]] <- linear(ex.train, m =
4)mod.test[["setar"]] <- setar(ex.train, m = 4, thDelay =
1)mod.test[["lstar"]] <- lstar(ex.train, m = 4, thDelay = 1, trace
= FALSE,control = list(maxit = 1e+05))mod.test[["nnet"]] <-
nnetTs(ex.train, m = 4, size = 3, control = list(maxit =
1e+05))mod.test[["aar"]] <- aar(ex.train, m = 4)
frc.test <- lapply(mod.test, predict, n.ahead = 10)plot(ex.test, ylim =
range(ex))for (i in 1:length(frc.test))     lines(frc.test[[i]], lty = i + 1,
col = i + 1)legend(381, 0.5, lty = 1:(length(frc.test) + 1), col =
1:(length(frc.test) +1), legend = c("observed", names(frc.test)))
I am expecting to have some plot like the graph on page 20 of this link
http://cran.r-project.org/web/packages/tsDyn/vignettes/tsDyn.pdf
but I get the picture,please see attachment.
here is the first few lines of my data> head(da)    End_Date USD_GBP1
07/01/2007  0.51222 14/01/2007  0.51523 21/01/2007  0.50834 28/01/2007  0.50735
04/02/2007  0.50946 11/02/2007  0.5097
I attached my data as well just in case you may need it.
Thank you very much for your help!!
Kind regards
Penny