I am trying to forecast sales for a retail store. The given data has daily sales information and also a dummy flag variable to indicate whether the store was open or not on that day. The sales is 0 when the store is closed. The range of dates is from 2013-01-01 to 2015-07-31 (2 years and 7 months). I have been asked to forecast sales for the next 48 days

store_530_ts <- ts(store_530[,-1], frequency = 7)

Min. 1st Qu. Median Mean 3rd Qu. Max.

0 3024 4338 4457 5681 12476


The resulting plot is :

enter image description here

The acf plot shows that there is both weekly and daily seasonality (Am I right about this one?)


enter image description here

My Question is what is the best way to capture both the multiple seasonality and the holiday information in a single model? I tried fitting a regression model with ARIMA errors with "Open" as a explanatory variable. I used lambda=0 to log transform the sales. But I am getting the below error:

fit<-auto.arima(store_530_ts[, "Sales"], xreg = store_530_ts[, "Open"], 

Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) : 
NA/NaN/Inf in 'y

I understand that the error is because of the records with 0 sales. But, It does not feel right to simply ignore the 0 sales records from analysis.

Can someone tell me which is the best way to go about analyzing such time-series and what is that I am doing wrong. I am completely new to time-series analyis and any help would be much appreciated!

  • $\begingroup$ This one seems to me to be about statistics, not programming so I am voting to leave it open. $\endgroup$
    – Peter Flom
    May 21, 2018 at 11:28

1 Answer 1


You have weekly and annual seasonality, but not daily (as you only see one observation per day).

I would use set the 0s to NAs, and then use a dynamic harmonic regression with Fourier terms for the weekly and annual seasonalities. (See https://otexts.org/fpp2/complexseasonality.html#dynamic-harmonic-regression-with-multiple-seasonal-periods for the details). You need to set seasonal periods to c(7,365). The forecasts can be adjusted to 0 on future days where the store is closed.

It looks like you have some high sales days, possibly associated with promotions. Perhaps use a dummy variable to model them.

  • $\begingroup$ Thank you very much Rob! I really appreciate it! May I ask how did you determine that it has annual seasonality? Also, the dataset I have has already a binary variable to indicate whether a promotion was run on that day or not. So, as per your answer I am thinking of fitting a harmonic regression model and add this binary promotion variable as predictor to the xreg matrix along with the fourier term. Would this work?? $\endgroup$
    – spv92
    May 19, 2018 at 21:23
  • $\begingroup$ You have a periodic pattern with a peak around time 0, one at time 52, another at time 104. As you have set the frequency to 7, they correspond to peaks that are 52 weeks apart. Yes, adding the dummy to xreg along with fourier terms is what I was suggesting. $\endgroup$ May 20, 2018 at 3:19
  • $\begingroup$ Thanks a lot! I have two more questions: 1. When replacing 0's with NA's, how to handle increasing variance with time? 2.I have another example of a different store where the sales tend to peak on particularly around last two weeks of the year ..say around 23rd dec, 30th dec and the promotion was applied on most of these days. Since this happened for consecutive 2 years, I expect that to happen in the next year also. I am thinking of extracting the week of the year and creating a dummy variable for week 51 and 52. and including fourier and promotion terms. do you have any suggestions? $\endgroup$
    – spv92
    May 20, 2018 at 3:43
  • $\begingroup$ This is not a general consulting forum. Please ask new questions if you have them. $\endgroup$ May 20, 2018 at 4:04

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.