Forecasting with daily data
R-bloggers 2013-09-17
Summary:
I’ve had several emails recently asking how to forecast daily data in R. Unless the time series is very long, the simplest approach is to simply set the frequency attribute to 7. y <- ts(x, frequency=7) Then any of the usual time series forecasting methods should produce reasonable forecasts. For example library(forecast) fit <- ets(y) fc <- forecast(fit) plot(fc) When the time series is long enough to take in more than a year, then it may be necessary to allow for annual seasonality as well as weekly seasonality. In that case, a multiple seasonal model such as TBATS is required. y <- msts(x, seasonal.periods=c(7,365.25)) fit <- tbats(y) fc <- forecast(fit) plot(fc) This should capture the weekly pattern as well as the longer annual pattern. The period 365.25 is the average length of a year allowing for leap years. In some countries, alternative or additional year lengths may be necessary. For example, with the Turkish electricity data analysed in De Livera et al (JASA 2011), we used three seasonal periods: 7, 354.35 and 365.25. The period 354.37 is the average length of the Islamic calendar. Capturing seasonality associated with moving events such as Easter or the Chinese New Year is more (More)…