1
$\begingroup$

I am trying to forecast the sales for next 48 days from the data given by modelling for multiple seasonality and day of week , promotional effects. R could not come up with a suitable model. I need help to figure out what I am doing wrong.

Given data has daily sales information of a store for 2 years and 7 months along with other information like holidays, promotion, week of year etc as shown below. Sales is 0 when store is closed. I have replaced 0 sales with NA's as mentioned in this post https://stats.stackexchange.com/q/347074/208891

As it can be seen from the below 2 screenshots, sales are highest during mondays and when promotion=1. sales hit the bottom on sundays when promo=0

enter image description here

enter image description here

I found that, the series shows both weekly and yearly seasonality using the results of tbats:

yearly <- ts(store_578[,6], frequency=365)
fit_yearly <- tbats(yearly)
seasonal <- !is.null(fit_yearly$seasonal)
weekly <- ts(store_578[,6], frequency=7)
fit_weekly <- tbats(weekly)
seasonal <- !is.null(fit_weekly$seasonal)

So, I created a multi seasonality time series

store_578_ts <- msts(store_578[,-1], seasonal.periods=c(7,365))
autoplot(store_578_ts[,5])

The resulting plot:

enter image description here

I built a dynamic harmonic regression model with fourier terms for multiple seasonality. To model the day of week effects that I mentioned above, I created 6 dummy variables (day1,day2..day6) and included them along with promotion and foruier terms

dummy<-cbind(Day1=store_578_ts[,"day1"],Day2=store_578_ts[,"day2"],Day3=store_578_ts[,"day3"],Day4=store_578_ts[,"day4"]
         ,Day5=store_578_ts[,"day5"],Day6=store_578_ts[,"day6"],promo=store_578_ts[,"Promo"])
xreg <- cbind(fourier(store_578_ts[,"Sales"], K = c(1,3)),dummy)
fit_578 <- auto.arima(store_578_ts[,"Sales"], xreg = xreg, lambda=0,seasonal = FALSE, stationary = TRUE)


Error in auto.arima(store_578_ts[, "Sales"], xreg = xreg, seasonal = FALSE,  
:   No suitable ARIMA model found

Am I missing something here? I really need some help with this.

Note:It is able to get me a model if I use only weekly seasonality, instead of multiple.

$\endgroup$
  • $\begingroup$ The dummy variables are confounded with the Fourier terms. $\endgroup$ – Rob Hyndman May 21 '18 at 5:43
  • $\begingroup$ Sir, I am not sure if I get that. I have added the dummy variables and fourier terms in a single xreg matrix. $\endgroup$ – spv92 May 21 '18 at 5:49
  • $\begingroup$ Don't add the dummy variables. You don't need them. The Fourier terms handle the day-of-week seasonality. $\endgroup$ – Rob Hyndman May 21 '18 at 5:51
  • $\begingroup$ ARIMA is not suitable for daily data as daily data might have multiple seasonalities. tbats can capture multiple seasonalities. $\endgroup$ – Ferdi May 21 '18 at 6:52
  • $\begingroup$ @Ferdi. The question was proposing a dynamic harmonic regression which does allow for multiple seasonality. $\endgroup$ – Rob Hyndman May 21 '18 at 9:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.