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.
I was wondering about this 2 outputs:
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