4
I want to make a recursive prediction. I need each month (t) to move the data window of the last month forward in a period (monthly 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’m facing is that when t equals 2 the window keeps taking only the period end=c(2007,12)
that is, does not walk towards end=c(2008,01)
and so on.
When I spin:
window(periodo,end=c(2007,11+3))
Should get as given end February 2008
Thanks, I’ll try! It seems I got it, but I used window. I added the command 'extend=TRUE' inside the window.
– Linkman