I want to make a Recursive prediction. I need every month (t) to move the data window from the last month to the next in a period (this period, that is, t + 1).
dados<-read.table("C:/Biomedica/Doença/evolmensal.txt", header=T, dec=",")
dados.ts <- ts(dados, start=c(1998,03), freq=12)
periodo = window(dados.ts, start=c(1999,01),end=c(2007,12))
periodo
stat=c(2008,01)
dado_de_fora=window(dados.ts,start=stat)
recurs.pred1=ts(0,start=stat,end=c(2014,10),frequency=12)
Follow the looping:
for (t in 1:(length(dado_de_fora))) {
reg.recur1=arima(window(periodo,end=c(2007,11+t)),order=c(1,0,1))
recurs.pred1[t]=predict(reg.recur1,n.ahead=1)$pred
The problem I am facing is that when t equals 2 the window continues to take only the period end=c(2007,12)
ie it does not walk to end=c(2008,01)
and so on.
When I roll:
window(periodo,end=c(2007,11+3))
Should get as final data February 2008