You are on page 1of 11

Tips&HintsTimeSeriesSmoothing 1 SpiderFinancialCorp,2012

Smoothing
Smoothingandfilteringaretwoofthemostcommonlyusedtimeseriestechniquesforremovingnoise
fromtheunderlyingdatatohelprevealtheimportantfeaturesandcomponents(e.g.trend,seasonality,
etc.).However,wecanalsousesmoothingtofillinmissingvaluesand/orconductaforecast.
Inthisissue,wewilldiscussfive(5)differentsmoothingmethods:weightedmovingaverage(WMA),
simpleexponentialsmoothing,doubleexponentialsmoothing,linearexponentialsmoothing,andtriple
exponentialsmoothing.
Whyshouldwecare?Smoothingisveryoftenused(andabused)intheindustrytomakeaquickvisual
examinationofthedataproperties(e.g.trend,seasonality,etc.),fitinmissingvalues,andconducta
quickoutofsampleforecast.
Whydowehavesomanysmoothingfunctions?Aswewillseeinthispaper,eachfunctionworksfora
differentassumptionabouttheunderlyingdata.Forinstance,simpleexponentialsmoothingassumes
thedatahasastablemean(oratleastaslowmovingmean),sosimpleexponentialsmoothingwilldo
poorlyinforecastingdataexhibitingseasonalityoratrend.
Inthispaper,wewillgoovereachsmoothingfunction,highlightitsassumptionsandparameters,and
demonstrateitsapplicationthroughexamples.
WeightedMovingAverage(WMA)
Amovingaverageiscommonlyusedwithtimeseriesdatatosmoothoutshorttermfluctuationsand
highlightlongertermtrendsorcycles.Aweightedmovingaveragehasmultiplyingfactorstogive
differentweightstodataatdifferentpositionsinthesamplewindow.

( )
1
1
N
i t i
i
t N
i
i
W X
Y
W

=
=


Where:
-
i
W istheithpositionfactor
- { }
t
X istheoriginaltimeseries
- { }
t
Y isthesmoothedtimeseries
-
t
Y usesthepriorNvaluesof
t
X observations(i.e.
1 1
{ , ,..., }
t N t N t
X X X
+
).

Tips&HintsTimeSeriesSmoothing 2 SpiderFinancialCorp,2012

Theweightedmovingaveragehasafixedwindow(i.e.N)andthefactorsaretypicallychosentogiven
moreweighttorecentobservations.
Thewindowsize(N)determinesthenumberofpointsaveragedateachtime,soalargerwindowssizeis
lessresponsivetonewchangesintheoriginaltimeseriesandasmallwindowsizecancausethe
smoothedoutputtobenoisy.
Foroutofsampleforecastingpurposes:

( )
( ) ( ) ( )
( ) ( ) ( ) ( )
( )
1 1
1
2 1 1 2 1 1 2
2 1 2
2
3 1 2 2 1 3 1 2 1 1 2 3
3 1 2 3
3 2
4 1 2 1 3 1 1 2
1
( )
( 2 ) ( )
N
T i T i
i
N N N
T T i T i i T i i T i
i i i
N N N N
T T T i T i i T i i T i i T i
i i i i
N
T i T i i
i
Y w X
Y wY w X w w X w X
Y wY w Y w X w w w X w w X w X
Y w w w w w X w w w
+ +
=
+ + + + +
= = =
+ + + + + + +
= = = =
+ +
=
=
= + = +
= + + = + + +
= + + + +

( ) ( ) ( )
2 1 3 4
2 3 4
N N N
T i i T i i T i
i i i
X w w X w X
+ + +
= = =
+ +

Where
- { }
i
w arethenormalizedweightfactors
Example1:LetsconsidermonthlysalesforCompanyX,usinga4month(equalweighted)moving
average.

Tips&HintsTimeSeriesSmoothing 3 SpiderFinancialCorp,2012

Notethatthemovingaverageisalwayslaggingbehindthedataandtheoutofsampleforecast
convergestoaconstantvalue.
Letstrytouseaweightingscheme(seebelow)whichgivesmoreemphasistothelatestobservation.

WeplottedtheequalweightedmovingaverageandWMAonthesamegraph.TheWMAseemsmore
responsivetorecentchangesandtheoutofsampleforecastconvergestothesamevalueasthemoving
average.
Example2:LetsexaminetheWMAinthepresenceoftrendandseasonality.Forthisexample,welluse
theinternationalpassengerairlinedata.Themovingaveragewindowis12months.

TheMAandtheWMAkeeppacewiththetrend,buttheoutofsampleforecastflattens.Furthermore,
althoughtheWMAexhibitssomeseasonality,itisalwayslaggingbehindtheoriginaldata.

Tips&HintsTimeSeriesSmoothing 4 SpiderFinancialCorp,2012

(Browns)SimpleExponentialSmoothing
SimpleexponentialsmoothingissimilartotheWMAwiththeexceptionthatthewindowsizeifinfinite
andtheweightingfactorsdecreaseexponentially.

1 1
2 1 1 1
3 2 2 1 2
2
4 3 3 1 2 3 1 2 3
3 2
5 4 4 1 2 3 4
1 1 1
1
1
1
(1 )
(1 ) (1 )
(1 ) (1 )((1 ) ) (1 ) (1 )
(1 ) (1 ) (1 ) (1 )
...
(1 ) (1 )
T
T T i
T i
i
T k T
k
Y X
Y Y X X
Y Y X X X
Y Y X X X X X X X
Y Y X X X X X
Y X X
Y Y
o o
o o o o
o o o o o o o o o o
o o o o o o o o
o o o

+ +
=
+ +
>
=
= + =
= + = +
= + = + + = + +
= + = + + +
= +
=

Where
- o isthesmoothingfactor( 0 1 o < < )
AswehaveseenintheWMA,thesimpleexponentialissuitedfortimeserieswithastablemean,orat
leastaveryslowmovingmean.
Example1:Letsusethemonthlysalesdata(aswedidintheWMAexample).

Intheexampleabove,wechosethesmoothingfactortobe0.8,whichbegsthequestion:Whatisthe
bestvalueforthesmoothingfactor?

Tips&HintsTimeSeriesSmoothing 5 SpiderFinancialCorp,2012

Estimatingthebest o valuefromthedata
Inpractice,thesmoothingparameterisoftenchosenbyagridsearchoftheparameterspace;thatis,
differentsolutionsfor o aretried,startingwith,forexample, o =0.1to o =0.9,withincrementsof
0.1.Theno ischosensoastoproducethesmallestsumsofsquares(ormeansquares)fortheresiduals
(i.e.,observedvaluesminusonestepaheadforecasts;thismeanssquaredtheerrorisalsoreferredto
asexpostmeansquarederror(expostMSEforshort).
UsingtheTSSUBfunction(tocomputetheerror),SUMSQ,andExceldatatables,wecomputedthesum
ofthesquarederrors(SSE)andplottedtheresults:

TheSSEreachesitsminimumvaluearound0.8,sowepickedthisvalueforoursmoothing.
(HoltWinters)DoubleExponentialSmoothing
Simpleexponentialsmoothingdoesnotdowellinthepresenceofatrend,soseveralmethoddevised
underthedoubleexponentialumbrellaareproposedtohandlethistypeofdata.
NumXLsupportsHoltWintersdoubleexponentialsmoothing,whichtakethefollowingformulation:

1 1
1
1
1 1 1
1 1 1
1
(1 ) ( )
( ) (1 )
T
t t t t
t t t t
t t
t
T T
S X
X X
B
T
S X S B
B S S B
S B t T
Y
S m B t T m
o o
| |
>
>
=

= + +
= +
+ <
=

+ = +

Where
- o isthesmoothingfactor( 0 1 o < < )

Tips&HintsTimeSeriesSmoothing 6 SpiderFinancialCorp,2012

- | isthetrendsmoothingfunction
Example1:Letsexaminetheinternationalpassengersairlinedata.

WechoseanAlphavalueof0.9andaBetaof0.1.Pleasenotethatalthoughdoublesmoothingtraces
theoriginaldatawell,theoutofsampleforecastisinferiortothesimplemovingaverage.
Howdowefindthebestsmoothingfactors?
Wetakeasimilarapproachtooursimpleexponentialsmoothingexample,butmodifiedfortwo
variables.Wecomputethesumofthesquarederrors;constructatwovariabledatatable,andpickthe
alphaandbetavaluesthatminimizetheoverallSSE.

Tips&HintsTimeSeriesSmoothing 7 SpiderFinancialCorp,2012

(Browns)LinearExponentialSmoothing
Thisisanothermethodofdoubleexponentialsmoothingfunction,butithasonesmoothingfactor:

'
1 1
''
1 1
' '
1 1
'' ' ''
1 1
' ''
1
' ''
(1 )
(1 )
2
( )
1
t t t
t t t
t T t t
t T t t
T m T T
S X
S X
S X S
S S S
a S S
b S S
Y a m b
o o
o o
o
o
>
>
s s
s s
+
=
=
= +
= +
=
=

= +

Where
- o isthesmoothingfactor
BrownsdoubleexponentialsmoothingtakesoneparameterlessthanHoltWintersfunction,butitmay
notofferasgoodafitasthatfunction.
Example1:LetsusethesameexampleinHoltWintersdoubleexponentialandcomparetheoptimal
sumofthesquarederror.

TheBrownsdoubleexponentialdoesnotfitthesampledataaswellastheHoltWintersmethod,but
theoutofsample(inthisparticularcase)isbetter.

Tips&HintsTimeSeriesSmoothing 8 SpiderFinancialCorp,2012

Howdowefindthebestsmoothingfactor(o )?
Weusethesamemethodtoselectthealphavaluethatminimizesthesumofthesquarederror.Forthe
examplesampledata,thealphaisfoundtobe0.8.

Tips&HintsTimeSeriesSmoothing 9 SpiderFinancialCorp,2012

(Winters)TripleExponentialSmoothing
Thetripleexponentialsmoothingtakesintoaccountseasonalchangesaswellastrends.Thismethod
requires4parameters:
1. o :thesmoothingfactor
2. | :thetrendsmoothingfactor
3. :theseasonalsmoothingfactor
4. L :theseasonlength
Theformulationfortripleexponentialsmoothingismoreinvolvedthananyoftheearlierones.Please,
checkouronlinereferencemanualfortheexactformulation.
Example:Usingtheinternationalpassengersairlinedata,wecanapplywinterstripleexponential
smoothing,findoptimalparameters,andconductanoutofsampleforecast.

Obviously,theWinterstripleexponentialsmoothingisbestappliedforthisdatasample,asittracksthe
valueswellandtheoutofsampleforecastexhibitsseasonality(L=12).
Howdowefindthebestsmoothingfactor( , , o | )?
Again,weneedtopickthevaluesthatminimizetheoverallsumofthesquarederrors(SSE),butthedata
tablescanbeusedformorethantwovariables,soweresorttotheExcelsolver:

Tips&HintsTimeSeriesSmoothing 10 SpiderFinancialCorp,2012

(1) Setuptheminimizationproblem,withtheSSEastheutilityfunction

(2) Theconstraintsforthisproblem

0 1
0 1
0 1
o
|

< <
< <
< <

(3) LaunchtheSolverandinitializeutilityandconstraints.

Tips&HintsTimeSeriesSmoothing 11 SpiderFinancialCorp,2012

(4) Thesolversearchesforoptimalsolution,ultimatelypromptingitscompletion.

(5) Theoptimalvaluesare:

Conclusion
Inthispaper,wedemonstratedtheuseofdifferentsmoothingfunctions,findingoptimalparameters
andprojectingforecastsforeach,whiledemonstratingscenariosinwhichparticularsmoothingmethods
maynotbeappropriate.
Youshouldalwaysvisuallyexaminethedataforsignsofseasonalityorlineartrend,andselecta
smoothingmethodbasedonyourfindings.
Inpractice,smoothingbasedforecastsareoftenusedforonetofewstepsandtheyarerelatively
accurate(giventheirsimplicity)comparedtomoresophisticatedmodels.

You might also like