You are on page 1of 6

NumXLTips&HintsPatternsUnplugged 1 SpiderFinancialCorp,2012

PatternsUnplugged
ThisisthethirdissueinourARMAUnpluggedmodelingseries.Inthisissue,weintroducethecommon
patternsoftenfoundinrealtimeseriesdataanddiscussafewtechniquestoidentify/modelthose
patterns,pavingthewayformoreelaboratediscussiondecompositionandseasonaladjustment
methodologiesinfutureissues.
Whatarethecommonpatterns,andhowdoweidentifyandmodelthemtoderiveabetter
understandingoftheunderlyingprocess,andtobetterforecastourdata?Thatisthecentralquestion
forthisissue.
Background
Intimeseriesanalysis,ourmainobjectivesare(a)identifyingthenatureofthephenomenon
representedbythesequenceofobservations,and(b)forecasting(i.e.predicting)futurevaluesofthe
timeseriesvariable.
Oncethepatternisestablished,wecaninterpretandintegrateitwithotherdata(i.e.,useitinour
theoryoftheinvestigatedphenomenon,e.g.,seasonalcommodityprices).Regardlessofthedepthof
ourunderstandingandthevalidityofourinterpretation(theory)ofthephenomenon,wecan
extrapolatetheidentifiedpatterntopredictfutureevents.
Inthemajorityoftimeseriesdata,therearetwodominantsystematicpatternsoridentifiable
components:trendandseasonality.
Trendisthelinearor(moreoften)nonlinearcomponentthatchangeswithtimeanddoesnotrepeat
(oratleastnotwithinthesampledatascope)itself.
Seasonality,ontheotherhand,repeatsitselfinasystematicintervalovertime.
Trendandseasonalitymaysimultaneouslyexistinrealtimedata.Forexample,acompanyssalesofa
givenconsumerproductsmayexperiencevariationamongthemonthsoftheyear(e.g.Holidayseason),
whilethesalesofthatmonthgrowby10%comparedtothesalesofthesamemonthintheprioryear.
Soundsimple?Notreally:thepresenceofirregulars(i.e.noise,shocks,andinnovations)makesthose
componentshardtoidentify.
TrendAnalysis
Thereisnoautomaticmeansofidentifyingatrendcomponent,butasalongastrendismonotonous
(consistentincreasingortimeseriesdecreasing),avisualexaminationofthedataseriesplot(orthe
smoothenedversionifthedatahasalotofnoise)canquicklyrevealitspresence.

NumXLTips&HintsPatternsUnplugged 2 SpiderFinancialCorp,2012

Intheeventthetimeseriesexhibitsaseasonalitycomponent,youcanapplyamovingaverage(or
median)smoothingfunctionwithawindowsizeequaltothelengthofoneperiodtocanceloutnoise
andseasonalityandisolatethetrendcomponent.

Thetrendhereisassumedtobedeterministic;inotherwordsitfollowsafixedrelationshipwithtime.
Thetimeseriesmaypossessastochastictrend,inwhichcaseitcantbecapturedwithasimple
smoothingfunction.Welldiscussthislateron.
Seasonalityvs.Cycle
Often,weusethetermseasonality(orperiodicity)whenthetimeseriesexhibitsapatternthatrepeats
itself.Thepatterncanbevisuallydetectedinthetimeseriesplot,unlessthedatahaslotofnoise.
Inthisdiscussion,weneedtomakeafurtherdistinctionintwotypesofperiodicity:
Deterministic(Seasonality):Aseasonalpatternexistswhenitisinfluencedbyseasonalfactors
(e.g.quarteroftheyear,themonth,dayoftheweek).Seasonalityisfixedandknownperiod.
Thisiswhyweoftencallitaperiodictimeseries.
Stochastic(Cyclic)patternexistswhenthedataexhibitsrisesandfallsthatarenotfixedovera
period(stochastic).Thedurationofaperiodisusuallyseveralyears,butthedurationisnot
knownaheadoftime.Thebusinesscycleisoftenusedineconometricsliteratureasanexample
ofacycle.
Goingforward,wewillassumewemeanadeterministic,calendardriven,fixedperiodtypeof
seasonalitywheneverthebroadtermseasonalityisused.Cycle,ontheotherhand,willreferto
stochasticperiodicity.

NumXLTips&HintsPatternsUnplugged 3 SpiderFinancialCorp,2012

Seasonality
Seasonaldependencyisdefinedasacorrelationaldependencyoforderkbetweentheithcomponent
and(i+k)component.Ifthemeasurementerrorisnottoolarge,itcanbevisibleinthedata:visually
identifiedintheseriesasapatternthatrepeatseverykelements.
Theexponentialsmoothingfunction(e.g.winterstripleexponentialsmoothing)issuitabletocapture
seasonalityanddeterministictrend,butnotatimeserieswith(stochastic)cycles.
Cycle
Forstochasticcycles(i.e.periodicitywithanonfixedperiodorunknownduration),wecanusean
ARMA(p,q)typeofprocess:withanautoregressivecomponentorder(p)greaterthanone(1)and
additionalconditionsontheparametersvaluestoobtaincyclicity.
Forexample,considertheARMA(2,q)process:

2
1 2
1
(1 )( ) (1 )
q
i
t i t
i
L L r L a | | u
=
= +


Let:

1
2
2
1 2
0
0
4 0
|
|
| |
>
<
+ <

ThenARcharacteristicequationpossessesacomplexroot,andcanberepresentedasfollows:

2
1 1 2
2
4
2
j
| | |
o e
|
+
= =


TheACFplotofthisprocessexhibitsexponentialdampingsineandcosinewaves.Theaveragelengthof
thestochasticcycle k is:

1
1
2
2
cos
2
k
t
|
|

=
| |
|
|

\ .

SeasonalityandCyclicity
ItispossibletohavebothcyclicandseasonalbehaviorinanARMAtypemodel:SeasonalARIMA(aka
SARIMA).Forthegeneralcase,aSARIMA ( )( ) , , , ,
s
p d q P D Q processisdefinedasfollows:

NumXLTips&HintsPatternsUnplugged 4 SpiderFinancialCorp,2012

( ) ( )(1 ) (1 ) ( ) ( )
( ) ( )
(1 ) (1 )
( ) ( )
s s D d s
t t
s
s D d
t t s
L L L L y L L a
L L
L L y a
L L
| u
u
|
u = O
O
=
u

Where:
s s isthelengthoftheseasonalperiod(deterministic)
WellcoverSARIMAingreaterdetailinfutureissues.
Note:LongperiodcyclicityisnothandledverywellintheARMAframework.Alternative(nonlinear)
modelsareusuallypreferred.
TimeSeriesDecomposition
Ingeneral,thetimeseries{ }
t
y canbebrokendownintotwoprimarysystematiccomponents:trend
{ }
t
T andseasonality{ }
t
S ,witheverythingelselumpedunderIrregulars{ }
t
I (ornoise).
TheIrregulars(residuals)component{ }
t
I capturesallthenonsystemic(i.e.deterministic)propertiesof
thetimeseries,sotoimproveourforecastfurtherwecanmodel{ }
t
I withanARMAtypeofmodel(e.g.
regARIMA).
Thetimeseriescanbemodeledasthesum(i.e.additivedecomposition)ortheproduct(multiplicative
decomposition)ofitscomponents.
Additivedecomposition
Insometimeseries,theamplitudeofboththeseasonalandirregularvariationsdonotchangeasthe
levelofthetrendrisesorfalls.Insuchcases,anadditivemodelisappropriate.
Letsexaminetheformulation:

t t t t
y T S I = + +
Toremovetheseasonaleffect(seasonaladjustment)fromthetimeseries:

t t t t t
SA y S T I = = +
Where:
-
t
T isthetrendcomponent
-

t
S istheestimatedseasonalitycomponent

NumXLTips&HintsPatternsUnplugged 5 SpiderFinancialCorp,2012

Note:Underthismodel,thethreecomponents( , ,
t t t
I S T )havethesameunitsastheoriginalseries{ }
t
y
.
MultiplicativeDecomposition
Inmanytimeseries,theamplitudeofboththeseasonalandirregularvariationsincreaseasthelevelof
thetrendrises.Inthissituation,amultiplicativemodelisusuallyappropriate.

t t t t
y T S I =
Toremovetheseasonaleffectfromthedata:

t
t t t
t
y
SA T I
S
= =

Note:Underthismodel,thetrendhasthesameunitsastheoriginalseries,buttheseasonaland
irregularcomponentsareunitlessfactors,distributed(centered)around1.
PseudoAdditiveDecomposition
Themultiplicativemodelcannotbeusedwhentheoriginaltimeseriescontainsverysmallorzero
values.Thisisbecauseitisnotpossibletodivideanumberbyzero.Inthesecases,apseudoadditive
modelcombiningtheelementsofboththeadditiveandmultiplicativemodelsisused.
( 1) ( 1) ( 1)
t t t t t t t t t
y T T S T I T S I = + + = +

NumXLTips&HintsPatternsUnplugged 6 SpiderFinancialCorp,2012

Note:Underthismodel,thetrendhasthesameunitsastheoriginalseries,buttheseasonaland
irregularcomponentsareunitlessfactors,distributed(centered)around1.
Thismodelassumesthatseasonalandirregularvariationsarebothdependentonthelevelofthetrend
butindependentofeachother.
Theseasonaladjustedseriesisdefinedasfollows:


( 1)
t t t t
SA y T S =
Where:
-

t
T istheestimatedtrendcomponent
-

t
S istheestimatedseasonalitycomponent
Conclusion
Inrealtimeseriesdata,thetwoprimarypatternsoftenobservedaretrendandseasonality.
Furthermore,thetimeseriesdataincludeanoiseorerrortermwhichlumpsallnonsystematicfactors
togetherandasaresultmakestheidentificationofthosecomponentsabitdifficult.Asmoothingor
filteringproceduremayberequiredtopreparethedataforanalysis
Seasonalityisdescribedasarepeateddeterministicpattern(i.e.upsanddowns)thatisdrivenprimarily
bycalendarrelatedfactors(e.g.dayofweek,monthoftheyear,holiday,etc.).Cyclicity,ontheother
hand,isstochasticinnatureanddoesnothaveafixedorknownperiod.
Inshort,agiventimeseriescanbeviewedasacompositionofoneormoreprimitiveseries(systematic
(i.e.deterministic)orstochastic).
Therearetwodistincttypesofdecompositionmodels:additiveandmultiplicative.Thedecisionofwhich
modeltousedependsontheamplitudeofboththeseasonalandirregularvariations.Iftheydonot
changeasthelevelofthetrendrises,thenadditivedecompositionisinorder;otherwiseamultiplicative
oneisused.Multiplicativedecompositionisfoundinthemajorityoftimeseries.
Thisissueisintendedtoserveasapreliminaryexercisefortimeseriesdecompositionandtimeseries
seasonaladjustment.

You might also like