Solved – do Time series forecasting on daily ATM transaction data

rtime series

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

Best Answer

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.

Update:

#load your data into R
require('data.table')
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)

require('forecast')

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

#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)
plot(fc.arima)

#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.