I have 10 minutes-intervaled wait-times data for a coffee shop for 4 weeks between 9am-5pm. I use R's ts for my analysis. What should be the frequency parameter?
Is it (48=# of intervals per day) or just 1?
I have 10 minutes-intervaled wait-times data for a coffee shop for 4 weeks between 9am-5pm. I use R's ts for my analysis. What should be the frequency parameter?
Is it (48=# of intervals per day) or just 1?
Most likely you have two seasonal periods: 48 (number of intervals per day) and 48x5 (number of intervals per week assuming a 5-day week).
The tbats()
function from the forecast
package in R will handle multiple seasonal periods. For example (where x
is the data):
library(forecast)
x <- msts(x, seasonal.periods=c(48, 48*5))
fit <- tbats(x)
fc <- forecast(fit, h=48*5)
plot(fc)
Alternatively (and the only easy option if there are missing data) is to use Fourier terms for the seasonal periods and ARMA errors to handle any remaining serial correlation. The ARIMA functions in R do not automatically handle multiple seasonal periods, but the following R code should work:
x <- ts(x, frequency=48)
seas1 <- fourier(x, K=3)
seas2 <- fourier(ts(x, freq=48*5), K=3)
fit <- auto.arima(x, xreg=cbind(seas1,seas2))
seas1.f <- fourierf(x, K=3, h=48*5)
seas2.f <- fourierf(ts(x, freq=48*5), K=3, h=48*5)
fc <- forecast(fit, xreg=cbind(seas1.f,seas2.f))
The number of Fourier terms (arbitrarily set to 3 for both seasonal periods in the above code) can be selected by minimizing the AIC.