I am working on predicting a time series of daily data for one month that looks like this:
As can be seen, the time-series has a weekly seasonality. I am trying to predict the next week's data (horizon=7), updating my forecasts every day, so at each time-step, I am getting forecasts for the next 7 time-steps.
I have tried a number of methods but I would expect at least the snaive method to give me something reasonable. The code I am using is (tseries is an XTS object with the daily data):
for (t in horizon:(length(a)-horizon)) { # Every day
timeseries <- ts(a[1:(t+horizon)], frequency=7)
fit <- snaive(timeseries[1:t], h=horizon)
plot(forecast(fit, h=horizon))
lines(1:(t+horizon),timeseries, col='black')
}
The method consistently gives me flat predictions, looking like this:
Has anyone had any similar problems? Is it because I set frequency=7 for my daily data?
Best Answer
The answer from the comment of RandomDude:
snaive() gives you already a forecast btw
It did not work probably because of the way how the user sliced the ts-object, he actually just extracted the values