This is a Retail sales dataset downloaded from Datamarket.com. I processed the data and performed the forecasting analysis.

library(rdatamarket)
## Loading required package: zoo
## 
## Attaching package: 'zoo'
## 
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
# fetch the data from data market
dminit("404ca002d8964fd682c3eb39a09dace1")
data <- dmlist("http://datamarket.com/data/set/3oei/retailers-sales#!ds=3oei")
# lets explore the data(first 5 rows) 
head(data)
##     Month  Value
## 1 1994-08 182445
## 2 1994-09 175128
## 3 1994-10 178642
## 4 1994-11 184272
## 5 1994-12 221549
## 6 1995-01 158004
names(data)
## [1] "Month" "Value"
tsdata<-data$Value
# convert to time series format
tseriesdata<-ts(tsdata,start=c(2006,10),end=c(2013,10),frequency=12)
# plot time series
plot.ts(tseriesdata)

plot of chunk unnamed-chunk-1

Though it does not look like having a multiplicative trend , yet to check that we will go for log transformation . this will convert it to additive trend if multiplicative trend exists.

r newts<-log(tseriesdata) plot(newts)

plot of chunk unnamed-chunk-2

As expected, it does not have any multiplicative trend. So we will perform seasonal decomposition to handle additive trend, seasonlity , and any irregular component if present.

# Seasonal decompostion
fit <- stl(tseriesdata, s.window="period")
plot(fit)

plot of chunk unnamed-chunk-3

# Lets check the seasonality ,if present
monthplot(tseriesdata)

plot of chunk unnamed-chunk-3

library(forecast)
## Loading required package: timeDate
## This is forecast 5.5
seasonplot(tseriesdata)

plot of chunk unnamed-chunk-3

fit<-ets(tseriesdata)
plot(fit)

plot of chunk unnamed-chunk-3

acf(tseriesdata)

plot of chunk unnamed-chunk-3

pacf(tseriesdata)

plot of chunk unnamed-chunk-3

# simple exponential - models level
fits <- HoltWinters(tseriesdata, beta=FALSE, gamma=FALSE)
accuracy(fits)
##                ME  RMSE   MAE   MPE  MAPE   MASE     ACF1
## Training set 5252 24870 17948 2.163 7.195 0.9418 -0.02458
# double exponential - models level and trend
fitd <- HoltWinters(tseriesdata, gamma=FALSE)
accuracy(fitd)
##                 ME   RMSE   MAE   MPE  MAPE  MASE   ACF1
## Training set 84837 149074 94682 1.831 7.397 4.969 0.9491
# triple exponential - models level, trend, and seasonal components
fite <- HoltWinters(tseriesdata)
accuracy(fite)
##                  ME   RMSE    MAE   MPE  MAPE  MASE   ACF1
## Training set 130882 186904 136227 1.512 5.502 7.149 0.9632
forecast1<-forecast(fite,5)
plot(forecast1)

plot of chunk unnamed-chunk-3

forecast2<-forecast(fitd,5)
plot(forecast2)

plot of chunk unnamed-chunk-3

acf(forecast1$residuals,lag.max=20)

plot of chunk unnamed-chunk-3

acf(forecast2$residuals,lag.max=20)

plot of chunk unnamed-chunk-3

tsforecast<-HoltWinters(log(tseriesdata))
plot(tsforecast)

plot of chunk unnamed-chunk-3

tsforecast
## Holt-Winters exponential smoothing with trend and additive seasonal component.
## 
## Call:
## HoltWinters(x = log(tseriesdata))
## 
## Smoothing parameters:
##  alpha: 0.3236
##  beta : 0
##  gamma: 0.7722
## 
## Coefficients:
##          [,1]
## a   12.706868
## b    0.004957
## s1   0.153936
## s2  -0.003740
## s3  -0.016749
## s4   0.089852
## s5   0.046179
## s6   0.137895
## s7  -0.001986
## s8  -0.041266
## s9   0.026064
## s10 -0.035710
## s11 -0.001709
## s12  0.043178
tsforecast$SSE
## [1] 0.5707
ftAsmooth<-forecast.HoltWinters(tsforecast,h=48)
plot.forecast(ftAsmooth)

plot of chunk unnamed-chunk-3