Single Exponential Smoothing - Excel : SAS : R
In the previous article of this series, we described basics about the time series and also enlisted the methods that can used for time series forecasting.
Let's now learn the methods one by one in details.
You HAVE TO read the following article(s) before reading this one, else it would not make much sense.
Time Series Forecasting - Part 1
Series Decomposition
Smoothing methods are based on the principle of decomposition of the series, we decompose the series into its components : Seasonality, level, trend, etc. and then using the components we forecast.
We will discuss it in more details, while covering Triple Exponential Smoothing (Holt Winter Method).
We will discuss it in more details, while covering Triple Exponential Smoothing (Holt Winter Method).
Single Exponential Smoothing (SES)
The method is used for a time series with NO SEASONALITY and NO TREND, such series are generally not very usual and not very interesting, but let's learn it for the sake of step wise learning.
SES using Excel
Since the series in case, we neither have seasonality nor we have trend, the series would look something like this :
Please download the attached file to understand the process of SES forecasting in Excel.
As you c find in the file, First in Sheet "Data Analysis" and "Seasonality Check", we have ploted the series to check the traces of TREND and SEASONALITY respectively. As we have found none, we performed SES in sheet "SES Calculations".
In Sheet SES calculation, monthly sales figures for 2010 Jan to 2013 Apr are given and we need to forecast for 2013 May.
In Column F, we first calculated first level/intercept value using INTERCEPT function in cell F3. Then F4 onward the above stated equation has been used to calculate the levels. Using the Levels in column F, forecast value has been calculated in column G. The ALPHA value can be iterated in cell J3 (but only between 0-1) and MAPE (Mean Absolute Percentage Error), which measures accuracy of forecast, is being calculated in cell J6.
SES using SAS
Download the csv file for using in SAS and R codes : SES sales.csv
/* ----------- Import the file ----------------------- */
Proc import datafile = "G:\AA\Time Series\SES sales.csv"
out = sales dbms = csv replace; Run;
/* ----------- Let's now use proc forecast ----------------------- */
Proc Forecst
DATA = sales
METHOD = EXPO /* for SES*/
TREND=1 /* fit a linear trend model for SES */
INTERVAL= month /* frequency of input time series*/
WEIGHT=(0.1) /* # specify alpha VALUE between 0 to 1 */
LEAD=1 /* #number of forecast periods*/
OUT = pred_results /* In this output dataset, we get forecasted values*/
OUTFULL
OUTRESID
OUTEST = model_stats; /* # goodness of fit measures, MAPE is most important*/
VAR Sales;
Run;
Run the code and check the results.
SES using R
setwd("G:\\AA\\Time Series")
data = read.csv("SES sales.csv")
# let's make the series a time series compatible to R
ts = ts(data$Sales, start=c(2010, 1), end=c(2013,4), frequency=12)
fit = stl(ts, s.window="period")
plot(fit)
# we need to install and use the package forecast
install.packages("forecast")
library(forecast)
# In these plots, we see if the series move together or not. If they do, they are seasonal, well in our case, definitely there is no seasonality.
# now let use SES to forecast
fit_1 = HoltWinters(ts, beta=FALSE, gamma=FALSE)
plot(forecast(fit_1, 1))
# and it is done !
In the subsequent articles of the series, we would cover other forecasting techniques enlisted in the first article of the series, till then ...
Enjoy reading our other articles and stay tuned with us.
Kindly do provide your feedback in the 'Comments' Section and share as much as possible.
The article has been written by Suyash Nigam with Rajat Agarwal as a co-author.
A humble appeal : Please do like us @ Facebook
No comments:
Post a Comment
Do provide us your feedback, it would help us serve your better.