I have a data for ATM transaction on a daily basis and this data represent a seasonal variation in weekend and holidays.

data structure like this

trans_date  tot_amount  Weekend Holiday_flag
01/10/2013  164800  0   0
02/10/2013  205900  0   1
03/10/2013  215600  0   0
04/10/2013  228600  0   0
05/10/2013  410200  1   0

I used arima() function in R to forecast the next one month data but I am not getting better forecast.

I am confusing to capture seasonal variation in my data.

I have to select the ARIMA order from ACF and PACF plot but I have some confusion to capture seasonal order from this graph.

So please advise me how can I select the right ARIMA model for my data


2 Answers 2


have you tried a "simple" tbats approach with multiple seasonalities yet as explained here: link

I would suggest you are getting familiar with the forecast package of Rob J Hyndman. There is also a really good book from him that is available online for free link

As for your Arima approach i would suggest you use the auto.arima() function in the forecast package. There you can include dummy variables including Fourier terms (as explained in the first link). Here is another example for that method link

IrishStat is for sure not wrong when he says that it is hard to make such forecasts "simply" with R - but (based on my own i experience) it is possible to get some good/decent results.


#load your data into R
dat <- fread('data.csv') #only the date and the amount column
setnames(dat, c(1,2), c('date', 'amount'))
dat$date <- as.Date(dat$date, '%d/%m/%y') #transform date column into real dates    
dat[,Weekday := weekdays(date)] # create a column for the weekdays

#create a time series
dat.ts <- ts(dat$amount, frequency=7)


#fit a tbats model, forecast 30days, and plot it
fm.tbats <- tbats(dat.ts)
fc.tbats <- forecast(fm.tbats, h=30)

#fit an arima model with a fourier term, forecast 30days and plot it
fm.arima <- auto.arima(dat.ts, xreg=fourier(dat.ts, 3))
fc.arima <- forecast(fm.arima, xreg=fourierf(dat.ts,3,30), h=30)

#fit an arima model with dummies for day of the week
dummies <- cbind(model.matrix(~dat$Weekday)[,2:7])
colnames(dummies) <- c('Tue','Wed','Thu','Fri','Sat','Sun')
fm.arima.d <- auto.arima(dat$amount, xreg=dummies)

That is how you can use auto.arima() and tbats() to work with your data. I am not saying anything about if it is good/fits your data/whatever - i just wanted to show you how to use it in the right way. When your dataset is less then a year you can also test other functions in the forecast package like stl() for example. When you type ?stl() you will see the help file for the function which normally includes a simple example on how it works. I highly recommend you to have a look at the book from Rob J Hyndman.

  • $\begingroup$ I would be interested in investigating/disproving your assertion of getting good/decent results with Fourier approaches as my experience tells me otherwise . Perhaps you might want to pursue this with me and perhaps we can both learn something. $\endgroup$
    – IrishStat
    Commented Oct 15, 2015 at 11:04
  • $\begingroup$ @random Dude i tried forecasting using auto.arima() function but it give error to Unable to fit final model using maximum likelihood. AIC value approximated. $\endgroup$
    – Shahnawaz
    Commented Oct 16, 2015 at 12:17
  • $\begingroup$ After giving some optional in auto.arima() it fitted model but its not giving forecasting value correct, means i getting this value are same for all h=10. $\endgroup$
    – Shahnawaz
    Commented Oct 16, 2015 at 12:19
  • $\begingroup$ i also tried tbats and fourier series but not getting satisfied results. $\endgroup$
    – Shahnawaz
    Commented Oct 16, 2015 at 12:20
  • $\begingroup$ I trying with arima function in R with seasonality and also add dummy variable in that for weekdays beacause so many seasonality present in my data in weekdays and weekdays $\endgroup$
    – Shahnawaz
    Commented Oct 16, 2015 at 12:22

Selecting the "right" ARIMA model for data like this is not the preferred choice . You might want to look at an alternative variable-driven example that uses daily atm machine data http://www.autobox.com/cms/index.php/afs-university/intro-to-forecasting/doc_download/53-capabilities-presentation starting at slide 45. The whole idea is to incorporate ( as needed ) daily effects,weekly effects . monthly effects , specific week-in-month effects , specific day-in=month effects , activity around known events like holidays , long-weekend effects , Friday before holiday events , Monday after holiday events , level-shifts , time trends , pulses and changes in day-of-the-week effects and any causal variables that you might like to suggest . You can possibly program these exploratory activities yourself but it might be tedious. I was one of the developers of AUTOBOX and so state for transparency and for any kudos you might like to send my way (grin).

  • $\begingroup$ But i want to do this forecasting in R using time series forecasting.I think i need to add dummy variable in xreg in arima function. So please help me do this forecasting in R $\endgroup$
    – Shahnawaz
    Commented Oct 13, 2015 at 4:13
  • $\begingroup$ In order to add these dummy variables you need to know which ones are important e.g. how many days before and after each holiday are important or how many different trends there are. Once you figure those out then you can use R . $\endgroup$
    – IrishStat
    Commented Oct 13, 2015 at 10:45
  • $\begingroup$ yes i figure out that from ACF and PACF plot and i found that mostly variation are in weekends. Means transaction are more on Friday and saturday and least on Sunday i want to add dummy variable on weekend so please suggest how to add this dummy variable in my model $\endgroup$
    – Shahnawaz
    Commented Oct 14, 2015 at 4:57
  • $\begingroup$ I used ARIMA model with seasonal difference bellow are the r code for it. w1_diff_arima<-arima(p1_ts,order=c(0,1,3),seasonal=list(order=c(0,1,3),xreg=xtrain,periods=7)). p1_ts is my time series data conatin tot_transaction amount and i am using xreg function in arima for adding the regressor. xtrain is the combination of holiday_flag and weekend. Weekend :-0 indicate no weekend and 1 indicate saturday and sunday i.e weekend. and holiday flag :- 0 no holiday and 1: there is holiday $\endgroup$
    – Shahnawaz
    Commented Oct 14, 2015 at 7:43
  • $\begingroup$ i took period =7 because more variation are seems in weekend. I am getting the nearest results but not actual forecast. some variation are there. i got bellow result using above arima function. $\endgroup$
    – Shahnawaz
    Commented Oct 14, 2015 at 8:40

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.