I’m trying to produce a hourly, daily forecast for revenue in R. I set seasonal periods to 24, for 24 hours, and 365.25 for days in a year. I attached the fit vs actual plot and the forecast produced by R.

I then fit the time series with the tbats model due to the high seasonal periods. I then try and forecast 8112 periods or just under 1 year.

My problem is that I keep getting a flat model$mean. However, the fitted vs actuals looks like its catching the seasonality.

rev_ts       <- msts(revenue_data, seasonal.periods=c(24,365.25))
rev_fit      <- tbats(rev_ts)
rev_forecast <- forecast(rev_fit,h=8112)
plot(rev_forecast )

Forecast Plot

Fitted vs Actual


Trying to reference your write-up here Rob:


So m=365.25? And n= # of observations? Sorry I'm a current student and new to R (and modeling for that matter). Where does this take into account hourly seasonality

Trying to implement your code from post using these lines of code:

m=365.25 (Where does this take into account hourly seasonality)

n= 25656 (number of observations, historical data)

rev_fit <- Arima(rev_ts, order=c(2,0,1), xreg=fourier(1:n,4,m))

plot(forecast(rev_fit, h=2*m, xreg=fourier(n+1:(2*m),4,m)))

Any explanation on the theory and what this is actually doing? Sorry for all the questions, but I'd love to understand this more fully.



1 Answer 1


The forecasts are not flat. The prediction intervals are extremely wide and highly skewed, so you can't see the variation in the point forecasts.

Most likely the point forecasts are actually reasonable, but the prediction intervals are clearly not.

You could try a regression model with Fourier terms for the seasonality, and ARMA errors for the remaining time series dynamics, applied to the logged data.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.