### Triple Exponential Smoothing - Excel : SAS : R

In the

**previous article**of this series, we explained Double Exponential Smoothing method, also called Holt's method for time series forecasting. Now we are taking up TES also called Holt Winter's Method.

Once we are done with this article we are all set to learn ARIMA.

You HAVE TO read the following articles before reading this one, else it would not make much sense.

**Time Series Forecasting - Part 1****(Overview)****Time Series Forecasting - Part 2****(SES)****Time Series Forecasting - Part 3 (DES)**

### Triple Exponential Smoothing (TES)

The method is used for a time series with

In TES method, first we need to check the presence of seasonality and trend in the time series and then we check the nature of trend. The trend can be either

You can see that, calculations of Level, Slope (Trend) and seasonality for first observations i.e. in cells

The value of

Rest remains same, you need to check MAPE for accuracy of forecast.

out = data_1 dbms = csv replace; Run;

PROC FORECAST DATA = data_1

METHOD = ADDWINTERS /* for Additive and

TREND= 3 /* fit a linear trend model for TES */

INTERVAL = month /* frequency of input time series*/

SEASONS = 12 /* Use this option for Holts Winter Method*/

nsstart = 2 /* give number of season for special seasonal effect*/

WEIGHT = (0.7, 0.1, 0.4) /*In TES method Alpha , Beta and gamma VALUE between 0 to 1 */

LEAD = 3 /* number of forecast */

OUT = pred_results /* FORECASTE VALUE WITH ACTUAL VALUE*/

OUTFULL

OUTRESID

OUTEST = model_stats; /* MODEL STATS VALUE WITH MAPE VALUE*/

VAR Sales;

RUN;

###

setwd("G:\\AA\\Time Series")

data = read.csv("TES sales.csv")

ts = ts(data$Sales, start=c(2010, 1), end=c(2012,12), frequency=12)

fit = stl(ts, s.window="period")

plot(fit)

if(!require(forecast)) install.packages("forecast")

library(forecast)

seasonplot(ts)

fit_1 = HoltWinters(ts)

forecast(fit_1, 3)

plot(forecast(fit_1, 3))

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.

**SEASONALITY**and a**TREND**, such series are generally interesting as we would learn to deal with trend as well as Seasonality, so let's learn it.
Please download the file to understand the calculation of TES better .

**TES Demo File****Mathematical Equations for TES****ADDITIVE**or**MULTIPLICATIVE**in mature. We have illustrated the same in sheet "**Additive or Multiplicative**". We need to use the equation according to nature of the trend.You can see that, calculations of Level, Slope (Trend) and seasonality for first observations i.e. in cells

**F3**,**G3**and**H3**of sheet**TES Calculation**are exceptional, second equation onward equations as shown below have been used.**In the forecasting window, formula is different, as the last observation's Level and Trend are used for forecasting along with Seasonality of the last occurrence of respective month.**The value of

**α, β**and**𝜸**lies between 0 and 1.Rest remains same, you need to check MAPE for accuracy of forecast.

**/* First import the time series data*/**

**Proc import datafile = "G:\AA\Time Series\TES sales.csv"**

out = data_1 dbms = csv replace; Run;

**/* Then use the Proc Forecast*/**

PROC FORECAST DATA = data_1

METHOD = ADDWINTERS /* for Additive and

**METHOD = WINTERS for**

**Multiplicative S**

**eries***/

TREND= 3 /* fit a linear trend model for TES */

INTERVAL = month /* frequency of input time series*/

SEASONS = 12 /* Use this option for Holts Winter Method*/

nsstart = 2 /* give number of season for special seasonal effect*/

WEIGHT = (0.7, 0.1, 0.4) /*In TES method Alpha , Beta and gamma VALUE between 0 to 1 */

LEAD = 3 /* number of forecast */

OUT = pred_results /* FORECASTE VALUE WITH ACTUAL VALUE*/

OUTFULL

OUTRESID

OUTEST = model_stats; /* MODEL STATS VALUE WITH MAPE VALUE*/

VAR Sales;

RUN;

Run the code and check the results.

###
__TES using R__

**# First import the time series data**

data = read.csv("TES sales.csv")

**# let's make the series a time series compatible to R**ts = ts(data$Sales, start=c(2010, 1), end=c(2012,12), frequency=12)

**# Lets decompose the series and see if any trend or seasonality is there.**fit = stl(ts, s.window="period")

plot(fit)

**# and we get these plots >>>>>>>>>>>>>>>>****# we need to install and use the package forecast**if(!require(forecast)) install.packages("forecast")

library(forecast)

**# let's now learn plotting classical seasonality plot**seasonplot(ts)

**# 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 definitely a seasonality. Not showing here as we have shown these plots earlier.****# now let use TES to forecast**fit_1 = HoltWinters(ts)

forecast(fit_1, 3)

plot(forecast(fit_1, 3))

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