theDate <- as.Date(end.date)
forec <- NULL
while (as.Date(theDate) < as.Date(end.date2)){
data <- tsales[paste(start.date,theDate,sep="::")]
fit <- auto.arima(data,xreg=na.omit(xreg[paste(start.date,theDate,sep="::")])*1)
fc <- forecast(fit, h=1,xreg=(xreg[theDate])*1)\$mean
forec <- c(forec,fc)
theDate <- as.Date(theDate) + 1
}


start.date/end.date are the start/end dates of my training period end.date2 is the end date of my test period.

forec:
2015-01-13 2015-01-14 2015-01-15 2015-01-16 2015-01-17
1034.266   1316.889   1250.597   1282.745   2875.170

testsales:
2015-01-15 1268
2015-01-16 1208
2015-01-17 2856


Why does forec starts at 01/13 ? Does it need a period to start forecasting?

thank you

• You would need to look at model summary to find out the order of your arima. It will skip that many observations before first forecast. – Arun Jose Oct 27 '16 at 19:12
• @ArunJose Put this as an answer and I'll close the topic :) – Tommaso Guerrini Nov 15 '16 at 11:09